# 1.7 Lesson 7

```> restart;
> g:= x -> a*x-x^2;

2
g := x -> a x - x
> a:= 3.8008;

a := 3.8008
> y[0]:= a/2;

y[0] := 1.900400000
> for jj from 1 to 99 do y[jj]:= g(y[jj-1]) od:
> stair:= x -> plot([[x,x],[x,g(x)]
> ,[g(x),g(x)]]);

stair := x -> plot([[x, x], [x, g(x)], [g(x), g(x)]])
> with(plots):
> p:= plot({x, g(x)}, x=0 .. a):
> display({p, seq(stair(y[jj]), jj=0..10)});
> y[99];

2.130930356
> Q:= x -> ((g@@8)(x)-(g@@8)(y[99]))/(x - y[99]);

(8)       (8)
g   (x) - g   (y[99])
Q := x -> ---------------------
x - y[99]
> plot({Q(x), -1, 1}, x = 2.12 .. 2.14);
--------------------------------------------------------------------------------
>
# Newton's Method
# -------------
#
#
> f:= 'f';

f := f
> newt:= x -> x - f(x)/D(f)(x);

f(x)
newt := x -> x - -------
D(f)(x)
> dnewt:=D(newt);

(2)
f(x) D   (f)(x)
dnewt := x -> ---------------
2
D(f)(x)
> taylor(newt(x), x=c, 3);

/                    (2)      \
|              f(c) D   (f)(c)|
|    D(f)(c) - ---------------|
/      f(c) \   |                  D(f)(c)    |
|c - -------| + |1 - -------------------------| (x - c) -
\    D(f)(c)/   \             D(f)(c)         /

(3)                   2         (2)         (2)
(2)             f(c) D   (f)(c)   (- D(f)(c)  + f(c) D   (f)(c)) D   (f)(c)
1/2 D   (f)(c) - 1/2 --------------- + -----------------------------------------
D(f)(c)                               2
D(f)(c)
--------------------------------------------------------------------------------
D(f)(c)

2            3
(x - c)  + O((x - c) )
> subs(f(c)=0,");

(2)
D   (f)(c)        2            3
c + 1/2 ---------- (x - c)  + O((x - c) )
D(f)(c)
> f:= x -> x^3 + x^2 - 2*x;

3    2
f := x -> x  + x  - 2 x
> newt(x)/x^2;

3    2
x  + x  - 2 x
x - --------------
2
3 x  + 2 x - 2
------------------
2
x
> normal(");

2 x + 1
--------------
2
3 x  + 2 x - 2
> plot({1,-1,newt(x)/x}, x=-3 .. 3, -3 .. 3);
> plot((newt@@2)(x), x = -3..3, -3 .. 3);
>
> plot((newt@@4)(x), x= -3 .. 3, -3 .. 3);
> plot((newt@@2)(x)-x, x = 0.4 .. 0.6, -3 .. 3);
> x[0]:=fsolve((newt@@2)(x)-x, x= 0.45 .. 0.46);

x[0] := .4588411303
> x[1]:= newt(x[0]);

x[1] := -.8957813727
> x[2]:= newt(x[1]);

x[2] := .4588411263
> dnewt(x[1]) * dnewt(x[2]);

47.17543445
>
# Can we find a polynomial for which Newton's method has a stable 2-cycle?
#

```