Assignment 4: Square-Roots and Cube

advertisement
MthSc 360 — Goddard — Spring13
Assignment 4: Square-Roots and Cube-Roots
Construct a function that calculates square-roots numerically using the following method.
Say you want the square-root of A. Start with an A × 1 rectangle. The method repeatedly
constructs rectangles that have area A, each time getting closer and closer to a square. Given a
rectangle with area A, it constructs another rectangle by starting with side-length the average
of the two side-lengths. It repeats the process until it achieves the desired accuracy.
Specifically, create a MATLAB function mysqrt that takes two values: the number and how
many decimal places of accuracy.
Then, adapt the procedure to calculate cube-roots, and create a suitable MATLAB function
mycuberoot.
Submit on one (two-sided) page:
• Copy of your mycuberoot function.
• Output of your two functions when applied to your CUID.
• Discussion of how the number of steps needed compares with the bisection method
discussed in class.
Due start of class: Wednesday 13 February
Download