Question

. (25 points) The recurrence relation for the Newtons Raphson method is a)0.1.2 f(r.) F(z.) The derivative of the function c
0 0
Add a comment Improve this question Transcribed image text
Answer #1



function [root,fx,ea,iter] = modnewtraph(func,x0,h,es,maxit ,method,p)
switch nargin %this is used to set the default values so it required at leat three input , otherwise it will show error
case 3
es = 0.0001 ;
maxit = 50;
method = "C";
p = 0 ; % additional parameter for function
case 4
maxit = 50;
method = "C";
p = 0 ;
case 5
  
method = "C";
p = 0 ;
case 6
p = 0;
  
end
are = 10 ; %%initialise approximate relative error as 10
X0 = x0;
itr = 0; %% initialise iteration variable to keep track of no. of iteration
while(are> es) %%% check if the current ARE is greater then the desired error
itr = itr + 1 ; % increment the itration value to keep track of iteration
if(method =="F")
F_dotX = (func(X0 + h,p) - func(X0,p))/h; %%for Forward finite difference
else
F_dotX = (func(X0 + h,p) - func(X0-h,p))/(2*h); %calculate the derivative of function according to the method,for %centered finite difference
end;
  
  
X1 = X0 - func(X0,p)/F_dotX; %apply Newton_Raphson rule , RECURRENCE formula
  
are = abs(X1-X0)*100/abs(X0) ;%Calculate approximate relative error
  
X0 = X1;
if(maxit ==itr) %%while the iteration is equal to maximum iterarion break the loop
break;
end;
end
fx = func(X1,p);
root =X1;
ea = are;
iter=itr;
  
end

%%%PLEASE UPVOTE !!!!! THANKS

Add a comment
Know the answer?
Add Answer to:
. (25 points) The recurrence relation for the Newton's Raphson method is a)0.1.2 f(r.) F(z.) 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
  • 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...

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

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

  • Problem 12.12 Pls show the m-file Develop your own M-file function for the Gauss-Seidel method without...

    Problem 12.12 Pls show the m-file Develop your own M-file function for the Gauss-Seidel method without relaxation based on Fig. 12.2, but change the first line so that it returns the approximate error and the number of iterations: function [x, ea, iter] = ... GaussSeidel (, b, es, maxit) Test it by duplicating Example 12.1 and then use it to solve Prob. 12.2a. Develop your own M-file function for Gauss-Seidel with relaxation. Here is the function's first line: function [x,...

  • Write a function named “NewtonRaphson” that implements the Newton-Raphson method. The inputs to this function are...

    Write a function named “NewtonRaphson” that implements the Newton-Raphson method. The inputs to this function are the name of the function, name of the function’s derivative function, initial guess, maximum number of iterations, and tolerance for the relative convergence error. The output is the root. Use the problem in Homework #3 to test your function.    Hw 3 that we are pulling from %Newton-Raphson method to find upward velocity of a rocket clear all; clc; u=2200; %m/s m0=160000; %kg q=2680;...

  • I'm working on the newton's method on matlab, could someone help me and show what two...

    I'm working on the newton's method on matlab, could someone help me and show what two lines are needed to be added in the codes in order to make this function work? function sample_newton(f, xc, tol, max_iter) % sample_newton(f, xc, tol, max_iter) % finds a root of the given function f over the interval [a, b] using Newton-Raphson method % IN: % f - the target function to find a root of % function handle with two outputs, f(x), f'(x)...

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