Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function [x,y,n]=secantf(fn,xl,xu,tol,max) % Function to find the root of a function fn using the Secant method %Inputs are:- % fn = funtion name in quotes

function [x,y,n]=secantf(fn,xl,xu,tol,max)

% Function to find the root of a function fn using the Secant method

%Inputs are:-

% fn = funtion name in quotes

% xl, xu = lower and upper guesses of the root

% tol = tolerance level

% max = maximum number of iterations allowed

%Outputs are:-

% x => desired root

% y => error in calculating root

% n => number of iterations

n=0;

error=1;

errora=1000;x=1000;

while errora > tol

fl=feval(fn,xl);

fu=feval(fn,xu);

xr=xl-fl*(xu-xl)/(fu-fl);

fr=feval(fn,xr);

xold=x;

x=xr;y=fr;

xl=xu;xu=xr;

errora=abs((x-xold)/(x+1e-20)*100);

error=abs(y);

n=n+1;

if n >= max

disp('Warning! Maximun number of iterations reached but not converged yet!')

break

end

end

image text in transcribed

Please help me write the matlab code to answer this question using the secant method.

Required information Consider the function Determine the positive root of the given function using the secant method (three iterations, x-1 = 0.5 and x0-04). (Round the final answer to four decimal places.) The positive root after three iterations is

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

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

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What are the logistics implications of internationalisation?

Answered: 1 week ago