List of usage examples for java.lang Math cosh
public static double cosh(double x)
From source file:Main.java
public static void main(String[] args) { double x = 45.0; double y = 180.0; // convert them to radians x = Math.toRadians(x);//from www . ja v a 2 s . c o m y = Math.toRadians(y); // output their hyperbolic cosine System.out.println("Math.cosh(" + x + ")=" + Math.cosh(x)); System.out.println("Math.cosh(" + y + ")=" + Math.cosh(y)); }
From source file:net.sf.dsp4j.octave.packages.signal_1_2_0.NCauer.java
public NCauer(double Rp, double Rs, int n) { // Cutoff frequency = 1: double wp = 1; // Stop band edge ws: double ws = __ellip_ws(n, Rp, Rs); double k = wp / ws; double k1 = Math.sqrt(1.0 - Math.pow(k, 2)); double q0 = (1.0 / 2.0) * ((1.0 - Math.sqrt(k1)) / (1 + Math.sqrt(k1))); double q = q0 + 2.0 * Math.pow(q0, 5) + 15.0 * Math.pow(q0, 9) + 150.0 * Math.pow(q0, 13); //%(....) double D = (Math.pow(10, 0.1 * Rs) - 1.0) / (Math.pow(10, (0.1 * Rp)) - 1.0); //Filter order maybe this, but not used now: //n=ceil(log10(16*D)/log10(1/q)) double l = (1.0 / (2.0 * n)) * Math.log((Math.pow(10, 0.05 * Rp) + 1.0) / (Math.pow(10, 0.05 * Rp) - 1.0)); double sig01 = 0; double sig02 = 0; for (int m = 0; m <= 30; m++) { sig01 = sig01 + Math.pow((-1), m) * Math.pow(q, (m * (m + 1))) * Math.sinh((2 * m + 1) * l); }/*w w w . j a v a 2 s.com*/ for (int m = 1; m <= 30; m++) { sig02 = sig02 + Math.pow(-1.0, m) * Math.pow(q, (Math.pow(m, 2))) * Math.cosh(2 * m * l); } double sig0 = Math.abs((2.0 * Math.pow(q, (1.0 / 4.0)) * sig01) / (1.0 + 2.0 * sig02)); double w = Math.sqrt((1.0 + k * Math.pow(sig0, 2)) * (1.0 + Math.pow(sig0, 2) / k)); int r; if (n % 2 != 0) { r = (n - 1) / 2; } else { r = n / 2; } double[] wi = new double[r]; for (int ii = 1; ii <= r; ii++) { double mu; if (n % 2 != 0) { mu = ii; } else { mu = (double) ii - 0.5; } double soma1 = 0; for (int m = 0; m <= 30; m++) { soma1 = soma1 + 2.0 * Math.pow(q, (1.0 / 4.0)) * (Math.pow(-1.0, m) * Math.pow(q, (m * (m + 1))) * Math.sin(((2.0 * m + 1.0) * Math.PI * mu) / n)); } double soma2 = 0; for (int m = 1; m <= 30; m++) { soma2 = soma2 + 2.0 * (Math.pow(-1.0, m) * Math.pow(q, (Math.pow(m, 2))) * Math.cos((2.0 * m * Math.PI * mu) / n)); } wi[ii - 1] = (soma1 / (1.0 + soma2)); } double[] Vi = new double[wi.length]; for (int i = 0; i < wi.length; i++) { Vi[i] = Math.sqrt((1.0 - (k * (Math.pow(wi[i], 2)))) * (1.0 - (Math.pow(wi[i], 2)) / k)); } double[] A0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { A0i[i] = 1.0 / (Math.pow(wi[i], 2)); } double[] sqrA0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { sqrA0i[i] = 1.0 / wi[i]; } double[] B0i = new double[wi.length]; for (int i = 0; i < wi.length; i++) { B0i[i] = (Math.pow((sig0 * Vi[i]), 2) + Math.pow((w * wi[i]), 2)) / Math.pow((1.0 + Math.pow(sig0, 2) * Math.pow(wi[i], 2)), 2); } double C01; if (wi.length == 0) { C01 = 1.0; } else { C01 = B0i[0] / A0i[0]; for (int i = 1; i < wi.length; i++) { C01 *= B0i[i] / A0i[i]; } } //Gain T0: if (n % 2 != 0) { T0 = sig0 * C01 * Math.sqrt(ws); } else { T0 = Math.pow(10, (-0.05 * Rp)) * C01; } //zeros: zer = new Complex[sqrA0i.length * 2]; for (int i = 0; i < sqrA0i.length; i++) { zer[i] = Complex.valueOf(0.0, sqrA0i[i]); zer[i + sqrA0i.length] = Complex.valueOf(0.0, -sqrA0i[i]); } //poles: pol = new Complex[Vi.length * 2]; for (int i = 0; i < Vi.length; i++) { pol[i] = new Complex(-2.0 * sig0 * Vi[i], 2.0 * wi[i] * w) .divide(2.0 * (1 + Math.pow(sig0, 2) * Math.pow(wi[i], 2))); pol[i + Vi.length] = new Complex(-2.0 * sig0 * Vi[i], -2.0 * wi[i] * w) .divide(2.0 * (1 + Math.pow(sig0, 2) * Math.pow(wi[i], 2))); } //If n odd, there is a real pole -sig0: if (n % 2 != 0) { pol = Arrays.copyOf(pol, pol.length + 1); pol[pol.length - 1] = new Complex(-sig0); } for (int i = 0; i < pol.length; i++) { pol[i] = pol[i].multiply(Math.sqrt(ws)); } for (int i = 0; i < zer.length; i++) { zer[i] = zer[i].multiply(Math.sqrt(ws)); } }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static ComplexNumber cos(final ComplexNumber z) { Validate.notNull(z, "z"); final double x = z.getReal(); final double y = z.getImaginary(); return new ComplexNumber(Math.cos(x) * Math.cosh(y), -Math.sin(x) * Math.sinh(y)); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static double cosh(final double x) { return Math.cosh(x); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static ComplexNumber cosh(final ComplexNumber z) { Validate.notNull(z, "z"); return new ComplexNumber(Math.cosh(z.getReal()) * Math.cos(z.getImaginary()), Math.sinh(z.getReal()) * Math.sin(z.getImaginary())); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static ComplexNumber sin(final ComplexNumber z) { Validate.notNull(z, "z"); final double x = z.getReal(); final double y = z.getImaginary(); return new ComplexNumber(Math.sin(x) * Math.cosh(y), Math.cos(x) * Math.sinh(y)); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static ComplexNumber sinh(final ComplexNumber z) { Validate.notNull(z, "z"); return new ComplexNumber(Math.sinh(z.getReal()) * Math.cos(z.getImaginary()), Math.cosh(z.getReal()) * Math.sin(z.getImaginary())); }
From source file:com.duy.pascal.interperter.libraries.math.MathLib.java
@PascalMethod(description = "") public double Cosh(double d) { return Math.cosh(d); }
From source file:com.nextbreakpoint.nextfractal.mandelbrot.core.Expression.java
public static Number funcSin(MutableNumber out, Number x) { return out.set(Math.sin(x.r()) * Math.cosh(x.i()), +Math.cos(x.r()) * Math.sinh(x.i())); }
From source file:com.nextbreakpoint.nextfractal.mandelbrot.core.Expression.java
public static Number funcCos(MutableNumber out, Number x) { return out.set(Math.cos(x.r()) * Math.cosh(x.i()), -Math.sin(x.r()) * Math.sinh(x.i())); }