Question

xs 2x2 Use the MAT AB code for Newton-Raphson method to find a root of he function table. x 6x 4 0 with he nitial gues& xo 3.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc
clear

f = @(x) x^3-2*x^2-6*x+4; % function f(x)
fp = @(x) 3*x^2-4*x-6; %fp = drivative of f(x)

x0 = 3; %initial guess
tol = 2; %percent tolerance
%tol = 0.2; %results table 2

%{
known solutions
x =
3.4142
-2.0000
0.5858
%}


x_exact = 3.4142; % picking closest root to initial guess


i = 0;
xi = x0;

maxit = 1000; % set to avoid infinite iterations

tolerance_achieved = false;


fprintf('\n For %0.2f %% tolerance:\n\n',tol)

fprintf('iter\t\t\tx\t\t\t\t\tf(Xi)\t\t\t\tf''(Xi)\t\t\t\te(%%) \n')

while i<maxit && ~tolerance_achieved

relative_err_percent = (abs(x_exact-xi)/x_exact)*100;

fprintf('%d \t\t\t %0.4f \t\t\t\t %0.4f \t\t\t %0.4f \t\t\t %0.4f \n',i,xi,f(xi),fp(xi),relative_err_percent)

if relative_err_percent>tol
Xi = xi - (f(xi)/fp(xi));
xi = Xi;
i = i+1;
else
tolerance_achieved = true;
end

end

.

Add a comment
Know the answer?
Add Answer to:
Xs 2x2 Use the MAT AB code for Newton-Raphson method to find a root of he function table. x 6x 4 ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson...

    (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson method with equation initial guess of xo = 1. Perform the computation until the percentage error is less than 0.03%. (1b) Employ bisection method to determine the root of the f(x)=x* – 3x + 7 =0) using equation two initial guesses of x; =-2.1 and x;, =-1.8 . Perform three iterations and calculate the approximate relative error for the third iteration. What is the...

  • 6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of...

    6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of (a) 4.52 f(x) 15.5x Pick the best numerical technique, justify your choice and then use that technique to determine the root. Note that it is known that for positive initial guesses, all techniques except fixed-point iteration will eventually converge. Perform iterations until the approximate relative error falls below 2 %. If you use a bracket- ing method, use initial guesses of x 0 and...

  • Use the Newton-Raphson method to find the root of f(x) = e-*(6 - 2x) - 1...

    Use the Newton-Raphson method to find the root of f(x) = e-*(6 - 2x) - 1 Use an initial guess of xo = 1.2 and perform 3 iterations. For the N-R method: Xi+1 = x; - f(x;) f'(x;)

  • 5.1.2 Open Methods - Newton-Raphson Method Xi+1= xi – FOTO Matlab Code Example:4 function mynewtraph (f,...

    5.1.2 Open Methods - Newton-Raphson Method Xi+1= xi – FOTO Matlab Code Example:4 function mynewtraph (f, f1,x0,n) Xx0; for ilin x = x - f(x)/f1(x); disp (li if f(x) <0.01 f(x))) break end end end Matlab Code from Chapra function [root, ea, iter)=newtraph (func,dfunc, xr, es,maxit,varargin) newtraph: Newton-Raphson root location zeroes 8 [root, ea, iter)-newtraph (func, dfunc, xr, es,maxit,pl,p2, ...): $uses Newton-Raphson method to find the root of fune input: func- name of function 8dfunc = name of derivative of...

  • Consider the function /(x) = -3x - 2x2, the true value of its root is x*...

    Consider the function /(x) = -3x - 2x2, the true value of its root is x* -0.392474. (1) Use the Newton-Raphson Method starting with x = 0, the new approximation to the root after one iteration is .x2 = __ __blank The true absolute error is EP =____blank 2__ (2) The new approximation to the root after one more iteration is x3 = ___ _blank 3 Use six significant digits for x; to calculate the true absolute error E -_...

  • 6) Use MATLAB and Newton-Raphson method to find the roots of the function, f(x) = x-exp...

    6) Use MATLAB and Newton-Raphson method to find the roots of the function, f(x) = x-exp (0.5x) and define the function as well as its derivative like so, fa@(x)x^2-exp(.5%), f primea@(x) 2*x-.5*x"exp(.5%) For each iteration, keep the x values and use 3 initial values between -10 & 10 to find more than one root. Plot each function for x with respect to the iteration #.

  • 45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using...

    45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using Newton-Rephson Method without showing any iteration. Also find the root of equation, f(x) = x 9-3x -10, take initial guess, Xo=2 العقدة College of 9:05 mybb.qu.edu.ca Numerical Methods (Lab.) GENG 300 Summer 2020 5.1.2 Open Methods - Newton-Raphson Method f(x) *1+1 = x; - Matlab Code Example:4 function mynewtraph.t1.x0,-) XXO for ilin x - x - x)/1 x) disp 1 x) <0.01 break end...

  • Newton-Raphson scheme ? Calculus Suppose you want to find zeros of the function f(x)102212 and plan to use the Newton-Raphson scheme. (a) Write down the Newton-Raphson algorithm for this. That is, wri...

    Newton-Raphson scheme ? Calculus Suppose you want to find zeros of the function f(x)102212 and plan to use the Newton-Raphson scheme. (a) Write down the Newton-Raphson algorithm for this. That is, write down explicitly a formula for computing your (n+1)st guess Tn+1 given your nth guess rn for a root. In other words, deter- mine the recurrence relation resulting from using this particular function f. (b) Modifying Algorithm 2.2 as required, find the values through x7 if you choose an...

  • 4) (16 points) The function f(x)= x? – 2x² - 4x+8 has a double root at...

    4) (16 points) The function f(x)= x? – 2x² - 4x+8 has a double root at x = 2. Use a) the standard Newton-Raphson, b) the modified Newton-Raphson to solve for the root at x = 2. Compare the rate of convergence using an initial guess of Xo = 1,2. 5) (14 points) Determine the roots of the following simultaneous nonlinear equations using a) fixed-point iteration and b) the Newton-Raphson method: y=-x? +x+0,75 y + 5xy = r? Employ initial...

  • Matlab problem using newton raphson to find square root of number

    Need help modifying my Matlab script below (myscript calculates the square root of a number. using a Newton-Raphson method with 1 as the initial guess, calculates true and estimated error, and shows each iteration).-I need to create three new functions each of which should be called in the main script. These functions are needed to replace code that is currently in my script shown below.-I need to create these functions:A function to find f(x)A function to find f '(x) ?A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT