Question

Use the following pseudocode for the Newton-Raphson method to write MATLAB code to approximate the cube...

Use the following pseudocode for the Newton-Raphson method to write MATLAB code to approximate the cube root (a)1/3 of a given number a with accuracy roughly within 10-8 using x0 = a/2. Use at most 100 iterations. Explain steps by commenting on them.
Use f(x) = x3 − a. Choose a = 2 + w, where w = 3
Algorithm : Newton-Raphson Iteration
Input: f(x)=x3−a, x0 =a/2, tolerance 10-8, maximum number of iterations100 Output: an approximation (a)1/3 within 10-8 or a message of failure
set x = x0, xold = x0;

for i = 1 to 100 do
x = x − f(x)/f′(x);
if |x − xold| < 10-8 then. % checking required accuracy
FoundSolution = true; % done
break;   % leave for environment
end if
xold = x; % update xold for the next iteration end for
if FoundSolution then
print x, ‘The number of iterations =’, i
else
print ‘The required accuracy is not reached in 100 iterations’
end if
For f′, define the function df(x) = 3x2 by using the command

df = @(x) 3 ∗ x.2;

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

Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all
close all
a=1/3;
f=@(x) x^3-a;
g=@(x) 3*x^2;
x0=a/2;
x=x0;
xold=x0;
flag=0;
for i=1:100
x=x-f(x)/g(x);
if(abs(x-xold)<1e-8)
flag=1;
break;
end
xold=x;
end
if(flag==1)
disp(['Root is ' num2str(x) ', The number of iterations are ' num2str(i)]);
else
disp('The required accuracy is not reached in 100 iterations');
end

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Use the following pseudocode for the Newton-Raphson method to write MATLAB code to approximate the cube...
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...

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

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

  • Consider the following function with a real variable, x: ?(?) = ?3 - 3?2 + 6?...

    Consider the following function with a real variable, x: ?(?) = ?3 - 3?2 + 6? + 10 a. Write a Python function for the derivative of f(x) that takes x and returns the derivative of f(x). Take the derivative of f(x) analytically with respect to x before writing the function. b. Write a Python code that approximately finds the real root, x0, of f(x) such that f(x0)~0 using the Newton-Raphson method. The code is expected to get an initial...

  • 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;)

  • Question: 03 (9 Points) Solve the following equations using Newton Raphson method. Show first two...

    Question: 03 (9 Points) Solve the following equations using Newton Raphson method. Show first two iterations only (E3) f(x) = 4x1 + 2x1-6s。 五(x) =-3x1 + 2x2-x1x2 + 10-0 Question: 03 (9 Points) Solve the following equations using Newton Raphson method. Show first two iterations only (E3) f(x) = 4x1 + 2x1-6s。 五(x) =-3x1 + 2x2-x1x2 + 10-0

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

  • Use Newton-Raphson method and hand calculation to find the solution of the following equations: x12 -...

    Use Newton-Raphson method and hand calculation to find the solution of the following equations: x12 - 2x1 - x2 = 3 x12 + x22 = 41 Start with the initial estimates of X1(0)=2 and X2(0)=3. Perform three iterations.

  • Xs 2x2 Use the MAT AB code for Newton-Raphson method to find a root of he function table. x 6x 4 ...

    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. Perfonn the computations until relative error is less than 2%. You are required to fill the followi Iteration! 뵈 | f(x) | f(x) | Em(%) 1. Continue the computation of the previous question until percentage approximate relative error is less 2. Repeat computation uing theial guess o1.0 xs 2x2 Use the MAT...

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