Question

In: Computer Science

Write a program using Newton's method: Use your programs to find approximations to within 10^(-4) to...

Write a program using Newton's method:

Use your programs to find approximations to within 10^(-4) to all zeros of the following cubic polynomials.


Use |P_(n+1)-P_n| as a measure of the error in the iteration. Save all of the iterations. What are your conclusions?
(a) f(x) = x^3-5x^2 + 2x

(b) f(x) = x^3-2x^2-5

The program has to be used with MATLAB. I'm still learning how to use the program. I would love some help and tips on solving these methods. Thank you

Solutions

Expert Solution

f1=@(x) x^3-5*x^2+2*x; %Function for part a
f1d=@(x) 3*x^2-10*x+2; %Derivative of function
f2=@(x) x^3-2*x^2-5; %Function for part b
f2d=@(x) 3*x^2-4*x; %Derivative of function
roota=NewtonRoot(f1,f1d,1,20) %Function call for root to part (a) initial guess=1,iterations=20
rootb=NewtonRoot(f2,f2d,2,20)%Function call for root to part (b) initial guess=2,iterations=20
function Xs=NewtonRoot(Fun,Funder,Xo,imax) %Function implementing Newton's method
Err=0.0001; %Error
for(i=1:imax) %Running a loop till maximum iterations
Xi=Xo-Fun(Xo)/Funder(Xo); %NR method iterative scheme
if(abs((Xi-Xo))<Err) %If error is permissible loop breaks
Xs=Xi;
break
end
Xo=Xi; %Otherwise updates value
end
if(i==imax)
fprintf('Solution not obtained in %i iterations',imax)
Xs=('No Answer');
end
end


Related Solutions

Write a program using the following root-finding methods: Mullers Method Use your programs to find approximations...
Write a program using the following root-finding methods: Mullers Method Use your programs to find approximations to within 10^(-4) to all zeros of the following cubic polynomials. Use |P_(n+1)-P_n| as a measure of the error in the iteration. Save all of the iterations. What are your conclusions? (a) f(x) = x^3-5x^2 + 2x (b) f(x) = x^3-2x^2-5 The program has to be used with MATLAB. I'm still learning how to use the program. I would love some help and tips...
How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to...
How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to all real zeros of the following polynomials using Newton's method.? f(x)=x3 - 2*x2- 5. b) Find approximations to within 10-5 to all the zeros of each of the following polynomials by first finding the real zeros using Newton’s method and then reducing to polynomials of lower degree to determine any complex zeros. f(x)=x4 + 5x3 - 9*x2 - 85*x - 136.
Use Theon's double sequence (Xn and Yn) method to find the first 10 rational approximations to...
Use Theon's double sequence (Xn and Yn) method to find the first 10 rational approximations to square root of 11. You may use a computer program
Use Newton's method to find a solution for the equation in the given interval. Round your...
Use Newton's method to find a solution for the equation in the given interval. Round your answer to the nearest thousandths. ? 3 ? −? = −? + 4; [2, 3] [5 marks] Answer 2.680 Q6. Use the Taylor Polynomial of degree 4 for ln(1 − 4?)to approximate the value of ln(2). Answer: −4? − 8?2 − 64 3 ? 3 − [6 marks] Q7. Consider the curve defined by the equation 2(x2 + y2 ) 2 = 25(x2 −...
PLEASE USE PYTHON CODE 7. Use Newton's method to find the polynomial that fits the following...
PLEASE USE PYTHON CODE 7. Use Newton's method to find the polynomial that fits the following points: x = -3, 2, -1, 3, 1 y = 0, 5, -4, 12, 0
Use Matlab to solve the system x2+xy3=9 , 3x2y-y3 =4 using Newton's method for nonlinear system....
Use Matlab to solve the system x2+xy3=9 , 3x2y-y3 =4 using Newton's method for nonlinear system. use each of initial guesses (x0,y0)=(1.2,2.5), (-2,2.5), (-1.2,-2.5), (2,-2.5) observe which root to which the method converges, the number of iterates required and the speed of convergence. Write the system in the form f(u) = 0, and report for each case the number of iterations needed for ||f(u)||2≤ 10-12−.
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) 6e−x2 sin(x) = x2 − x + 1
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) −2x7 − 4x4 + 8x3 + 6 = 0
Use Newton's method to find all solutions of the equation correct to six decimal places. (Enter...
Use Newton's method to find all solutions of the equation correct to six decimal places. (Enter your answers as a comma-separated list.) sqrt(x + 1) = x^2 − x What does x equal?
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) 4e-x2 sin(x) = x2 − x + 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT