这个作业是用Matlab解决牛顿法相关的数学问题

Math 4800 Problem Set 3 Due

1.(10分)后退和前进错误。
(a)找到前向误差(解误差),后向误差(残差)和误差放大系数,
EMF,对于以下函数,其中精确根为xe = 3/5,近似根为
xa = 0.61。在计算EMF时,假设相对误差与绝对误差相同
错误。
1. f(x)= 5x-3
2. f(x)=(5x-3)2
3. f(x)=(5x-3)3
4. f(x)=(5x-3)7
5. f(x)=(5x-3)1/3
(b)使用bisect Matlab函数和Matlab函数fzero计算近似值
到函数的零
f = @(x)x。^ 5-(5/3)* x。^ 4 +(10/9)* x。^ 3-(10/27)* x。^ 2 +(5/81)* x-1 / 243;
(这是(x-
1个
3

5
)尽可能准确。要显示所有数字,您可以使用
fprintf(’来自等分线的解决方案:xc =%22.16e,f(xc)=%9.2e \ n’,xc,f(xc));
每种情况下的正向和反向错误是什么?这是状况良好还是病态
问题(解释一下)?
2.(10分)牛顿法。
(a)从分析上证明,牛顿法在发现时的任何初始猜测都可以一步收敛
当b 6 = 0时,线性函数的根f(x)= a + bx。
(b)推导使用牛顿法求实数a的立方根的公式(按
找到x的根
3 = a)。简化结果表达式。使用计算器确定
计算81/3时,前4个牛顿迭代xk,k = 1,2,3,4,
从最初的猜测
x0 = 1。
(c)推导用于使用牛顿法找到某人的实数a的第p个根的公式
实数简化结果表达式。
1个
3.(10分)估计收敛顺序。
考虑解决方程f(x)=0。让xn表示对解的猜测,xe表示精确
解决方案,en = xn − xe步骤n的误差。
(a)使用泰勒的Thereom来证明
恩≈
f(xn)
F
0(xe)
假设en足够小而f
0
(xe)6 =0。因此,残差(后向误差)f(xn)与解误差(前向误差)en成正比。
(b)方案的收敛阶数p定义为值p,使得
en + 1
(en)
p
≈M =常数,当n→∞时
其中M是一个有限且非零的常数。使用(a)的结果表明
f(xn + 1)
f(xn)
p
≈N =常数
对于其他常数N(您可以假设f
0
(xe)是一个非零常数)。
(c)使用(b)的结果得出p的以下近似公式,
p≈
log(Rn + 1)
对数(Rn)
,(1)
其中Rn是步骤n和步骤n − 1的残差的绝对值之比,
Rn =
| f(xn)|
| f(xn−1)|

4. (20 pts)
(a) Implement Newton’s method in a Matlab function to find a solution to a scalar problem
f(x) = 0 .
%
% Find an approximate solution to a scalar equation
% f(x)=0
% by Newton’s method
%
% f (input) : function f(x)
% fx (input) : function that defines f’(x)
% x0 (input) : initial guess
% tol (input) : convergence tolerance
% xc (output) : approximate solution
% maxIterations (input) : maximum number of iterations
function [xc] = solveEquationByNewton( f,fx,x0,tol,maxIterations )
• Iterate until |f(xc)| < tol.
2
• Keep track of the iteration number, k, and take at most maxIterations iterations. Print an
error message if the maximum number of iterations is exceeded.
• Avoid evaluating the function f(x) more times than necessary.
• Add a statement to the code that outputs the current values for k, xk, f(xk), ratio =
f(xk)/f(xk−1) and p (estimated order of convergence from equation (1)) at iteration k =
1, 2, . . . . You could use the following statements:
if( k==1 ) % do not print p first time
fprintf(’Newton: it=%2d: x=%13.6e f(x)=%9.2e ratio=%9.2e\n’,k,xc,fc,ratio);
else
fprintf(’Newton: it=%2d: x=%13.6e f(x)=%9.2e ratio=%9.2e p=%4.2f\n’,k,xc,fc,ratio,p);
end;
(b) Test your Newton solver by finding √
7 by looking for a root to f(x) = x
2 − 7 = 0 using an
initial guess x0 = 1. (Use tol = 10−12 and maxIterations = 20). Hint: Make sure that you see
quadratic convergence (approximately).
(c) Use your Newton solver to find all 3 real roots to the nonlinear equation
f =
1
2
exp(sin3
(x)) + x
6 − 2.5 x
4 − x
3 −
1
2
.
• First plot the function f(x) on [−2, 2] to determine a rough initial guess that can be used for
each root. Include the plot with your answer.
• For each root determine whether the algorithm converges quadratically (approximately) or
at some other rate. Use tol = 10−12 and maxIterations = 20.