MSC321 Homework 3
MSC321
February 10, 2011
1
Reviews
1. What are the differences between functions and subroutines?
2. How are arguments passed to procedures in FORTRAN?
3. What does the term “dummy argument” refer to and contrast it to an “actual argument”
4. Explain why dummy and actual arguments have to agree on position and data type
5. Explain what an interface block is and why it is useful in programming.
6. What are the differences between an internal procedure and an external procedure?
2
Coordinate transformation
The transformations between cartesian coordinates (
x, y
) and polar coordinates (
r, θ
) are
(
r
=
√
x
2
+
y
2
θ
=
tan

1
y
x
and its inverse
(
x
=
r
cos
θ
y
=
r
sin
θ
(1)
Write a module with subroutines
cart2pol(r,t,x,y)
and
pol2cart(x,y,r,t)
that transform
cartesian coordinates
x
,
y
into polar coordinates (
r, θ
) and vice versa.
Test these subroutines on
the 4 points (
±
1
,
±
1)
/
√
2, use the inverse transformation to recover the original points. Use the
intrinsic function atan2 to find the angle which should be reported in degrees.
3
Function and derivative evaluation
Write a module with a subroutine
disp(f,df,x)
that calculates the function
f
(
x
) =
x
tanh
x

1
/
4
and its derivative
f
0
(
x
) = tanh
x
+
x
(1

tanh
2
x
) given
x
. Use this subroutine to calculate these
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Staff
 Subroutine, Polar coordinate system

Click to edit the document details