TASK: Estimate the arithmetic-geometric mean.
COMMENT: Given two positive real numbers X and Y:
the arithmetic mean is a(x,y) = (x+y)/2.
the geometric mean is g(x,y) = sqrt(x*y).
The arithmetic-geometric mean is computed as follows:
a0 = x
g0 = y
a1 = a(a0,g0)
g1 = g(a0,g0)
a2 = a(a1,g1)
g2 = g(a1,g1)
...
Each time we compute a new pair of values, they get closer and closer,
and converge to the arithmetic geometric mean.
INSTRUCTIONS:
Use the input() statement to get values of x and y.
Create a for loop in which i goes from 1 to 10.
(We figure the process will converge in about 10 steps).
Move your new data to "old" data:
x0 = x
y0 = y
Compute your new data, x = a ( x0, y0 ), y = b ( x0, y0 ):
x = ?
y = ?
end your FOR loop
fprintf ( ' AGM estimates are %g and %g\n', x, y );
If you are doing things correctly, you should find that the
AGM of 4 and 9 is about 6.247.
SUBMIT: Your work should be stored in a script file called "hw022.m". Your script file should begin with at least three comment lines:
% hw022.m
% YOUR NAME
% This script (describe what it does)
% Add any comments here that you care to make.
If this problem is part of an assignment, then submit it to Canvas.