Question

1. Create the flowchart for the Secant method. 2. Create an M-file secant.m with function function [x0, loopCount] = secant(fn, a, b, tolerance, max_loop_count) with at least 3 inputs and up to 5 inputs, and two outputs % Inputs: % fn a handle to the target function for which the secant algorithm will attempt to find and return the zero % a first of two approximations to the zero of the target function % b second of two approximations to the zero of the target function % tolerance (optional) an acceptable error value to terminating the algorithm. The default is square root of machine epsilon % max_loop_count (optional) the maximum number of times to execute the algorithm. The default value is 128 % Outputs: % x0 the value of the domain variable closest to the zero of the target function. abs(f(x0)) should be small unless the maximum loop count is exceeded or the secant algorithm fails % loopCount the number of iterations of the secant algorithm before terminating the algorithm 1. Remember to include your function trailer and header. Make sure you use comments, indentation, and whitespace. 2. Check your first three inputs for valid values. The MATLAB builtin function isa will be helpful. 3. Check your last two arguments and set their values to the specified defaults if necessary. 4. Implement the secant algorithm in a sub-function.

          1. Create the flowchart for the Secant method.
2. Create an M-file secant.m with function
function [x0, loopCount] = secant(fn, a, b, tolerance, max_loop_count)
with at least 3 inputs and up to 5 inputs, and two outputs
% Inputs:
% fn
a handle to the target function for which the secant algorithm
will attempt to find and return the zero
% a
first of two approximations to the zero of the target function
% b
second of two approximations to the zero of the target function
% tolerance
(optional) an acceptable error value to terminating the
algorithm. The default is square root of machine epsilon
% max_loop_count
(optional) the maximum number of times to execute the
algorithm. The default value is 128
% Outputs:
% x0
the value of the domain variable closest to the zero of the
target function. abs(f(x0)) should be small unless the maximum
loop count is exceeded or the secant algorithm fails
% loopCount
the number of iterations of the secant algorithm before
terminating the algorithm
1. Remember to include your function trailer and header. Make sure you use comments, indentation, and whitespace.
2. Check your first three inputs for valid values. The MATLAB builtin function isa will be helpful.
3. Check your last two arguments and set their values to the specified defaults if necessary.
4. Implement the secant algorithm in a sub-function.
        
Show more…
1. Create the flowchart for the Secant method.
2. Create an M-file secant.m with function
function [x0, loopCount] = secant(fn, a, b, tolerance, maxloopcount)
with at least 3 inputs and up to 5 inputs, and two outputs
% Inputs:
% fn
a handle to the target function for which the secant algorithm
will attempt to find and return the zero
% a
first of two approximations to the zero of the target function
% b
second of two approximations to the zero of the target function
% tolerance
(optional) an acceptable error value to terminating the
algorithm. The default is square root of machine epsilon
% maxloopcount
(optional) the maximum number of times to execute the
algorithm. The default value is 128
% Outputs:
% x0
the value of the domain variable closest to the zero of the
target function. abs(f(x0)) should be small unless the maximum
loop count is exceeded or the secant algorithm fails
% loopCount
the number of iterations of the secant algorithm before
terminating the algorithm
1. Remember to include your function trailer and header. Make sure you use comments, indentation, and whitespace.
2. Check your first three inputs for valid values. The MATLAB builtin function isa will be helpful.
3. Check your last two arguments and set their values to the specified defaults if necessary.
4. Implement the secant algorithm in a sub-function.

Added by Gonzalo J.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Create the flowchart for the Secant method. Create an M-file secant.m with function: function [x0, loopCount] = secant(fn, a, b, tolerance, max_loop_count) with at least 3 inputs and up to 5 inputs, and two outputs. % Inputs: % fn - a handle to the target function for which the secant algorithm will attempt to find and return the zero % a - first of two approximations to the zero of the target function % b - second of two approximations to the zero of the target function % tolerance (optional) - an acceptable error value to terminate the algorithm. The default is the square root of machine epsilon % max_loop_count (optional) - the maximum number of times to execute the algorithm. The default value is 128 % Outputs: % x0 - the value of the domain variable closest to the zero of the target function. abs(f(x0)) should be small unless the maximum loop count is exceeded or the secant algorithm fails % loopCount - the number of iterations of the secant algorithm before terminating the algorithm 1. Remember to include your function trailer and header. Make sure you use comments, indentation, and whitespace. 2. Check your first three inputs for valid values. The MATLAB built-in function isa will be helpful. 3. Check your last two arguments and set their values to the specified defaults if necessary. 4. Implement the secant algorithm in a sub-function.
Close icon
Play audio
Feedback
Powered by NumerAI
David Collins Kathleen Carty
Jennifer Stoner verified

Sri K and 91 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
the-following-incomplete-code-in-matlab-was-proposed-to-use-the-bisection-method-in-order-to-compute-root-of-the-equation-tan-the-bisection-gori-thm-for-finding-root-of-the-equation-tanx-x-0-21636

The following (incomplete) code in Matlab was proposed to use the bisection method in order to compute a root of the equation tan x - x = 0. % The bisection algorithm for finding % a root of the equation tan(x)-x=0. f=inline('tan(x)-x'); a=4.3; b=4.6; iter=0; if f(a)*f(b)>0 error( 'f(a) and f(b) do not have opposite signs' ) else p = (a + b)/2; err = abs(f(p)); while err > 0.01 if f(a)*f(p)<0 .....; else .....; end iter=iter+1; .....; err = abs(f(p)); end end (a) Fill in the lines indicated by the arrows in order to complete the above code. Note: You are NOT allowed to change or remove any other lines of the code. (b) How many iterations are needed for the above accuracy? (c) What is the approximation of the root of tan x - x = 0 computed by the above (completed) code?

Sri K.

for-the-function-xexsx-05-ix-x-a-use-matlab-to-plot-the-function-for-values-of-x-in-the-range-2-2-important-notes-include-copy-of-your-matlab-code-in-your-solution-include-the-plot-of-the-fu-91754

Sri K.

provide-an-nonlinear-shooting-method-routine-with-secant-method-matlab-code-to-solve-the-following-bvps-in-each-problem-show-the-iterates-returned-from-the-secant-routine_-also-graph-the-sol-88407

Sri K.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 2,000 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,888 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,121 solutions

*

Transcript

-
00:01 Here the matlab code will be % the bisection algorithm for finding % a root of the equation tan x -x equals to 0.
00:39 If it equals to inline tan x -x.
00:46 Here for a equals to 4 .3, b equals to 4 .6, ? equals to?.
01:00 If f a star f b greater 0, ? equals to 0...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever