Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my MATLAB code below and I got error 'Too many output arguments' and in line [xolder, xold] = xi; I am not sure

image text in transcribed

Here is my MATLAB code below and I got error 'Too many output arguments' and in line [xolder, xold] = xi; I am not sure how to fix it.

function [xroot,residual,ea,iter_count] = student_solution(fun,xi,es,max_it,varargin) % 5 inputs and 4 outputs

% check number of inputs if nargin

% initial guesses [xolder, xold] = xi; iter_count = 0; for iter = 1:max_it xolder = xold; xold = xroot; xroot = xold - fun(xold,varargin{:})*(xolder-xold)/(fun(xolder,varargin{:})-fun(xold,varargin{:})); if xroot ~= 0, ea = (xroot-xold)/xroot*100; end % approximate relative error if abs(ea) Write a function m-file that implements the secant method. Your function should accept the following inputs (in order): 1. A function defining the roots problem 2. A vector of two initial guesses (first element is the first guess, second element is second guess) 3. A stopping criterion ( es ) for the numerical solution with a default value of 1e5 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

Where may you not offer visitors shoe covers?

Answered: 1 week ago

Question

What one of the Followinging is defined in a corporation s charter

Answered: 1 week ago