Write a script that does the following. Assign two unequal positive numbers to x and y (for example, two different digits of your SUID). Compute their arithmetic mean \(a = \dfrac{x+y}{2}\) and geometric mean \(g = \sqrt{xy}\text{.}\) Then display the arithmetic mean of \(a\) and \(g\text{.}\) Finally, display the geometric mean of \(a\) and \(g\text{.}\)
Answer.
x = 4; y = 7; a = (x+y)/2; g = sqrt(x*y); disp((a+g)/2) disp(sqrt(a*g))
Remark: Karl Gauss discovered that if the above process of taking arithmetic and geometric means is repeated, both these means quickly converge to the same number. This number is called the arithmetic-geometric mean of x and y. It is linked to certain integrals which cannot be evaluated with calculus methods, and therefore provides an efficient computational approach to such integrals. For more, see Wikipedia.
