Question

in matlab Using the polynomial entered and the starting guess , compute the root of the...

in matlab Using the polynomial entered and the starting guess , compute the root of the polynomial using the Newton-Raphson method. Repeat the method until the percent error between the most recent two iterations is less than the percent error entered by the user . Determine the percent error of the most recent two iterations using the formula. Output the final value of the root found with the Newton-Raphson method and the number of iterations the method took to converge to that value (as shown in the sample output).

the equation used is percent error = ((Vn-Vn-1)/Vn-1)) *(100)

the polynomial is the vector you enter

here is my code so far

vector = input("Enter a vector this vector will be your polynomial ");

v0=input('what is your starting guess ');

percenterror=input('Enter percent error: ');

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

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long;
vector = input('Enter a vector this vector will be your polynomial ');
v0=input('what is your starting guess ');
percenterror=input('Enter percent error: ');
f=@(x) polyval(vector,x);
g=@(x) polyval(polyder(vector),x);
for i=1:100
v1=v0-f(v0)/g(v0);
if(abs((v1-v0)/v0)*100<percenterror)
break;
end
v0=v1;
end
fprintf('Root is %f\n',v1);
fprintf('Iterations taken is %d\n',i);

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
in matlab Using the polynomial entered and the starting guess , compute the root of the...
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
  • C PROGRAM NOT C++ Make sure your program reports out the following: - The polynomial that...

    C PROGRAM NOT C++ Make sure your program reports out the following: - The polynomial that the user has entered - The initial guess that the user has entered - Whether or not the Newton-Raphson algorithm converged to a solution - If successful, the root of the polynomial that the algorithm found - The number of iterations that the Newton-Raphson algorithm required to converge to a solution Also, add any numerical protections to the algorithm that you find necessary HINT:...

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

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

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

  • Write a MATLAB function (IncNR) combining the capabilities of both the Incremental Search Method and the...

    Write a MATLAB function (IncNR) combining the capabilities of both the Incremental Search Method and the Newton-Raphson Method to find all the roots in a given function [xR, err, n] = IncNR(AF, xb, ed) AF = anonymous function xb = initial guess x bracket = [xL xU], where xL = lower x and xU = upper x ed = desired error Outputs: xR = vector of roots err = vector of errors corresponding to the roots n = vector of...

  • clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold...

    clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold = 0.5; % this is the initial guess test = 1; % this simply ensures we have a test value to enter the loop below. %If we don't preallocate this, MATLAB will error when it trys to start the %while loop below k = 1; %this is the iteration counter. Similar to "test" we need to preallocate it %to allow the while loop to...

  • Write a MATLAB function newtonRaphson(fx, x0, sigfig, maxIT) that will return a root of the funct...

    Write a MATLAB function newtonRaphson(fx, x0, sigfig, maxIT) that will return a root of the function f(x) near x=x0 using the Newton-Raphson method, where sigfig is the accuracy of the solution in terms of significant figures, and maxIT is the maximum number of iterations allowed. In addition to the root (xr), the function newtonRaphson is expected to return the number of iterations and an error code (errorCode). As such, the first line of the function m file newtonRaphson.m must read...

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

  • B. Implement the Newton-Raphson (NR) method for solving nonlinear equations in one dimension. The...

    B. Implement the Newton-Raphson (NR) method for solving nonlinear equations in one dimension. The program should be started from a script M-file. Prompt the user to enter an initial guess for the root. -Use an error tolerance of 107, -Allow at most 1000 iterations. .The code should be fully commented and clear 2. a) Use your NR code to find the positive root of the equation given below using the following points as initial guesses: xo = 4, 0 and-1...

  • ____________ % This function is a modified versio of the newtmult function obtained % from % “Ap...

    ____________ % This function is a modified versio of the newtmult function obtained % from % “Applied Numerical Methods with MATLAB, Chapra, % 3rd edition, 2012, McGraw-Hill.” function [x,f,ea,iter]=newtmult(func,x0,es,maxit,varargin) % newtmult: Newton-Raphson root zeroes nonlinear systems % [x,f,ea,iter]=newtmult(f,J,x0,es,maxit,p1,p2,...): % uses the Newton-Raphson method to find the roots of % a system of nonlinear equations % input: % f = the passed function % J = the passed jacobian % x0 = initial guess % es = desired percent relative error...

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