{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lab9 - Engineering 7 Introduction to Programming for...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering 7: Prof. Alexandre Bayen Introduction to Programming for Engineers Spring 2011 Lab 9: Root Finding Date Assigned: 5:00pm, Friday – April 8 Date Due: 5:00pm, Friday – April 15. Problem 1: Write a function with header [R, E] = myBisection(f, a, b, tol) where f is a function handle, a and b are scalars such that a < b , and tol is a strictly positive scalar value. The function should return an array, R , where R(i) is the estimation of the root of f defined by (a + b)/2 for the i th iteration of the bisection method. Remember to include the initial estimate. The function should also return an array, E , where E(i) is the value of |f(R(i))| for the ith iteration of the bisection method. The function should terminate when E(i) < tol . You may assume that sign(f(a)) ~= sign(f(b)) . Clarification : The input a and b constitute the first iteration of bisection, and therefore, R and E should never be empty. Test Cases: >> f = @(x) x.^2 - 2; >> [R, E] = myBisection(f, 0, 2, 1e-1) R = 1.0000 1.5000 1.2500 1.3750 1.4375 E = 1.0000 0.2500 0.4375 0.1094 0.0664 >> f = @(x) sin(x) - cos(x); >> [R, E] = myBisection(f, 0, 2, 1e-2) R = 1.0000 0.5000 0.7500 0.8750 0.8125 0.7813 E = 0.3012 0.3982 0.0501 0.1265 0.0383 0.0059
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern