Information Technology Reference
In-Depth Information
(a) Show that the water volume is given by the expression
V D Z H
0
Z 2
Z R.x/
rdrddx :
(6.14)
0
0
Here, .r;;x/ denotes cylindrical coordinates. Show that the integral (6.14)
reduces to
V D Z H
0
ŒR.x/ 2 dx :
(6.15)
(b) Write the function R.x/ in Fig. 6.3 as mathematical pseudo code.
(c) Write a mathematical pseudo code for calculating V ,
volume ( R , H , n )
given R.x/ , H , the number of evaluation points n , using the trapezoidal rule.
(d) Implement the algorithm from (c) with the aid of a programming language.
(e) Show how an implementation of Algorithm 6.2 in a specific programming lan-
guage can be reused as is for computing V . (Hint: Define a function f.x/ as
ŒR.x/ 2 , with R.x/ as a global function.) Discuss the pros and cons of this
approach and the tailored solution in (d).
6.7.2
A Class Hierarchy for Scalar ODE Solvers
This project concerns applying the ideas of Sect. 6.5.2 to the solution of scalar
ODEs. We introduce a base class ODESolver for all solver algorithms, and a
class ODESolver prm holding all parameters needed for initializing and running an
ODESolver subclass instance.
(a) Write a pseudo code for class ODESolver prm , specifying data members and
methods.
(b) Write a pseudo code for class ODESolver .
(c) Write a pseudo code for a specific ODE algorithm, such as Heun's method, as
a subclass of ODESolver .
(d) Implement the class hierarchies in Java, C CC , and Python.
(e) Find at least three different solution algorithms for the ODEs and implement
these algorithms as subclasses of ODESolver .
(f) Make libraries out of the implementation in (e). The C CC library can be named
libODE.a , the Java library ODE.jar , and the Python module ODE.py .(See
Sect. 6.5.1 for information on how to create such libraries.)
(g) Construct a test problem for verifying the implementation. Write associated
main programs and check that the code works. The main programs should make
use of the libraries from (f).
 
Search WWH ::




Custom Search