Docsity

Fixed Points, Lecture Notes - Advanced Calculus, Study notes of Calculus

Toggle sidebar
bg1
Math 128A Lab 1: Fixed Points
Adrian Down
February 04, 2006
Plotting methodology
For each point in the plot of g(x), I wanted to plot the point (xν, g(xν)) =
(xν, xν+1), followed by the point (xν+1, xν+1 ). The next point would be
(xν+1, xν+2), and so on. Hence, I plotted a sequence of points where each
xvalue is repeated twice, and the array of xand ycoordinates are offset by
one array position. To construct a matrix with two xvalues for each coor-
dinate, I used the command [x;x] to concatenate two copies of the matrix
of xvalues into an 2 ×nmatrix. I then made this into an n×2 matrix
with the transpose operator. Since MatLab reads across rows and then down
columns, the matrix element x(3) then refers to the first element in the sec-
ond row. Using one-dimensional indices, the matrix [x;x]’ then represents
an array containing two copies of each xvalue. To plot the desired points,
I use [x;x]’ for both the xand the ycoordinate, with the indices of the
coordinates offset by one.
In the plot of f(x), I wanted to plot (xν, f (xν)) followed by the point
(xν+1,0). The next point would be (xν+1 , f (xν+1)). I used the same display
array from the first plot for the xcoordinate. For the ycoordinate, I made
an array of 2nzeros, and then using a for loop, I filled every second element
with f(xν).
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Fixed Points, Lecture Notes - Advanced Calculus and more Study notes Calculus in PDF only on Docsity!

Math 128A Lab 1: Fixed Points

Adrian Down

February 04, 2006

Plotting methodology

For each point in the plot of g(x), I wanted to plot the point (xν , g(xν )) = (xν , xν+1), followed by the point (xν+1, xν+1). The next point would be (xν+1, xν+2), and so on. Hence, I plotted a sequence of points where each x value is repeated twice, and the array of x and y coordinates are offset by one array position. To construct a matrix with two x values for each coor- dinate, I used the command [x;x] to concatenate two copies of the matrix of x values into an 2 × n matrix. I then made this into an n × 2 matrix with the transpose operator. Since MatLab reads across rows and then down columns, the matrix element x(3) then refers to the first element in the sec- ond row. Using one-dimensional indices, the matrix [x;x]’ then represents an array containing two copies of each x value. To plot the desired points, I use [x;x]’ for both the x and the y coordinate, with the indices of the coordinates offset by one. In the plot of f (x), I wanted to plot (xν , f (xν )) followed by the point (xν+1, 0). The next point would be (xν+1, f (xν+1)). I used the same display array from the first plot for the x coordinate. For the y coordinate, I made an array of 2n zeros, and then using a for loop, I filled every second element with f (xν ).

Part 1 - Chord method

Discussion

General method

The function we are examining is f (x) = x^2 −2. The chord method constructs a chord with fixed slope from a given point on the curve y = f (x). The intercept of this chord with the x axis is taken as the next x value, and the iterative process is repeated. The slope of the chord is thus

m =

f (xν ) xν − xν+

Solving for xν+1 yields

xν+1 = xν −

f (xν ) m Thus the function g that defines the iterative process is

g(x) = x −

x^2 − 2 m To examine the error in the iteration, I assume { xν } converges to some value, call it α, and I write each xν in terms of the error, ǫν = xν − α. With this substitution,

ǫν+1 = ǫν −

f (α + ǫν ) m

I Taylor expand the numerator of the fractional term above. Since { xν } is assumed to converge to α, it must be that { ǫν } converges to 0, and so I keep only first order terms in ǫν (with some foresight, I know that the chord method has only first-order convergence, so it is sufficient to keep only first- order terms in the Taylor expansion). By the definition of the fixed point α, f (α) = 0. Hence the Taylor expansion simplifies,

