List of usage examples for java.lang StrictMath tan
public static native double tan(double a);
From source file:Main.java
public static void main(String[] args) { double d1 = (45 * Math.PI) / 180, d2 = 0.0; System.out.println("tangent value of d1 : " + StrictMath.tan(d1)); System.out.println("tangent value of d2 : " + StrictMath.tan(d2)); }
From source file:net.nicoulaj.benchmarks.math.DoubleTan.java
@GenerateMicroBenchmark public void strictmath(BlackHole hole) { for (int i = 0; i < data.length - 1; i++) hole.consume(StrictMath.tan(data[i])); }
From source file:org.deidentifier.arx.risk.Gamma.java
/** * Approximates the digamma function. Java port of the * "The Lightspeed Matlab toolbox" version 2.7 by Tom Minka see: * http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/ * /* ww w. j ava 2s . com*/ * @param x * input value * @return approximation of digamma for x */ static double digamma(double x) { /* Illegal arguments */ if (Double.isInfinite(x) || Double.isNaN(x)) { return Double.NaN; } /* Singularities */ if (x == 0.0d) { return Double.NEGATIVE_INFINITY; } /* Negative values */ /* * Use the reflection formula (Jeffrey 11.1.6): digamma(-x) = * digamma(x+1) + pi*cot(pi*x) * * This is related to the identity digamma(-x) = digamma(x+1) - * digamma(z) + digamma(1-z) where z is the fractional part of x For * example: digamma(-3.1) = 1/3.1 + 1/2.1 + 1/1.1 + 1/0.1 + * digamma(1-0.1) = digamma(4.1) - digamma(0.1) + digamma(1-0.1) Then we * use digamma(1-z) - digamma(z) = pi*cot(pi*z) */ if (x < 0.0d) { return digamma(1.0d - x) + (StrictMath.PI / StrictMath.tan(-StrictMath.PI * x)); } /* Use Taylor series if argument <= small */ if (x <= SMALL_DIGAMMA) { return (DIGAMMA_1 - (1.0d / x)) + (TRIGAMMA_1 * x); } double result = 0.0d; /* Reduce to digamma(X + N) where (X + N) >= large */ while (x < LARGE_DIGAMMA) { result -= 1.0d / x; x++; } /* Use de Moivre's expansion if argument >= C */ /* This expansion can be computed in Maple via asympt(Psi(x),x) */ if (x >= LARGE_DIGAMMA) { double r = 1.0d / x; result += StrictMath.log(x) - (0.5d * r); r *= r; result -= r * (S3 - (r * (S4 - (r * (S5 - (r * (S6 - (r * S7)))))))); } return result; }
From source file:org.esa.beam.util.math.FastMathPerformance.java
public void testTan() { System.gc();//w w w . j a v a 2s .co m double x = 0; long time = System.nanoTime(); for (int i = 0; i < RUNS; i++) x += StrictMath.tan(i * F1); long strictTime = System.nanoTime() - time; System.gc(); double y = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) y += FastMath.tan(i * F1); long fastTime = System.nanoTime() - time; System.gc(); double z = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) z += Math.tan(i * F1); long mathTime = System.nanoTime() - time; report("tan", x + y + z, strictTime, fastTime, mathTime); }