Schedule LabAssignments LabInstructions

Lab Five

Assignment

Write two functions that return the nearest root based on some initials guesses. One function should utilize the secant method, and the other the bisection method. Then test your program by finding the roots of a couple of equations.

Python Functions

Inputs:

  • f an arbitrary function
  • a the left guess
  • b the right guess
  • d=1E-3 a default precision

Outputs:

  • best guess
  • number of iteration

Math Functions

Test your program by find the zero of following functions:

  • cos(x) - x
  • sin(5x)/x near pi

On your wiki page, post the results, including:

  • the number found
  • the number of iterations
  • the error

References

From Wikipedia: