Example usage for java.lang Math log

List of usage examples for java.lang Math log

Introduction

In this page you can find the example usage for java.lang Math log.

Prototype

@HotSpotIntrinsicCandidate
public static double log(double a) 

Source Link

Document

Returns the natural logarithm (base e) of a double value.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println("Natural logarithm value of 2 is : " + Math.log(2));
}

From source file:MainClass.java

public static void main(String args[]) {
    System.out.println(Math.log(12.234));
}

From source file:Main.java

public static void main(String args[]) {
    double loanAmount = 0;
    double top = 2 * 5 / 1200;
    double bot = 1 - Math.exp(5 * (-12) * Math.log(1 + 7 / 1200));

    System.out.println(loanAmount);
    System.out.println(top);//w w  w.j  av  a 2s  .c om
    System.out.println(bot);
}

From source file:Main.java

public static void main(String[] args) {
    double x = 123456.7;
    double y = -123.45;

    // get the natural logarithm for x
    System.out.println("Math.log(" + x + ")=" + Math.log(x));

    // get the natural logarithm for y
    System.out.println("Math.log(" + y + ")=" + Math.log(y));

}

From source file:MainClass.java

public static void main(String[] args) {
    double num, loge, log10, aloge, alog10;

    // Obtain input from user
    num = 0.111d;// w  ww .  jav a2s .  com

    // Calculate and display the natural logarithm
    loge = Math.log(num);
    System.out.println("log base e = " + loge);
    // Calculate the common log
    log10 = Math.log(num) / Math.log(10.0);
    System.out.println("log base 10 = " + log10);

    // Calculate the antilogarithm of log base e
    aloge = Math.exp(loge);
    System.out.println("antilog of log base e = " + aloge);

    // Calculate the antilogarithm of log base 10
    alog10 = Math.pow(10.0, log10);
    System.out.println("anitlog of log base 10 = " + alog10);
}

From source file:Main.java

public static void main(String[] args) {
    int a = 10;/*from  w w w  .  ja v  a 2s .c  o m*/
    int b = -50;
    int c = 3;
    double x = 25.0;
    double y = 3.0;
    double z = 4.0;

    System.out.println("abs(b)     = " + Math.abs(b));
    System.out.println("cbrt(x)   = " + Math.cbrt(x));
    System.out.println("exp(y)     = " + Math.exp(z));
    System.out.println("hypot(y, z)= " + Math.hypot(y, z));

    System.out.println("log(y)    = " + Math.log(y));
    System.out.println("log10(y)  = " + Math.log10(y));
    System.out.println("max(a, b) = " + Math.max(a, b));
    System.out.println("min(a, b) = " + Math.min(a, b));
    System.out.println("pow(a, c) = " + Math.pow(a, c));
    System.out.println("random()  = " + Math.random());
    System.out.println("signum(b) = " + Math.signum(b));
    System.out.println("sqrt(x)   = " + Math.sqrt(y));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DataLine.Info info = null;/*from  w w  w .  j av a2 s .  com*/
    Clip clip = (Clip) AudioSystem.getLine(info);

    FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    double gain = .5D; // number between 0 and 1 (loudest)
    float dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0);
    gainControl.setValue(dB);

    BooleanControl muteControl = (BooleanControl) clip.getControl(BooleanControl.Type.MUTE);
    muteControl.setValue(true);

    muteControl.setValue(false);

}

From source file:HypFun.java

public static void main(String[] args) {
    double rads, degs, sinHA, cosHA, tanHA, asinHA;

    // Obtain angle in degrees from user
    degs = 20d;//from  ww  w . ja v  a  2 s. c o  m
    // 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);
}

From source file:MainClass.java

public static void main(String args[]) {
    System.out.printf("Math.abs( 23.7 ) = %f\n", Math.abs(23.7));
    System.out.printf("Math.abs( 0.0 ) = %f\n", Math.abs(0.0));
    System.out.printf("Math.abs( -23.7 ) = %f\n", Math.abs(-23.7));
    System.out.printf("Math.ceil( 9.2 ) = %f\n", Math.ceil(9.2));
    System.out.printf("Math.ceil( -9.8 ) = %f\n", Math.ceil(-9.8));
    System.out.printf("Math.cos( 0.0 ) = %f\n", Math.cos(0.0));
    System.out.printf("Math.exp( 1.0 ) = %f\n", Math.exp(1.0));
    System.out.printf("Math.exp( 2.0 ) = %f\n", Math.exp(2.0));
    System.out.printf("Math.floor( 9.2 ) = %f\n", Math.floor(9.2));
    System.out.printf("Math.floor( -9.8 ) = %f\n", Math.floor(-9.8));
    System.out.printf("Math.log( Math.E ) = %f\n", Math.log(Math.E));
    System.out.printf("Math.log( Math.E * Math.E ) = %f\n", Math.log(Math.E * Math.E));
    System.out.printf("Math.max( 2.3, 12.7 ) = %f\n", Math.max(2.3, 12.7));
    System.out.printf("Math.max( -2.3, -12.7 ) = %f\n", Math.max(-2.3, -12.7));
    System.out.printf("Math.min( 2.3, 12.7 ) = %f\n", Math.min(2.3, 12.7));
    System.out.printf("Math.min( -2.3, -12.7 ) = %f\n", Math.min(-2.3, -12.7));
    System.out.printf("Math.pow( 2.0, 7.0 ) = %f\n", Math.pow(2.0, 7.0));
    System.out.printf("Math.pow( 9.0, 0.5 ) = %f\n", Math.pow(9.0, 0.5));
    System.out.printf("Math.sin( 0.0 ) = %f\n", Math.sin(0.0));
    System.out.printf("Math.sqrt( 900.0 ) = %f\n", Math.sqrt(900.0));
    System.out.printf("Math.sqrt( 9.0 ) = %f\n", Math.sqrt(9.0));
    System.out.printf("Math.tan( 0.0 ) = %f\n", Math.tan(0.0));
}

From source file:ExponentialDemo.java

public static void main(String[] args) {
    double x = 11.635;
    double y = 2.76;

    System.out.printf("The value of e is %.4f%n", Math.E);
    System.out.printf("exp(%.3f) is %.3f%n", x, Math.exp(x));
    System.out.printf("log(%.3f) is %.3f%n", x, Math.log(x));
    System.out.printf("pow(%.3f, %.3f) is %.3f%n", x, y, Math.pow(x, y));
    System.out.printf("sqrt(%.3f) is %.3f%n", x, Math.sqrt(x));
}