f (α + ǫν ) = f ′(α)ǫν + O(ǫ^2 ν )

With this substitution,

ǫν+1 = ǫν

f ′(α) m

  • O(ǫ^2 ν )

⇒ lim ν→∞

ǫν+ ǫν

f ′(α) m

fp = ’/Users/adrian/Documents/Documents/Academic/School/Classes/Current/Math 128A/ ff = ’-depsc’; fn = ’’; format long; % Increased display precision err = zeros(1,n+1); % Error errrat = zeros(1,n); %Error ratio err(1) = sqrt(2) - x(1); % Initial error for k = 1:n x(k+1) = x(k) - (x(k).^2 - 2) ./ m; % Compute next iterate err(k+1) = x(k+1)-sqrt(2); % Compute error errrat(k) = err(k+1) ./ err(k); % Compute ratio of successive errors end tablestr = ’’; if (table) % If the table flag is on, make a LaTeX table for k = 1:n tablestr = strvcat(tablestr,[’$’ num2str(k) ’$ & $’ num2str(x(k)) ’$ & $’ end end disp1=[x;x]; % See discussion about plotting methods x=x(:)’; plot(disp1(2:end-1),disp1(3:end),’b’) hold on xf=linspace(-20,20,10000); plot(xf,xf-1/m(xf.^2-2),’k’) plot([-20 20],[-20 20],’r’) axis([max(min(x)-.5,-20) min(max(x)+.5,20) max(min(x)-.5,-20) min(max(x)+.5,20)]) legend(’Iterations’,’g(x)=x-m^{-1}(x^{2}-2)’,’y=x’) title([’Chord method, finding the fixed point of g(x), m=’ num2str(m) ’ , x_{1}=’ if (save) % If save flag is on, save and close graph fn = [fp fp1 ’g-m-’ int2str(m) ’-x-’ int2str(x(1))]; print(ff,fn); close(gcf); end figure disp2 = zeros(2,n+1); for k = 1:n disp2(2k-1) = x(k).^2-2; end

plot(disp1(2:end),disp2(1:end-1),’b’) hold on plot(xf,xf.^2-2,’k’,xf,0*xf,’r’) axis([max(min(x)-.5,-20) min(max(max(x),2)+.5,20) max(min(min(disp2)),-20)-.5 min( legend(’Iterations’,’f(x)=x^{2}-2’,’y=0’) title([’Chord method, finding the zero of f(x), m=’ num2str(m) ’ , x_{1}=’ num2str if (save) fn = [fp fp1 ’f-m-’ int2str(m) ’-x-’ int2str(x(1))]; print(ff,fn); close(gcf); end

Results

ν xν ǫν = α − xν ǫν ǫ+1ν

−0.5 1 1.5 2 2.

0

1

2

Chord method, finding the zero of f(x), m=4 , x 1 = Iterations f(x)=x^2 − y=

(c)

1 1.5 2 2.

1

2

Chord method, finding the fixed point of g(x), m=4 , x 1 = Iterations g(x)=x−m−1(x^2 −2) y=x

(d)

−2.5−0.5 0 0.5 1 1.5 2 2.

−

−1.

−

−0.

0

1

2

Chord method, finding the zero of f(x), m=1 , x 1 = Iterations f(x)=x^2 − y=

(e)

−0.5 −0.5 0 0.5 1 1.5 2 2.

0

1

2

Chord method, finding the fixed point of g(x), m=1 , x 1 = Iterations g(x)=x−m−1(x^2 −2) y=x

(f)

ν xν ǫν = α − xν ǫν ǫ+1ν

  • 1 2 −
  • 2 1 − 0 4142135624 −
  • 3 1 5 0 08578643763 −
  • 4 1 375 − 0 03921356237 −
  • 5 1 4296875 0 01547393763 −
  • 6 1 407684326 − 0 006529236201 −
  • 7 1 416896745 0 002683182724 −
  • 8 1 413098552 − 0 001115010409 −
  • 9 1 414674793 0 0004612308096 −
  • 10 1 414022408 − 0 0001911544237 −
  • 11 1 414292723 7 916048478 e − 05 −
  • 12 1 41418077 − 3 279247959 e − 05 −
  • 13 1 414227145 1 358255212 e − 05 −
  • 14 1 414207936 − 5 626169541 e − 06 −
  • 15 1 414215893 2 330419901 e − 06 −
  • 16 1 414212597 − 9 652942448 e − 07 −
  • 17 1 414213962 3 998375018 e − 07 −
  • 18 1 414213397 − 1 65618196 e − 07 −
  • 19 1 414213631 6 860128909 e − 08 −
  • 20 1 414213534 − 2 841558677 e − 08 −
    • 1 2 −
    • 2 0 − 1 414213562 −
    • 3 2 0 5857864376 −
    • 4 0 − 1 414213562 −
    • 5 2 0 5857864376 −
    • 6 0 − 1 414213562 −
    • 7 2 0 5857864376 −
    • 8 0 − 1 414213562 −
    • 9 2 0 5857864376 −
  • 10 0 − 1 414213562 −
  • 11 2 0 5857864376 −
  • 12 0 − 1 414213562 −
  • 13 2 0 5857864376 −
  • 14 0 − 1 414213562 −
  • 15 2 0 5857864376 −
  • 16 0 − 1 414213562 −
  • 17 2 0 5857864376 −
  • 18 0 − 1 414213562 −
  • 19 2 0 5857864376 −
  • 20 0 − 1 414213562 −

ν xν ǫν = α − xν ǫν ǫ+1ν 1 4 − 2. 585786438 1. 707106781 2 − 3 − 4. 414213562 1. 792893219 3 − 6. 5 − 7. 914213562 3. 542893219 4 − 26. 625 − 28. 03921356 13. 60539322 5 − 380. 0703125 − 381. 4845261 190. 3280495 6 − 72605. 79153 − 72607. 20575 36303. 18866 7 − 2635873087 − 2635873088 1317936544 8 − 3. 473913468 e + 18 − 3. 473913468 e + 18 1. 736956734 e + 18 9 − 6. 034037391 e + 36 − 6. 034037391 e + 36 3. 017018696 e + 36 10 − 1. 820480362 e + 73 − 1. 820480362 e + 73 9. 10240181 e + 72 11 − 1. 657074374 e + 146 − 1. 657074374 e + 146 8. 285371871 e + 145 12 − 1. 372947741 e + 292 − 1. 372947741 e + 292 Inf 13 −Inf −Inf NaN 14 −Inf −Inf NaN 15 −Inf −Inf NaN 16 −Inf −Inf NaN 17 −Inf −Inf NaN 18 −Inf −Inf NaN 19 −Inf −Inf NaN 20 −Inf −Inf NaN

Part 2

Discussion

General method

Newton’s method constructs a chord from the function f (x) at the point xν to the x axis with slope f ′(xν ). This process is then repeated at the point xν+1, where xν+1 is the x intercept of the previous chord line. Finding the

slope of the chord line,

f ′(xν ) =

∆y ∆x

f (xν ) − 0 xν − xν+

⇒ xν+1 = xν −

f (x) f ′(x)

Hence the function g characterizing the iterative method is

g(x) = x −

f (x) f ′(x)

Taking f (x) = x^2 − 2, f ′(x) = 2x, so

g(x) = x −

x^2 − 2 2 x = x −

x 2

x

x 2

x To examine the limiting behavior of the iteration, I write xν = α + ǫν , where ǫν is the error term. With this substitution,

ǫν+1 = ǫν −

f (α + ǫν ) f ′(α + ǫν )

As before, I assume convergence and expand the functions on the right, using the fact that f (α) = 0 and that limν→∞ ǫν = 0. With some foresight, I know that Newton’s method should yield second-order convergence, so I keep terms to second order in ǫν.

1 f ′(α + ǫν )

f ′(α)

f ′′(α) f ′(α)^2

ǫν + O(ǫ^2 ν )

f (α + ǫν ) = f ′(α)ǫν +

f ′′(α)ǫ^2 ν + O(ǫ^3 ν ) f (α + ǫν ) f ′(α + ǫν )

= ǫν −

f ′′(α) f ′(α)

ǫ^2 ν +

f ′′(α) f ′(α)

ǫ^2 ν + O(ǫ^3 ν )

= ǫν −

f ′′(α) f ′(α)

ǫ^2 ν + O(ǫ^3 ν )

ǫν+1 = (^) ǫν − (^) ǫν +

f ′′(α) f ′(α)

ǫ^2 ν + O(ǫ^3 ν )

⇒ lim ν→∞

ǫν+ ǫ^2 ν

f ′′(α) f ′(α)

if (table) % If the table flag is on, make a LaTeX table for k = 1:n tablestr = strvcat(tablestr,[’$’ num2str(k) ’$ & $’ num2str(x(k),10) ’$ & end tablestr end disp1=[x;x]; % See discussion about plotting methods x=x(:)’; plot(disp1(2:end-1),disp1(3:end),’b’) hold on xf=linspace(-20,20,10000); plot(xf,xf./2+1./xf,’k’) plot([-20 20],[-20 20],’r’) axis([max(min(x)-.5,-20) min(max(x)+.5,20) max(min(x)-.5,-20) min(max(x)+.5,20)]) legend(’Iterations’,’g(x)=.5x+x^{-1}’,’y=x’) title([’Chord method, finding the fixed point of g(x), x_{1}=’ num2str(x(1))]) if (save) % If save flag is on, save and close graph fn = [fp fp1 ’g-x-’ int2str(x(1))]; print(ff,fn); close(gcf); end figure disp2 = zeros(2,n+1); for k = 1:n disp2(2k-1) = x(k).^2-2; end plot(disp1(2:end),disp2(1:end-1),’b’) hold on plot(xf,xf.^2-2,’k’,xf,0xf,’r’) axis([max(min(x)-.5,-20) min(max(max(x),2)+.5,20) max(min(min(disp2)),-20)-.5 min( legend(’Iterations’,’f(x)=x^{2}-2’,’y=0’) title([’Chord method, finding the zero of f(x), x_{1}=’ num2str(x(1))]) if (save) fn = [fp fp1 ’f-x-’ int2str(x(1))]; print(ff,fn); close(gcf); end

Results

ν xν ǫν = α − xν ǫν ǫ+1 (^2) ν 1 2 0. 5857864376 0. 25 2 1. 5 0. 08578643763 0. 3333333333 3 1. 416666667 0. 002453104294 0. 3529411764 4 1. 414215686 2. 123901415 e − 06 0. 3535223846 5 1. 414213562 1. 594724353 e − 12 − 87311002. 13 6 1. 414213562 − 2. 220446049 e − 16 − 4. 503599627 e + 15 7 1. 414213562 − 2. 220446049 e − 16 − 4. 503599627 e + 15 8 1. 414213562 − 2. 220446049 e − 16 − 4. 503599627 e + 15 9 1. 414213562 − 2. 220446049 e − 16 − 4. 503599627 e + 15 10 1. 414213562 − 2. 220446049 e − 16 − 4. 503599627 e + 15

2 4 6 8 10 12 14 16 18 20

0

2

4

6

8

10

12

14

16

18

20

Chord method, finding the zero of f(x), x 1 = Iterations f(x)=x^2 − y=

(k)

2 4 6 8 10 12 14 16 18 20

2

4

6

8

10

12

14

16

18

20

Chord method, finding the fixed point of g(x), x 1 = Iterations g(x)=.5x+x− y=x

(l)