Java Math cosh() Function
Java Math Class
Java Math class provides several methods to perform several operations on math calculations like max(), min(), sin(), cos(), round(), ceil(), floor(), abs(), cosh Function etc.
The java.lang.Math class contains various methods for performing basic numeric operations
Here, in the page we will discuss about the cosh Function of Math class in java.
Java cosh Function :
Java Collection contains Math class and The class Math contains methods for performing basic and advance numeric operations such as the exponential, logarithm, square root, and trigonometric functions.
The cosh Function of math class in Java returns the hyperbolic cosine of the input angle. It is a static function so we can access it by using the Math class.
Syntax:
Math.cosh(number);
Definition of Parameters:
Return Type :
- For positive or negative number, It returns hyperbolic cosine value.
- For 0 as argument, It will return 1.
- For Infinity, It will return + Infinity.
- For NaN argument, this method will return NaN.
Example :
import java.util.*; public class Main{ public static void main(String[] args){ // Initializing variables in Degree int a = 0; int b = 60; // Using cosh Function double cosha = Math.cosh(a); double coshb = Math.cosh(b); // Printing Values of Variables System.out.println("Cos Value For angle a : " + cosha); System.out.println("Cos Value For angle b : " + coshb); } }
Output: Cos Value For angle a : 1.0 Cos Value For angle b : 5.710036949078421E25
In the above Example, We had taken two variables with two different angles stored in them. we need to store the hyperbolic cosine values of the given angles in variables of double data type.
Example:
import java.util.*; public class Main{ public static void main(String[] args){ // Initializing variables in Degree int a = 0; int b = 60; // converting variables to radians double radiana = Math.toRadians(a); double radianb = Math.toRadians(b); // printing cosine values System.out.println("Cos value of a : " + Math.cosh(radiana)); System.out.println("Cos value of b : " + Math.cosh(radianb)); } }
Output: Cos value of a : 1.0 Cos value of b : 1.600286857702386
In the above Example, We had converted the given angle into radians because as per the official documentation of Java, the cos() method takes the angle as radians.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment