Basic Plan of Attack


Let us use what we have learned in the first half of this book to design our user -defined math methods. Our methods will have to be defined inside a class, which we will call Math2 . We want the methods to be freely accessible to other programs, so the methods will be declared to be public and static . We will organize the user-defined math capability by placing the Math2 class in a package named TechJava.MathLib . If at some point we develop more user-defined math classes, they can be placed in the TechJava.MathLib package as well.

The general approach for writing mathematical methods is to first find an approximate form for the function we wish to model. Generally speaking, the approximate form will involve a series or summation expression. For example, the sine function can be modeled using the Maclaurin series (Eq. (17.1)).

Equation 17.1

graphics/17equ01.gif


It is usually a good idea to build upon what already exists, so whenever possible we will leverage off of the existing Java math capability by incorporating Math class methods into our user-defined math methods.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net