MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Transc. Eqn - Symb. Iterative Sol'n.?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15721] Re: Transc. Eqn - Symb. Iterative Sol'n.?
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 5 Feb 1999 03:42:18 -0500 (EST)
  • Organization: University of Western Australia
  • References: <78ul25$911@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Eric Strobel wrote:

> Problem: I *think* it should be relatively straightforward to write a
> Block/ Module to do a symbolic Newton-Raphson (or similar such thing)
> solution of a transcendental equation.

For a pure function (e.g, Sin instead of Sin[x] or #^2 & instead of
x^2), here is a function which uses Nest to implement the
Newton-Raphson recursion directly:

In[1]:= NewtonRoot[f_Function, x0_, n_:3] := 
  Nest[# - f[#]/f'[#] & , x0, n]

Now, we simply extend this syntax to work for any function f_ of
argument x_, starting at x0 and, by default, iterating 3 times:

In[2]:= NewtonRoot[f_, x_, x0_, n_:3] := 
  NewtonRoot[Function[y, Evaluate[f /. x -> y]], x0, n]

This simply involves turning the argument f into a Fuction and then
calling the first definition.

For example, to solve x^2==2 starting at y,

In[3]:= NewtonRoot[x^2 - 2, x, y,2]

Out[3]=
                              2
                        -2 + y  2
          2   -2 + (y - -------)
    -2 + y                2 y
y - ------- - -------------------
      2 y                    2
                       -2 + y
                2 (y - -------)
                         2 y

or for the transcendental equation Tan[x]==x, 

In[4]:= NewtonRoot[Tan[x] - x, x, y, 2]

Out[4]=
                        -y + Tan[y]            -y + Tan[y]
                   -y + ------------ + Tan[y - ------------]
                                   2                      2
    -y + Tan[y]         -1 + Sec[y]            -1 + Sec[y] y -
------------ - -----------------------------------------
               2                       -y + Tan[y]  2
    -1 + Sec[y]           -1 + Sec[y - ------------]
                                                  2
                                       -1 + Sec[y]

The code also works with numerical values:

In[5]:= NewtonRoot[Tan[x] - x, x, 4.5, 10] Out[5]= 4.49341 

> Example: The prototypical example would be Kepler's problem, M = E - e
> Sin[E], where M = mean anomaly, e = eccentricity and E = eccentric 
> anomaly.  One will sometimes run across approximate solutions in 
> powers of e, for e small

You can certainly use this approach. See

  ftp://ftp.physics.uwa.edu.au/pub/Mathematica/MathGroup/Kepler.nb

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at physics.uwa.edu.au  AUSTRALIA                       
http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Q: Why can't I stop TraditionalForm dismissing Times Attributes ?
  • Next by Date: EPS Display problem with OpenStep
  • Previous by thread: Re: Q: Why can't I stop TraditionalForm dismissing Times Attributes ?
  • Next by thread: EPS Display problem with OpenStep