[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Computing square-root of two [Was: Re: No subject]
From: |
Vic Norton |
Subject: |
Computing square-root of two [Was: Re: No subject] |
Date: |
Fri, 17 Feb 2012 11:51:43 -0500 |
On Fri, 2012-02-17 at 10:24 +0100, joseph appau wrote:
> please i need help in how to find" square root of 2" in 15 significant
> figures
>
printf ("%.15f\n", sqrt(2));
produces
1.414213562373095
With
function x = approxroot2(n)
x = 2;
while n
printf ("%.15f\n", x - 1);
x = 2 + 1/x;
n--;
endwhile
x -= 1;
printf ("%.15f\n", x);
endfunction
approxroot2(25);
produces
1.000000000000000
1.500000000000000
1.400000000000000
1.416666666666667
1.413793103448276
1.414285714285714
1.414201183431953
1.414215686274510
1.414213197969543
1.414213624894870
1.414213551646055
1.414213564213564
1.414213562057320
1.414213562427273
1.414213562363800
1.414213562374690
1.414213562372821
1.414213562373142
1.414213562373087
1.414213562373096
1.414213562373095
1.414213562373095
1.414213562373095
1.414213562373095
1.414213562373095
1.414213562373095
Re:, Martin Helm, 2012/02/17
Re: your mail, lxnf98mm, 2012/02/17
Computing square-root of two [Was: Re: No subject],
Vic Norton <=