Question

Lastname, Firstname MECH 1314 Homework #12-Bisection Due: 4/22/2019 Instructions: Submit your script in a file named hwk12.m

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function bisection_UDF(inputVec)
lower=inputVec(1);
upper=inputVec(2);
zero=inputVec(3);
maxIter=inputVec(4);
iter=1;
root=(lower+upper)/2;
while abs(myFunction(root))>zero && iter<maxIter
    if (myFunction(lower)*myFunction(root)<0)
        upper=root;
    else
        lower=root;
    end
    iter=iter+1;
    root=(lower+upper)/2;
end
if iter<maxIter
    fprintf('Approximated root: %f\nFunction value at root: %f\n',root,myFunction(root))
else
    fprintf('Approximate value for root has not been found after %d iterations.\n',iter)
end

Add a comment
Know the answer?
Add Answer to:
Lastname, Firstname MECH 1314 Homework #12-Bisection Due: 4/22/2019 Instructions: Submit your scr...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

  • Instructions: Submit your script in a file named hwk08.m to the dropbox before 11:59 pm on the du...

    Instructions: Submit your script in a file named hwk08.m to the dropbox before 11:59 pm on the due date NOTE: This assignment is neither quick nor simple. You will be well served to start on it early, and to ask for help if you need it. Being a more substantial assignment than earlier hwk, it is worth- s. When you ask your calculator for the value of a function for a specified argument, (e.g., sin(22), cos(74), In(6.5)), it almost certainly...

  • Submission Items: (1) A Word document in which you: a. Describe in brief the problem you...

    Submission Items: (1) A Word document in which you: a. Describe in brief the problem you are solving and the numerical method used. b. Snapshot of the output, when you run the program for the conditions mentioned in the questions. c. Discuss your results. (2) MATLAB code (m) file() Question 1: [10 points) Write a MATLAB function that calculates the approximate value of arctan(x) using the Maclaurin series approximation: arctan(x) = x- + +... The function should accept 3 parameters:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT