Calculate arc-tangent in Java

Description

The following code shows how to calculate arc-tangent.

Example


//  www .  j  av a 2  s. c o m
public class Main {
  public static void main(String[] args) {
    double rads, degs, tanA, coTanA;

    // Obtain angle in degrees from user
    degs = 120d;
    // Convert degrees to radian
    rads = Math.toRadians(degs);

    // Calculate tangent
    tanA = Math.tan(rads);
    System.out.println("Tangent = " + tanA);

    
    // Calculate arc-tangent
    rads = Math.atan(tanA);
    degs = Math.toDegrees(rads);
    System.out.println("Arc tangent: " + degs);
    
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization