๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_math_cos.asp
Java Math cos() Method
System.out.println(Math.cos(3)); System.out.println(Math.cos(-3)); System.out.println(Math.cos(0)); System.out.println(Math.cos(Math.PI)); System.out.println(Math.cos(Math.PI/2)); ... The cos() method returns the cosine of an angle.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ lang โ€บ math_cos.htm
Java - Math cos(double) Method
The Java Math cos(double a) returns the trigonometric cosine of an angle.If the argument is NaN or an infinity, then the result is NaN. The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic. Following is the declaration for java.lang.Math.cos() method ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-math-cos-method
Java Math cos() Method - GeeksforGeeks
May 12, 2025 - In Java, the Math.cos() method returns the trigonometric cosine of an angle. This method calculates the cosine of the angle, which must be provided in radians. If the argument is NaN or an infinity, then the result returned is NaN.
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ library โ€บ math โ€บ cos
Java Math cos()
import java.lang.Math; class Main { public static void main(String[] args) { // create variable // square root of negative number // results in not a number (NaN) double a = Math.sqrt(-5); // Using Double to implement infinity double infinity = Double.POSITIVE_INFINITY; // print the cosine ...
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ java โ€บ math methods โ€บ .cos()
Java | Math Methods | .cos() | Codecademy
May 15, 2024 - The .cos() method returns the trigonometric cosine of the given angle. The result is in the range [-1, 1]. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more! ... Learn to code in Java โ€” a robust programming language used to create software, web and mobile apps, and more. Beginner Friendly.Beginner Friendly17 hours17 hours ... Note: If the angle is NaN or Infinity, NaN is returned. The following example ...
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ number_cos.htm
Java - cos() Method
The method returns the cosine of the specified double value. Here is the detail of parameters โˆ’ This will produce the following result โˆ’
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ lang โ€บ Math โ€บ cos
Java Math cos() - Calculate Cosine | Vultr Docs
September 27, 2024 - java Copy ยท for (int degrees = 0; degrees <= 360; degrees += 30) { double radians = Math.toRadians(degrees); double cosineValue = Math.cos(radians); System.out.println("Cosine of " + degrees + " degrees is: " + cosineValue); } Explain Code ...
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ java math โ€บ math.cos() method in java
Math.cos() method in Java
October 11, 2023 - double toRadians(double angDeg) ... Math.PI; //using java.lang.Math.cos() for 1, 0.5 and PI rad System.out.println("cosine of " + x1 + " rads = " + Math.cos(x1)); System.out.println("cosine of " + x2 + " rads = " + Math.cos(0)); ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ trigonometric-functions-in-java-with-examples
Trigonometric Functions in Java with Examples - GeeksforGeeks
May 27, 2019 - // Java program for cos() method ... double cosValue = Math.cos(radians); // prints the cosine value System.out.println("cos(" + degrees + ") = " + cosValue); } } Output: ... Java.lang.Math.tan() : is an inbuilt method which ...
Find elsewhere
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ home โ€บ java โ€บ java cos function
Java cos Function
March 26, 2025 - Cosine of 15.45 = -0.9669 Cosine of 65.64 = -0.9449 Cosine of 95.60 = 0.2168 Cosine of 120.75 = 0.2000 Cosine of 140.68 = -0.7702 Cosine of 180.98 = 0.3320 ยท Within this math cos function example, we used the For Loop to iterate the double ...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ java math cos()
Java Math cos() | Scaler Topics
April 14, 2024 - The value is stored in a'; it is then converted to radians using the Math. radians ()function and stored inb; we then use the cos()method onb` to obtain its cosine value. Letโ€™s see the implemenation of cos() with Double.POSITIVE_INFINITY in Java
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ lang โ€บ number_cos.htm
Java - Math.cos() Method
public class Test { public static void main(String args[]) { float degrees = (float)45.0; double radians = Math.toRadians(degrees); System.out.format("The value of pi is %.4f%n", Math.PI); System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians)); } } ... In this ...
๐ŸŒ
AlphaCodingSkills
alphacodingskills.com โ€บ java โ€บ note โ€บ java-math-cos.php
Java Math cos() Method - AlphaCodingSkills
In special cases it returns the following: If the argument is NaN or an infinity, then the result is NaN. In the graph below, cos(x) vs x is plotted. ... Returns the trigonometric cosine of an angle. ... In the example below, cos() method is used to find out the trigonometric cosine of an angle.
๐ŸŒ
BeginnersBook -
beginnersbook.com โ€บ home โ€บ java โ€บ java math.cos() method
Java Math.cos() Method
October 17, 2022 - This angle value is passed as an argument to this method and it returns the cosine value ranging from -1 to 1. For example, Math.cos(Math.toRadians(0)) returns 1.0. public class JavaExample { public static void main(String[] args) { double degrees = 0; //conversion
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ lang โ€บ Math โ€บ acos
Java Math acos() - Compute Arc Cosine | Vultr Docs
December 3, 2024 - This example calculates the angle between two vectors using the cosine rule. The result is the angle in radians. The Math.acos() function in Java is a critical tool for computing the arc cosine of a value, which helps derive angles from the cosine in mathematical and geometric computations.
๐ŸŒ
Apache Commons
commons.apache.org โ€บ sandbox โ€บ commons-text โ€บ jacoco โ€บ org.apache.commons.text.similarity โ€บ CosineSimilarity.java.html
CosineSimilarity.java - Apache Commons
* * @param leftVector left vector * @param rightVector right vector * @return cosine similarity between the two vectors */ public Double cosineSimilarity(final Map<CharSequence, Integer> leftVector, final Map<CharSequence, Integer> rightVector) { if (leftVector == null || rightVector == null) { throw new IllegalArgumentException("Vectors must not be null"); } final Set<CharSequence> intersection = getIntersection(leftVector, rightVector); final double dotProduct = dot(leftVector, rightVector, intersection); double d1 = 0.0d; for (final Integer value : leftVector.values()) { d1 += Math.pow(valu
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ java-program-implement-cos-function
Java Program to Implement the cos() Function
May 12, 2025 - Case 1 (Simple Test Case): Enter the angle whose cosine is to be calculated in degrees 45 The cosine of 45.0 is 0.707107 Case 2 (Simple Test Case - another example): Enter the angle whose cosine is to be calculated in degrees 75 The cosine of ...