List of usage examples for java.lang Math exp
@HotSpotIntrinsicCandidate public static double exp(double a)
From source file:Main.java
public static void main(String[] args) { System.out.println("Exponential of 2 is : " + Math.exp(2)); }
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 a va 2s .co m System.out.println(bot); }
From source file:Main.java
public static void main(String[] args) { double x = 5; double y = 0.5; // print e raised at x and y System.out.println("Math.exp(" + x + ")=" + Math.exp(x)); System.out.println("Math.exp(" + y + ")=" + Math.exp(y)); }
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;//w w w . ja v a 2s .com // 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:Main.java
public static void main(String[] args) { int a = 10;//from w w w . j av a 2 s.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:MainClass.java
public static void main(String[] args) { double num, loge, log10, aloge, alog10; // Obtain input from user num = 0.111d;/*from w ww . j ava2 s . c om*/ // 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: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:mase.deprecated.FastMathTest.java
public static void main(String[] args) { double MIN = -10; double MAX = 10; int N = 10000; DescriptiveStatistics diff = new DescriptiveStatistics(); DescriptiveStatistics diffJava = new DescriptiveStatistics(); long tFast = 0, tNormal = 0, tBounded = 0, tJava = 0; for (int i = 0; i < N; i++) { double x = Math.random() * (MAX - MIN) + MIN; long t = System.nanoTime(); double v1 = (1.0 / (1.0 + FastMath.expQuick(-1 * x))); tFast += System.nanoTime() - t; t = System.nanoTime();/*from w w w . j av a2s. co m*/ double v2 = (1.0 / (1.0 + FastMath.exp(-1 * x))); tNormal += System.nanoTime() - t; t = System.nanoTime(); double v3 = (1.0 / (1.0 + BoundMath.exp(-1 * x))); tBounded += System.nanoTime() - t; t = System.nanoTime(); double v4 = (1.0 / (1.0 + Math.exp(-1 * x))); tJava += System.nanoTime() - t; diff.addValue(Math.abs(v1 - v2)); diffJava.addValue(Math.abs(v3 - v1)); } System.out.println("MAX: " + diff.getMax()); System.out.println("MEAN: " + diff.getMean()); System.out.println("MAX JAVA: " + diffJava.getMax()); System.out.println("MEAN JAVA: " + diffJava.getMean()); System.out.println("Fast: " + tFast); System.out.println("Normal: " + tNormal); System.out.println("Bounded: " + tBounded); System.out.println("Java: " + tJava); }
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)); }
From source file:ExponentialDemo.java
public static void main(String[] args) { double x = 11.635; double y = 2.76; System.out.println("The value of e is " + Math.E); System.out.println("exp(" + x + ") is " + Math.exp(x)); System.out.println("log(" + x + ") is " + Math.log(x)); System.out.println("pow(" + x + ", " + y + ") is " + Math.pow(x, y)); System.out.println("sqrt(" + x + ") is " + Math.sqrt(x)); }