
AOE/ESM 2074
Introduction to Computational Methods
H.W. Set 4
due 20 September 2000
1. Read Chapter 5 through page 183 in the Chapman text.
2. Write a Matlab script to evaluate the Maclaurin series approximation of tan(x), the
tangent of x. The code should ask the user to specify a value of xand a tolerance and
then evaluate the partial sum until the next term (the ļ¬rst one not included) is less
than the speciļ¬ed value. Compare the series approximation to the value provided the
Matlab tan function.
Turn in a listing of your command script and the diary from exercising the code for
x=0.2,tol=.0001.
3. Generalize the random walk code so that it will repeat the entire walk sequence for a
user speciļ¬ed number of times (say m= 500). Compute the probablity that the sailor
falls of the pier of length 15 in 1000 steps for the coin-toss probablility parameter
p=.5. Repeat the calculation for several values of the pier length parameter. Draw a
graph of the fall-oļ¬ probablity versus the pier length and estimate the value of length
so that there is about a 50% chance of falling oļ¬ the pier.
Turn in the listing of your script ļ¬le, including ācommentsā, and a well-labeled graph.
Annotate the graph to distinguish the value of the length parameter for which there is
a 50% chance of falling oļ¬ the pier.
4. Write a Matlab function .m ļ¬le to convert from plane Cartesian (x, y) to plane polar
(r, Īø)coordinates.
Turn in a listing of your function and a diary illustrating the use of your code for
the point (1,2).
5. Write a Matlab function .m ļ¬le to convert from Cartesian (x, y, z) to spherical polar
coordinates (r, Īø, Ļ), where Ļis the co-latitude, the angle between the positive z-axis
and the radial vector to the point.
Turn in a listing of your function and a diary illustrating the use of your code for
the point (1,2,2).
1