Geometric mean

Here is my riddle of the day for you. Explain why the following piece of Matlab code returns the following

x=5.477226, y=5.477226

Here is the piece of code:

%lasting gemsfunction

function blog1(x0,y0)

for i = 1 : 100000
x = (x+y)/2;
y = 2*tmp*y/(tmp+y);

fprintf(‘x=%f, y=%f\n’,x,y);

Also, generalize the above example and realize that the above gives you a numerical procedure to find the geometric mean of two numbers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: