Write a script to make this code work in matlab function x = Newton_method (f, df, x0,
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a script to make this code work in matlab
Transcribed Image Text:
function x = Newton_method (f, df, x0, Tol, MaxIter ) % NEWTON Newton's Method Newton's method for finding successively better approximations to the zeroes of a real-valued function. % Inputs: f - solve f(x)3D0 df derivative of f(x) initial guess X0 Tol - stopping tolerance MaxIter - maximum number of iterations % Output: X - a root of f (x)%3D0 nit=0;%number of iterations disp('step| disp(' while 1 X f(x) ') creat a script for this code on matlab x = x0 - f(x0)/df(x0); nit=nit+1; if nit>MaxIter disp('Maximum number of iterations is reached!') break end if abs(x-x0)<Tol disp('The sequence is convergent!') break end x0=x; fprintf('%3i |%12.8f|%12.8f\n',nit,x,f(x)) end function x = Newton_method (f, df, x0, Tol, MaxIter ) % NEWTON Newton's Method Newton's method for finding successively better approximations to the zeroes of a real-valued function. % Inputs: f - solve f(x)3D0 df derivative of f(x) initial guess X0 Tol - stopping tolerance MaxIter - maximum number of iterations % Output: X - a root of f (x)%3D0 nit=0;%number of iterations disp('step| disp(' while 1 X f(x) ') creat a script for this code on matlab x = x0 - f(x0)/df(x0); nit=nit+1; if nit>MaxIter disp('Maximum number of iterations is reached!') break end if abs(x-x0)<Tol disp('The sequence is convergent!') break end x0=x; fprintf('%3i |%12.8f|%12.8f\n',nit,x,f(x)) end
Expert Answer:
Answer rating: 100% (QA)
THIS IS THE MATLAB CODE FOR CALLING THE FUNCTION Newtonmethod clc clear all to clear a... View the full answer
Posted Date:
Students also viewed these programming questions
-
Write a script to find the largest of 3 numbers? Write a script that will compare 3 strings? Write a script that will read 3 numbers (1,2 and 3) and display them in words? Write a script that will...
-
b) Consider the following system describing a resonator : 1 -1 2 - 1-2r cos 0 z +r z -2 H(z)= Provide an approximate relation between r, and the frequency of the resonant peak in H(ejo) (in terms of...
-
Write a MATLAB program in a script file that finds a positive integer n such that the sum of all the integers 1 + 2 + 3 + ... + n is a number between 100 and 1000 whose three digits are identical. As...
-
Calculate the numerical value of cross-price elasticity, exy, in each of the following situations. Do not round your interim calculations before obtaining the final solution (i.e. do not clear your...
-
The following list contains events that occurred during January 2011 at the local Ford dealer, Malcom Motors: a. California Central University (CCU) signed a contract to purchase a fleet of Ford...
-
On May 1, 2012, Bovar Company began the manufacture of a new paging machine known as Dandy. The company installed a standard costing system to account for manufacturing costs. The standard costs for...
-
Journal entries for both buyer and seller periodic inventory system Non- GST version (a) Prepare general journal entries to record the following transactions (i) for Esther Ltd and (ii) for Barton...
-
Sustainable Industries manufactures cardboard containers (boxes) made from recycled paper products. The company operates two divisions, paper recycling and box manufacturing, as decentralized...
-
6. The number of (staircase) paths in the xy-plane from (0, 0) to (7, 5) where each such path is made up of individual steps going one unit upward (U) or one unit to the right (R). (a) 12C5 (b) 12!...
-
13. A 10,000 kW turbo-generator operating at rated capac- ity receives 52,000 kg/h of steam at 2.90 MPa and 310C, exhaust is aat 0.007 MPa. At 1.20 MPa and 230C, there are actually extracted 20% of...
-
Let P, Q and R be the propositions P: You get an A in the final exam. Q: You do every exercise in this book. R: You get an A in this class. Write the following propositional forms in symbolic form...
-
Explain the strategic/consultative selling model in relation to selling in the global context.
-
Not surprisingly, an event with the size and scale of Milan Expo drew its share of criticism. For example, on April 30, the day before Expo opened, thousands of protesters took to the streets in...
-
Identify the forces that shape competition in an industry, and illustrate each force with a specific company or industry example.
-
How do support media complement the primary media in reinforcing their messages? Discuss the potential problems of support media.
-
Define value network and explain the differences between sustaining technologies and disruptive technologies.
-
Joni Shamrock Inc. has the following amounts reported in its general ledger at the end of the current year. Organization costs Trademarks Discount on bonds payable Deposits with advertising agency...
-
The diameter of a sphere is 18 in. Find the largest volume of regular pyramid of altitude 15 in. that can be cut from the sphere if the pyramid is (a) square, (b) pentagonal, (c) hexagonal, and (d)...
-
Where does the management accounting function fit into an organizations structure?
-
What are the ethical responsibilities of management accountants?
-
Diana Corporation provides the following information for 2017: Calculate (a) Cost of goods manufactured in 2017 and (b) Cost of goods sold in 2017 Beginning work-in-process inventory, 1/1/2017 Total...
Study smarter with the SolutionInn App