Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! I need some help with this programming assignment. It's to be graded by Matlab. Pic 1 is the question, pic 2 is my m-file

image text in transcribed

image text in transcribed

image text in transcribed

Hello! I need some help with this programming assignment. It's to be graded by Matlab. Pic 1 is the question, pic 2 is my m-file and pic three is the failed pretest on Matlab.

se Courses LMS Integration Documentation Problem 1: Secant Method O solutions submitted (max Unlimited) Write a function m.file that implements the secant method Your function should accept the following inputs in ordery 1. A function defining the roots problem 2A vector of two initial guesses (first element is the first guess, Sexcond element is second guess) 3. A stopping criterion (es) for the numerical solution with a default value of le-5 4. A maximum iteration count for the numerical solution with a default value of 30 5. An arbitrary number of parameter values associated with the roots problem Your function should output the following four scalar outputs (in order) 1. The root estimate 2. The residual in the numerical solution 3. The approximate relative error in the numerical solution 4 The number of iterations required for convergence I recommend you use the examples newtonraphson.m and/or bisect param.m as starting points from which you develop your own function mfile for the secant method Note Test cases 3.4 and 5 test the functionality of the default values for unspecified inputs and the parameter passing through varargin New Step Out Function Call Stac secant Run to Cursor DEBUG FILE Open Save reakpoints Continue Step Print Find I ndent NAVIGATE BREAKPOINTS Drunction [root, residual, ea, Iter s ecant (tun, x1, x2, es,max it, varargin) [root, residual, ea, iter] - secant (fun, x1,x2, es,max it, yl, y2, .) This function implements the secant method for the solution to a roots problem. Inputs fun u ser defined function that defines the roots problem [xl x2:a vector of the first and second initial guesses est optional stopping criterion, default ses - LE-5 max_it: optional maximum iterations, de tault is max_it - 30 yl, 2. optional parameter inputs for function evaluation Outputs TOOTE Toot estimate esidual: the residual in the numerical solution ea: approximate relative error in root estimate iter: number of iterations required for convergence nargin

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions