Problem 2 (25 points) (CCO 3)/MatlabGrader Develop a Matlab function that finds a root of a function g(x) starting from the given initial estimates x (-1) and x (0) with a tolerance in function of at least OK using the secant method. Name the function mySecant using as input the anonymous function g, the initial estimates x00 and x0, the maximum number of iterations to perform N, and the required tolerance in function epsok. As output, the function shall return four scalar variables: the numerical solution x, its tolerance in function tolFunc, its estimated relative error ere, and the number of iterations performed n. If the requested tolerance in function cannot be reached within N iterations, the function shall execute Matlab's error("...") function with an appropriate error message. Other than this potential error message, do not print out any results to screen or do any plotting within the function. You must minimize the number of function calls g(x) required per iteration, by storing function call results in temporary storage variables. You may use only 1 function call to g to update the solution per iteration. Required submission: ☐ well commented function source code submitted to Matlab Grader using the Canvas link for Exam 3 - Problem 2
Problem 2 (25 points) (CCO 3)/MatlabGrader Develop a Matlab function that finds a root of a function g(x) starting from the given initial estimates x (-1) and x (0) with a tolerance in function of at least OK using the secant method. Name the function mySecant using as input the anonymous function g, the initial estimates x00 and x0, the maximum number of iterations to perform N, and the required tolerance in function epsok. As output, the function shall return four scalar variables: the numerical solution x, its tolerance in function tolFunc, its estimated relative error ere, and the number of iterations performed n. If the requested tolerance in function cannot be reached within N iterations, the function shall execute Matlab's error("...") function with an appropriate error message. Other than this potential error message, do not print out any results to screen or do any plotting within the function. You must minimize the number of function calls g(x) required per iteration, by storing function call results in temporary storage variables. You may use only 1 function call to g to update the solution per iteration. Required submission: ☐ well commented function source code submitted to Matlab Grader using the Canvas link for Exam 3 - Problem 2
Principles of Heat Transfer (Activate Learning with these NEW titles from Engineering!)
8th Edition
ISBN:9781305387102
Author:Kreith, Frank; Manglik, Raj M.
Publisher:Kreith, Frank; Manglik, Raj M.
Chapter8: Natural Convection
Section: Chapter Questions
Problem 8.47P
Related questions
Question

Transcribed Image Text:Problem 2 (25 points) (CCO 3)/MatlabGrader
Develop a Matlab function that finds a root of a function g(x) starting from the given initial estimates x (-1) and x (0) with a tolerance
in function of at least OK using the secant method. Name the function mySecant using as input the anonymous function g, the
initial estimates x00 and x0, the maximum number of iterations to perform N, and the required tolerance in function epsok. As
output, the function shall return four scalar variables: the numerical solution x, its tolerance in function tolFunc, its estimated
relative error ere, and the number of iterations performed n. If the requested tolerance in function cannot be reached within
N iterations, the function shall execute Matlab's error("...") function with an appropriate error message. Other than this
potential error message, do not print out any results to screen or do any plotting within the function. You must minimize the
number of function calls g(x) required per iteration, by storing function call results in temporary storage variables. You
may use only 1 function call to g to update the solution per iteration.
Required submission:
☐ well commented function source code submitted to Matlab Grader using the Canvas link for Exam 3 - Problem 2
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Principles of Heat Transfer (Activate Learning wi…
Mechanical Engineering
ISBN:
9781305387102
Author:
Kreith, Frank; Manglik, Raj M.
Publisher:
Cengage Learning

Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning

International Edition---engineering Mechanics: St…
Mechanical Engineering
ISBN:
9781305501607
Author:
Andrew Pytel And Jaan Kiusalaas
Publisher:
CENGAGE L

Principles of Heat Transfer (Activate Learning wi…
Mechanical Engineering
ISBN:
9781305387102
Author:
Kreith, Frank; Manglik, Raj M.
Publisher:
Cengage Learning

Refrigeration and Air Conditioning Technology (Mi…
Mechanical Engineering
ISBN:
9781305578296
Author:
John Tomczyk, Eugene Silberstein, Bill Whitman, Bill Johnson
Publisher:
Cengage Learning

International Edition---engineering Mechanics: St…
Mechanical Engineering
ISBN:
9781305501607
Author:
Andrew Pytel And Jaan Kiusalaas
Publisher:
CENGAGE L

Precision Machining Technology (MindTap Course Li…
Mechanical Engineering
ISBN:
9781285444543
Author:
Peter J. Hoffman, Eric S. Hopewell, Brian Janes
Publisher:
Cengage Learning

Automotive Technology: A Systems Approach (MindTa…
Mechanical Engineering
ISBN:
9781133612315
Author:
Jack Erjavec, Rob Thompson
Publisher:
Cengage Learning

Understanding Motor Controls
Mechanical Engineering
ISBN:
9781337798686
Author:
Stephen L. Herman
Publisher:
Delmar Cengage Learning