Question

II. Using Newton’s method, write a MATLAB program to find the fixed point of the following...

II. Using Newton’s method, write a MATLAB program to find the fixed point of the following
function:
?(?) = √? + ??
accurate to at least 8 decimal places. (HINT: finding the fixed point of f(x) is the same as finding the zero of g(x) = f(x) − x. ) The output of this program should display in a single table (i) the solution for the fixed point, (ii) the initial guess, (iii) the number of iterations it took to reach an
answer, and (iv) the stopping rule (i.e. the tolerance). Remember that your initial guess should be
contained in the interval [−πe, ∞), as f is defined only on this interval. Finally, you should also
store each successive guess of the final solution in a vector and plot them, give your figure a title
and label the horizontal axis “iterations” and the vertical axis “guesses”.

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

MATLAB code for the problem is provided below, please comment if any doubts:

MATLAB code:

%set the function here
g=@(x) sqrt(x)+pi()*exp(1);

%set the inital guess
init=1;
x0 = init;
x1 = g(x0);

%set the alue of n
n=8;
%compute the epsilon
epsi= 5*10^-(n+1);

%declare the iteration vector
itr = 0;

%iteration array
iteraArr=[];

%guess array
guessArr=[];

%the while loop
while (abs(x1-x0) > epsi && itr<100)
     %update the itr
    itr = itr + 1;
    x0 = x1;
  
    %find the next guess
    x1 = g(x0);
  
    %set the iteration and guess array values
    iterArr(itr)=itr;
    guessArr(itr)=x1;
end

%display the results as table
h={'solution' 'inital_guess' 'number of iterations' 'Tolerance'};
data=[x1 init itr epsi];
f=figure;
t=uitable(f,'data',data,'columnname',h);

%plot
figure
plot(iterArr, guessArr)
title('Iterations Vs Guess')
xlabel('iterations')
ylabel('guesses')

Output:

Add a comment
Know the answer?
Add Answer to:
II. Using Newton’s method, write a MATLAB program to find the fixed point of the following...
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
  • in C++. Write a function squareRoot that uses the Newton’s method of approximate calcu-lation of the...

    in C++. Write a function squareRoot that uses the Newton’s method of approximate calcu-lation of the square root of a number x. The Newton’s method guesses the square root in iterations. The first guess is x/2. In each iteration the guess is improved using ((guess + x/guess) / 2 ) as the next guess. Your main program should prompt the user for the value to find the square root of (x) and how close the final guess should be to...

  • Using the "Newton's Method" Write a MATLAB script to solve for the following nonlinear system of...

    Using the "Newton's Method" Write a MATLAB script to solve for the following nonlinear system of equations: x2 + y2 + z2 = 3 x2 + y2 - z = 1 x + y + z =3 using the initial guess (x,y,z) = (1,0,1), tolerance tol = 1e-7, and maximum number of iterations maxiter = 20.

  • Not in C++, only C code please In class, we have studied the bisection method for...

    Not in C++, only C code please In class, we have studied the bisection method for finding a root of an equation. Another method for finding a root, Newton's method, usually converges to a solution even faster than the bisection method, if it converges at all. Newton's method starts with an initial guess for a root, xo, and then generates successive approximate roots X1, X2, .... Xj, Xj+1, .... using the iterative formula: f(x;) X;+1 = x; - f'(x;) Where...

  • This program has to be written in matlab 2. Write a function to find a root...

    This program has to be written in matlab 2. Write a function to find a root of f(c) using the secant method. Call this routine secant, call the file secant.m; its first line should be function [x,nf] = secant (fname, x0, x1, tol) fname is the name of the m-file which evaluates the function f(x), 20 and 21 are initial approximations to .c", and tol is a stopping tolerance. Your code should return an approximation x = 2X+1 to 3*...

  • 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...

  • Write a matlab program to implement the secant root finding method in matlab. The function name...

    Write a matlab program to implement the secant root finding method in matlab. The function name should be Secant and it should take the equation as input whoes root has to be found and the two initial values of a and b and maximum tolerable error. Consider the following example: Your code should generate the following: >> secantAssg5(@(x)(x^4+x^2+x+10),2,3,0.0001)    Xn-1      f(Xn-1)      Xn      f(Xn)      Xn+1      f(Xn+1) 2.0000   32.0000    3.0000 103.0000    1.5493   19.7111 ….. ….. ….. Root is x = 0.13952 ans...

  • Questions: 1. Write a MATLAB program to find all the roots of a given, twice continuously differe...

    Questions: 1. Write a MATLAB program to find all the roots of a given, twice continuously differentiable, function f E C2[a, b]. Your program should first probe the function f(x) on the given interval to find out where it changes sign. (Thus, the program has, in addition to f itself, four other input arguments: a, b, the number nprobe of equidistant values between a and b at which f is probed, and a tolerance tol.) For each subinterval [ai,b] over...

  • Task 2 (25 points + 4 points for commenting): Write computer code to perform the Fixed.Point...

    Task 2 (25 points + 4 points for commenting): Write computer code to perform the Fixed.Point method and use your code to find the root of the following equation using an initial guess of 3 and a stopping criterion of 0.001%; f(x) e -4x For Fixed-Point, you do not have to code Matlab to take the derivatives of the function and check the g'(x). You can do that step by hand, and then show me your hand cal ulations to...

  • Using Matlab, write an .M code program: Write a program for numerical solution of nonlinear equation...

    Using Matlab, write an .M code program: Write a program for numerical solution of nonlinear equation by Fixed-Point Iteration method with given accuracy elementof. Solve the equation. Try 3 different representations of the equation in the form x = g(x). For every representation solve the problem with initial approximations x0 = 0, x0 = 2, and x0 = 10 and with the accuracy elementof = 10^-8. f(x) = e^x - 3x^4 - 40x - 10 = 0.

  • A5.2. Write a matlab program to find out the root of equation f (x)-x*-3x - 1, using false-positi...

    numerical method lab A5.2. Write a matlab program to find out the root of equation f (x)-x*-3x - 1, using false-position method. Use initial and upper guesses -1 and 1.5 False Position method: xr-Xu Explanation of False Position f(x)(x-xu) Hints change) xu far-feval (foxr) ; root-0.3294 Xr A5.2. Write a matlab program to find out the root of equation f (x)-x*-3x - 1, using false-position method. Use initial and upper guesses -1 and 1.5 False Position method: xr-Xu Explanation of...

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