next up previous
Next: About this document ...

ESC 251 HW 18 Due: Oct. 20

Reminder: All counting variables must be of INTEGER datatype.

1)
(2 pts) Write an F90 program that will tabulate the sine and cosine functions on the interval $[0^{\circ},45^{\circ} ]$ in steps of $5^{\circ}.$
2)
(4 pts) Write an F90 program that will tabulate the function below for $x \in [0,\pi].$ Use n = 15.

\begin{displaymath}f(x) = \left\{ \begin{array}{ll}
x^2 + x -2 \,\,\,\quad \mbo...
...or} \quad \frac{\pi}{2} \le x \le \pi \\
\end{array} \right. \end{displaymath}

3)
(5 pts) Suppose you need to generate a set of n+1 equally spaced points on some interval of the x-axis, [a,b], given the values of a, b and the number of subdivisions, n. There are 2 ways to do this:
      Method 1:
         h = (b-a)/n
         x = a
         DO i = 2,n+1
            x = x + h
         ENDDO

      Method 2:
         h = (b-a)/n
         DO i = 1,n+1
            x = a + (i-1)*h
         ENDDO
Test both methods using the values $a = -\displaystyle{\frac{\pi}{2}} , b = \displaystyle{\frac{\pi}{3}}$ and n = 123456789. For both cases, compute the relative error in the value of x once the loop terminates (this should be equal to b). Which method is more accurate (i.e., which method has the smaller relative error)? Explain why the more accurate method has the lower relative error.




2017-10-18