Hyperbolic Trigonometric Methods


Hyperbolic Trigonometric Methods

Another useful set of mathematical functions that are provided by the C, C++, and Fortran ”but not the Java ”libraries are the hyperbolic sine, cosine, and tangent functions. These can be used to solve certain types of second-order differential expressions, for example. We will define methods to compute the sinh, cosh, and tanh functions in the Math2 class.

The hyperbolic sine and cosine functions are defined as combinations of e x and e x shown in Eq. (17.5).

Equation 17.5

graphics/17equ05.gif


As you would probably expect, the hyperbolic tangent function is the ratio of the hyperbolic sine and cosine functions (Eq. (17.6)).

Equation 17.6

graphics/17equ06.gif


You can see from Eq. (17.5) and Eq. (17.6), the hyperbolic trigonometric functions are easily implemented using the Math.exp() method. The code listings for these methods are ”

 public static double sinh(double a) {   return 0.5*(Math.exp(a) - Math.exp(-a)); } public static double cosh(double a) {   return 0.5*(Math.exp(a) + Math.exp(-a)); } public static double tanh(double a) {   double e1 = Math.exp(a);   double e2 = Math.exp(-a);   return (e1-e2)/(e1+e2); } 

As with the logarithmic methods, the sinh() and cosh() hyperbolic trigonometric methods consist of one executable statement. The tanh() method requires three lines of code.



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