Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
id558966080 pdfMachine by Broadgun Software - a great PDF writer! - a great PDF creator! - http://www.pdfmachine.com http://www.broadgun.com
Section 2.3
1,4 Graphically determine the approximate location of the roots of f(x)=0 in the given
interval. Determine an interval [a,b] over which the bisection or false position algorithms
can be used to determine the roots.
So the root is approximately at x=-0.7. You could use the interval [-1,-.5] in the
algorithms.
There are two roots, at approximately x = -1.8 and x = 1.8. You could use the intervals
[-2, -1.6] or [1.6, 2].
Algorithms and Programs
1-2. Approximate the real roots, to 12 decimal places, of each function over the given
interval.
MATLAB code is shown below. Three files were used: (i) a script that defines the
function and bounds, (ii) a function to find coarse approximations of the roots (approot.m
in the text), and (iii) a function that performs the bisection algorithm to find a fine
approximation of the roots (bisect.m in the text). The output was the following:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Find root of f(x)=0 using bisection method %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R = approot(f,(ai:delta1:bi));
rts=0;
for i=1:length(R)
a=R(i)-delta1; b=R(i)+delta1;
[c,err,yc,k]=bisect(f,a,b,delta2);
rts(i)=c;
disp(sprintf('\nCoarse approximation: %.4e\n%i iterations\nRoot:
%.12e, \nError: %.3e \nf(c)=%.3e',R(i),k,c,err,f(c)))
end
figure(1);
ezplot(f,[ai,bi])
hold on;
plot(rts,0*rts,'r*')%,[ai bi],[0 0],'g')
Section 2.4
2. Let f(x) = x2 – x – 3.
(a) Find the Newton-Raphson formula pk = g(pk-1)
g(x) = x – f(x)/f’(x)
= x – (x2 – x – 3)/(2x – 1) = ((2x – 1)x – x2 + x + 3)/(2x – 1)
= (x2 + 3)/(2x – 1),
so pk = (pk-12+3)/(2 pk-1 – 1)
(b) Start with po = 1.6 and find p1, p2, and p3.
p1 = 2.527272, p2 = 2.31520, p3 = 2.302818
(c) Start with po = 0.0 and find p1, p2, and p3. What do you conjecture about this
sequence?
p1 = -3, p2 = -1.71429, p3 = -1.34101
The sequence is converging quadratically to the zero at x = -1.3027756377.
8. Use the secant method to compute the next two iterates p2 and p3.
f(x) = x2 – 2x – 1; po = 2.6, p1 = 2.5, p2 = 2.41935484, p3 = 2.4136464
14. Can Newton-Raphson iteration be used to solve f(x) = 0 if f(x) = x1/3? Why?
NO. f’(x) = 1/3 x-2/3 is not continuous at the root of f(x) = 0, which is x=0.
p 1k / 31
The iteration is p k p k 1 f ( p k 1 ) / f ' ( p k 1 ) p k 1 2 p k 1 ,
1 2 / 3
p k 1
3
which exhibits oscillatory divergence from the root at x=0.
Algorithms and Programs
3. Modify the Newton iteration program to approximate each of the following square
roots to 10 decimal places.
The code shown below produces the results for the following problems:
(a) Start with po = 3 and approximate 8
[p0,err,k,y]=newton(@(x)x^2-8,@(x)2*x,3,10^(-10),10^(-5),10^3);
Iteration 1, p_1 = 2.8333333333e+000
Iteration 2, p_2 = 2.8284313725e+000
Iteration 3, p_3 = 2.8284271247e+000
(b) Start with po = 10 and approximate 10
[p0,err,k,y]=newton(@(x)x^2-91,@(x)2*x,10,10^(-10),10^(-5),10^3);
Iteration 1, p_1 = 9.5500000000e+000
Iteration 2, p_2 = 9.5393979058e+000
Iteration 3, p_3 = 9.5393920142e+000
(c) Start with po = -3 and approximate - 8
[p0,err,k,y]=newton(@(x)x^2-8,@(x)2*x,-3,10^(-10),10^(-5),10^3);
Iteration 1, p_1 = -2.8333333333e+000
Iteration 2, p_2 = -2.8284313725e+000
Iteration 3, p_3 = -2.8284271247e+000
8. (a) Find the point on the parabola y = x2 that is closest to the point (3,1) accurate to 10
decimal places.
The distance from a point (x,y) = (x,x2) on the parabola to (3,1) is
D ( x 3) 2 ( y 1) 2 ( x 3) 2 ( x 2 1) 2 .
To minimize D, we find the point where the derivative of D2 with respect to x is zero.
d 2
D 2( x 3) 2( x 2 1) 2 x 2 x 3 x 3
dx
In other words, we need to find a zero of
f(x) = 2x3 – x – 3.
Using the Newton iteration above, we find that x = 1.2896239015, and since y = x2 on the
parabola, the point is
(1.289623902, 1.663129807).
2
The graph of y = x , the point above, and the point (3,1) are shown below.
(b) Find the point on the graph of y = sin(x – sin(x)) that is closest to the point (2.1, 0.5),
accurate to 10 decimal places.
The distance from a point (x,y) = (x,sin(x-sin(x))) to (2.1, 0.5) is
D ( x 2.1) 2 ( y 0.5) 2 ( x 2.1) 2 (sin( x sin( x )) 0.5) 2
Again, we differentiate D2 with respect to x and set the resulting expression = 0.
d 2
D 2( x 2.1) 2(sin( x sin( x )) 0.5) cos( x sin( x ))(1 cos( x))
dx
So, we must find the zero of
f ( x ) 2( x 2.1) 2(sin( x sin( x )) 0.5) cos( x sin( x ))(1 cos( x ))
Again using the Newton iteration, with a starting point po = 2, we find the desired point:
(1.869372237, 0.7917177973)
The graph of y = sin(x-sin(x)), the point above, and the point (2.1,0.5) are shown below.
(c) Find the value of x at which the minimum vertical distance between the graphs of
f(x) = x2 + 2 and g(x) = x/5 – sin(x) occurs accurate to 10 decimal places.
The minimum vertical distance is simply the difference between the functions:
|f(x) – g(x)|.
To minimize this quantity, we again find where the derivative with respect to x is zero.
f’(x) – g’(x) = 2x – 1/5 + cos(x).
Using the Newton iteration, we find that this quantity has a zero at
x = -0.3667490121.
The graphs of the functions f(x) and g(x), and the line x = -0.3667490121 are shown
below.