QUESTION

# Give a program in python to do the following: A zero z of a function f(x) is a value of x such that f(x)=0. This problem deals with a method to find zeros. Motivation (click to view)A so-called 'black

Give a program in python to do the following:

A zero z of a function f(x) is a value of x such that f(x)=0. This problem deals with a method to find zeros.

Motivation (click to view)

A so-called 'black-box' zero-finding method is only allowed to evaluate the function f at some x's of its choosing--it does not usually have any special knowledge about the function--it treats the function as a black box. These function evaluations are typically viewed as expensive, so whichever method does fewer of them wins. Usually, both x and f are vector-valued, but in this problem, we'll assume that they're just scalars. We'll get to the vector-valued case later in the class. As an example, consider a material scientist who, using a complicated computer program, can figure out what composition of alloy has what tensile strength. But what if he wants the opposite? Assume he knows the tensile strength, but wants to know a possible composition of an alloy.

By the way, there's a reason we care so much about just zeros: If you can find a zero, you can solve any equation f(x)=c: You can just run your zero-finding method on a new function g(x)=f(x)−c, and a zero of g will solve f(x)=c.

The bisection methodMethod description (click to view)

In addition to the function f, the bisection method takes as input two points a and b which "bracket" a zero and a tolerance ϵ. Bracketing the zero means that the sign of f at a is different from the sign of f at b.

Mathematically speaking, you will receive as input a and b with a