How to Use Calculating Hyperbolic Functions

From Java Example Source Code

Jump to: navigation, search

Contents

[edit] Overview - How to Use Calculating Hyperbolic Functions

This example program shows how to use calculating hyperbolic functions in Java.

[edit] Java Source Code

  • Package: example.math
  • File: HypFun.java
package example.math;
 
strictfp class HypFun {
    public static void main(String[] args) {
	double rads, degs, sinHA, cosHA, tanHA, asinHA;
 
	// Obtain angle in degrees from user
	degs = 20d;
	// Convert degrees to radian
	rads = Math.toRadians(degs);
 
	// Calculate hyperbolic sine
	sinHA = (Math.exp(rads) - Math.exp(-rads)) / 2;
	System.out.println("Hyperbolic sine = " + sinHA);
 
	// Calculate Hyperbolic cosine
	cosHA = (Math.exp(rads) + Math.exp(-rads)) / 2;
	System.out.println("Hyperbolic cosine = " + cosHA);
 
	// Calculate hyperbolic tangent
	tanHA = sinHA / cosHA;
	System.out.println("Hyperbolic tangent = " + tanHA);
 
	// Calculate hyperbolic arc-sine
	asinHA = Math.log(sinHA + Math.sqrt((sinHA * sinHA) + 1.0));
	degs = Math.toDegrees(asinHA);
	System.out.println("Arc hyperbolic sine = " + degs);
    }
}

[edit] What Result You Can Get

Run the program, you will get:

Hyperbolic sine = 0.35619793240001163
Hyperbolic cosine = 1.0615446137803364
Hyperbolic tangent = 0.3355468322066387
Arc hyperbolic sine = 19.99999999999999

[edit] Required External Libraries and/or Files for this Java Example

Need nothing.


[edit] How to Run this Java Example Program

We recommend running this Java example program with Eclipse.

For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.

It's fairly easy.



[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools