Question
must be done in matlab
Part B (Based off Week 3 Content) Newtons Method approximates a root of a function by iterating through the equation where n
media%2F50d%2F50d11020-1e9c-4998-bcfc-19
Part B (Based off Week 3 Content) Newtons Method approximates a root of a function by iterating through the equation where n is the nth estimate for the root of the function f(z). In order to it- erate through this method, we need to provide an initial guess for the root, For example, if we apply this method to f(z) = sin(z) using note that f(cos(r) = 1, we sin(1) =-0.5574 cos(1) sin(-0.5574 ) cos(-0.5574) Z3 -0.5574- 0.0659 sin(0.0659) 0.0659--(0.0659) = We can see that as we iterate through Newtons Method we are converging towards r = 0, which is one of the roots of f(z) = sin(z) Questions: 1. Create a function that can numerically solve f(r) given f(x) and I are provided as inputs You can do this using the central finite difference formula: 2h where h = 10-10 2. Create a function that can apply a single iteration of Newtons Method given f(x) and r are provided as inputs. The output should be r2- 3. Using a for loop, create a function that can apply N iterations of New- tons Method given f(x), r and N are provided as inputs. The output should be a vector containing all iterations of n (should have a length of N +1) Useful Control Structures and Functions: for
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Derivative function:

START CODE

function der = func_der(f,x)
der=(f(x+10^(-10))-f(x-10^(-10)))/(2*10^(-10)); %numerically calculates derivative
end

END CODE

Newton's next iteration function:

START CODE

function newt = newt_one(f,x)
newt=(x-f(x)/func_der(f,x)); %next iteration
end

END CODE

Main function:

START CODE

function [x] = Q_newt_final(f,x1,N)
x=zeros(1,N+1); %initialize
x(1)=x1; %initialize
for i=2:N+1
    x(i)=newt_one(f,x(i-1)); %for loop
end
end

END CODE

Sample usage:

Command Window >> Q newt final ( (x) x.*2-3,1,5) ans - 1.0000 2.0000 1.7500 1.7321 1.7321 17321

\blacksquare

Please do rate this answer positively if you found it helpful. Thanks and have a good day!

Add a comment
Know the answer?
Add Answer to:
Part B (Based off Week 3 Content) Newtons Method approximates a root of a function by iterating t...
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
  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root ^n and the number of steps n taken to reach the solution. Use function mynewton.m to perform...

  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max.iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root n and the number of steps n taken to reach the solution. Use function mynewton.m to perform the...

  • Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2...

    Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2 +3x−7 Calculate the accuracy of the solution to 1 × 10−10. Find the number of iterations required to achieve this accuracy. Compute the root of the equation with the bisection method. Your program should output the following lines: • Bisection Method: Method converged to root X after Y iterations with a relative error of Z.

  • Page 73, as mentioned in the stated question, is provided below 1. Consider a new root-finding...

    Page 73, as mentioned in the stated question, is provided below 1. Consider a new root-finding method for solving f(x) = 0. Successive guesses for the root are generated from the following recurrence formula: Xn+1 = In f(xn) fhen + f(xn)] – F(Xn) (1) Write a user-defined function with the function call: [r, n] = Root fun (f, xl, tol, N) The inputs and outputs are the same as for the user-defined function Newton described on page 73 of Methods....

  • Programming Language: MATLAB Problem 3: (5 Points) Write a function with the header: function [R] -myNewtonRaphson...

    Programming Language: MATLAB Problem 3: (5 Points) Write a function with the header: function [R] -myNewtonRaphson (f, fp, x0, tol) which takes as input f: a function handle fp: a function handle to the derivative of f (note how I do it in the test case). x0: the initial guess of the root tol: a tolerance above which the algorithm will keep iterating. Tips: . Be sure to include an iteration counter which will stop the while-loop if the number...

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

  • Problem 1 (Matlab): One of the most fundamental root finding algorithms is Newton's Method. Given a real-valued, di...

    Problem 1 (Matlab): One of the most fundamental root finding algorithms is Newton's Method. Given a real-valued, differentiable function f, Newton's method is given by 1. Initialization: Pick a point xo which is near the root of f Iteratively define points rn+1 for n = 0,1,2,..., by 2. Iteration: f(xn) nt1 In 3. Termination: Stop when some stopping criterion occurs said in the literature). For the purposes of this problem, the stopping criterion will be 100 iterations (This sounds vague,...

  • 5. For each of the following functions, and the corresponding initial interval, tell whether Bisection method...

    5. For each of the following functions, and the corresponding initial interval, tell whether Bisection method can be applied to find a root in the interval, and if so, how many iterations are required to achieve the associated accuracy. Recall 10-G1 (b-a). (a) f(x) = sin(x), [-1, 1], E = 2-16 (b) f(x) = sn'(x), [-1, 1], € = 2-16 (c) f(z) = cos(x), [-1, 1], ε = 2-16 7. Show that Newton's method for finding the root of a...

  • The equation f(x) = (1 ‐ x) cos x ‐ sin x = 0 has at...

    The equation f(x) = (1 ‐ x) cos x ‐ sin x = 0 has at least one root between a = 0 and b = 1 since f(a)f(b) < 0. The bisection method of finding the root proceeds as follows: a. It finds the midpoint r = (a + b)/2. b. If f(r) = 0, then r is the root. If |b ‐ a| is very small less than ∈ then also we can take r as the root....

  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

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