Re: newtons method, notation

• To: mathgroup at smc.vnet.net
• Subject: [mg21233] Re: newtons method, notation
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Mon, 20 Dec 1999 02:27:53 -0500 (EST)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <831voa\$g9v@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Lots of ways to do Newton's method.  Here's a crude functional approach:

newt[f, estimate_] := estimate - f[estimate]/f'[estimate]  (* one
step *)

Say you want to estimate Sqrt[2] numerically:

f[x_] := x^2 - 2

NestList[newt[f, #]&, 1., 10]   (* iterate 10 times, initial estimate
1. *)
{1., 1.5, 1.41667, 1.41422, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421,
\
1.41421, 1.41421}

To see all 15 machine digits for that floating-point calculation:

NumberForm[NestList[newt[f, #] &, 1., 10], 15]
{1., 1.5, 1.41666666666667, 1.41421568627451, 1.41421356237469, \
1.4142135623731, 1.4142135623731, 1.4142135623731, 1.4142135623731, \
1.4142135623731, 1.4142135623731}

Of course, you can also use "arbitrary" precision, say by forcing the
initial estimate to have a precision > \$MachinePrecision.  And of course
an explicitly iterative procedural form can be written -- but why bother
when the iteration is done automatically, at a deeper level, by the
built-in function NestList.

(I called the method "crude" because there's no test for f' vanishing at
one of the iterates.)

If you just want the last iterate, use Nest instead of NestList.  If you
want the iteration to proceed until there's no detectable difference,

As to Fibonnacci numbers, define a function in Mathematica just the way
you see it in the mathematical definition (subject to Mathematica syntax
of course):

fib[0] = fib[1] = 1;
fib[n_ /; n > 1] := fib[n] = fib[n - 1] + fib[n - 2]

The extra "fib[n] =" causes Mathematica to cache each value of fib as it
is calculated rather than to have to recalculate it again when it is
needed in finding the value for a larger n.

fib[4]
5
Map[fib, Range[0, 20]]
{1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
2584, \
4181, 6765, 10946}

aka007 at mail.com wrote:
>
> can someone explain a bit the notation for newtons method?
> can someone show me the fibonacci sequence on mathematica?
>
> f(n_):=x(n_)=f(n)/f'(n)
>
> sorry, i don't exactly recall newtons method, nor the mathematica
> to do it.
>
> and then the second part is creating a table of data, based on inital
> guess. graph would be good, too.
>
> but what in the world is the first part doing???
>
> thanks,
>
> Jesse
> aka007 at mail.com
> btw, pls email me, as my i only see messages from nov 21, some sort
> of problem.  also, this is not for a class, i'm supposed to help
> students with mathematica (which i never used till now).

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       phone 413 549-1020 (H)
Univ. of Massachusetts                     413 545-2859 (W)
Amherst, MA 01003-4515

```

• Prev by Date: Re: GraphicsArray and alignment of graphs
• Next by Date: Re: weird behavior of simplify
• Previous by thread: Re: newtons method, notation
• Next by thread: Re: Dividing top and bottom