Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB QUESTION: if you do not have matlab , please do not try to solve QUESTION: write a script for the function below that finds

MATLAB QUESTION: if you do not have matlab, please do not try to solve

QUESTION:

write a script for the function below that finds zeros of f (x) = sin(x) with various values for the initial guess. Have the output look similar to the chart pictured below

Function:

function [xc,fEvals] = Newton(f,fp,x0,delta,fEvalMax)

% f is a handle to a continuous function f(x) of a single variable.

% fp is a handle to the derivative of f.

% x0 is an initial guess to a root of f.

% delta is a positive real number.

% fEvalsMax is a positive integer >= 2 that indicates the maximum

% number of f-evaluations allowed.

% % Newtons method is repeatedly applied until the current iterate xc

% has the property that |f(xc)|

% after fEvalsMax function evaluations, then xc is the current iterate.

% % fEvals is the number of f-evaluations required to obtain xc.

fEvals = 0;

while (abs(f(x0))>delta)

fEvals =fEvals+1;

xc = x0 - f(x0)/fp(x0);

if fEvals >= fEvalMax

break;

end

x0= xc;

end

image text in transcribed

Sample Output from the Script Eg9_3 Initial interval = [ 0.00, 0.30] f-evaluation maximum = 100 delta Root f-Evals 1.0e-003 1.0e-004 1.0e-005 1.0e-006 1.0e-007 1.0e-008 1.0e-009 1.0e-010 1.0e-011 1.0e-012 1.0e-013 1.0e-014 1.0e-015 1.0e-016 1.0e-017 1.0e-018 1.0e-019 1.0e-020 0.156152343749999980 0.156408691406249990 0.156431579589843720 0.156434726715087900 0.156434476375579830 0.156434462964534780 0.156434464920312160 0.156434465025085960 0.156434465038182700 0.156434465040092620 0.156434465040263180 0.156434465040233340 0.156434465040230950 0.156434465040230840 0.156434465040230840 0.156434465040230840 0.156434465040230840 0.156434465040230840 14 17 21 24 27 31 34 37 41 47 51 54 100 100 100 100 Sample Output from the Script Eg9_3 Initial interval = [ 0.00, 0.30] f-evaluation maximum = 100 delta Root f-Evals 1.0e-003 1.0e-004 1.0e-005 1.0e-006 1.0e-007 1.0e-008 1.0e-009 1.0e-010 1.0e-011 1.0e-012 1.0e-013 1.0e-014 1.0e-015 1.0e-016 1.0e-017 1.0e-018 1.0e-019 1.0e-020 0.156152343749999980 0.156408691406249990 0.156431579589843720 0.156434726715087900 0.156434476375579830 0.156434462964534780 0.156434464920312160 0.156434465025085960 0.156434465038182700 0.156434465040092620 0.156434465040263180 0.156434465040233340 0.156434465040230950 0.156434465040230840 0.156434465040230840 0.156434465040230840 0.156434465040230840 0.156434465040230840 14 17 21 24 27 31 34 37 41 47 51 54 100 100 100 100

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago