Re: Induction problem ? (Atleast I think it is that :)
- From: RobertSzefler <NOSPAMrszeflerNOSPAM@xxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 11:38:50 +0100
Vinay wrote:
Hi,
I recently came across the following code:
const double epsilon = 1.0e-15; double compute(double m) { double x = m; double y = 1.0; while(x - y > epsilon ) { x = (x+y)/2; y = m/x; } return x; }
This function returns the square-root for given value(m). I tried solving this algebraically but expression got too complex. Can anybody point me how one can PROVE this to be true. I don't remember seeing any expansions for square-root similar to say that of log(x), or sin(x) - in case there is one please do mention it.
Vinay
PS: I tried looking up at recurring function solutions for square-root ( of the type y/(1+y/1+y(1/...))) but drew a blank.
This algorithm is elementary and widely known as the Newton formula. For proof, see for example:
http://mathews.ecs.fullerton.edu/n2003/newtonsmethod/Newton'sMethodProof/Links/Newton'sMethodProof_lnk_3.html
BTW, the method can be applied, after making appropriate substitutions, to computing sin and log as well.
HTH .
- Follow-Ups:
- Re: Induction problem ? (Atleast I think it is that :)
- From: John Gabbriel
- Re: Induction problem ? (Atleast I think it is that :)
- From: Vinay
- Re: Induction problem ? (Atleast I think it is that :)
- References:
- Prev by Date: Induction problem ? (Atleast I think it is that :)
- Next by Date: Re: Induction problem ? (Atleast I think it is that :)
- Previous by thread: Induction problem ? (Atleast I think it is that :)
- Next by thread: Re: Induction problem ? (Atleast I think it is that :)
- Index(es):