Answered step by step
Verified Expert Solution
Question
1 Approved Answer
root, x i , the next estimate for the root is found using the tangent line to the function curve at x i . Thus,
root, the next estimate for the root is found using the tangent line to the function curve at Thus, the NewtonRaphson formula for the next estimate of the root is given by the root of the tangent line: This iteration process repeats until the root is found to within a given tolerance. The iteration is not guaranteed to converge so there needs to be a maximum iteration that occurs. Write a function NewtonRaphson that implements the NewtonRaphson method. Your function should accept the following inputs: func a handle to a MATLAB function of func a handle to a MATLAB function of initial guess for the root Your function should return the following output: computed root estimate Your solution should do the following: Implement the Newton Raphson method to find a root of and print the iteration history. Do not use the MATLAB solver functions like fzero, solve. roots. etc. Terminate the search when the relative error tolerance is reached or when the iteration limit is reached whichever occurs first See this video if you need a refresher of the Newton Raphson Method. function NewtonRaphsonfunc funcd Find the root of using the NewtonRaphson method. Input: fun function handle, returns the value of the function and the first derivative of the function at ;fun initial guess for the root TolX desired relative error itmax maximum number of iterations Output: computed root tol ; itmax ; Write a While loop that continues the calculation until itermax Remember what is needed for a while loop In the loop: Compute the change of as ie compute the new value of as the current value of minus the value of the function at divided by the slope. Compute the error as how close is to Check the error. If the error is less than tol, break end end Code to call your function Assessment: Check for a correct result using the test case provided Check for another correct result Check that MATLAB solver functions were not used
root, the next estimate for the root is found using the tangent line to the function curve at Thus, the NewtonRaphson formula for the next estimate of the root is given
by the root of the tangent line:
This iteration process repeats until the root is found to within a given tolerance. The iteration is not guaranteed to converge so there needs to be a maximum iteration that
occurs.
Write a function NewtonRaphson that implements the NewtonRaphson method. Your function should accept the following inputs:
func a handle to a MATLAB function of
func a handle to a MATLAB function of
initial guess for the root
Your function should return the following output:
computed root estimate
Your solution should do the following:
Implement the Newton Raphson method to find a root of and print the iteration history. Do not use the MATLAB solver functions like fzero, solve. roots.
etc.
Terminate the search when the relative error tolerance is reached or when the iteration limit is reached whichever occurs first
See this video if you need a refresher of the Newton Raphson Method.
function NewtonRaphsonfunc funcd
Find the root of using the NewtonRaphson method.
Input:
fun function handle, returns the value of the function and the
first derivative of the function at ;fun
initial guess for the root
TolX desired relative error
itmax maximum number of iterations
Output:
computed root
tol ;
itmax ;
Write a While loop that continues the calculation until itermax
Remember what is needed for a while loop
In the loop:
Compute the change of as
ie compute the new value of as the current value of minus
the value of the function at divided by the slope.
Compute the error as how close is to
Check the error. If the error is less than tol, break
end
end
Code to call your function
Assessment:
Check for a correct result using the test case provided
Check for another correct result
Check that MATLAB solver functions were not used
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started