public Complex tanh() { double scalar; double temp1Re, temp1Im; double temp2Re, temp2Im; Complex sinRes, cosRes; // tanh(z) = sinh(z) / cosh(z) scalar = Math.exp(re); temp1Re = scalar * Math.cos(im); temp1Im = scalar * Math.sin(im); scalar = Math.exp(-re); temp2Re = scalar * Math.cos(-im); temp2Im = scalar * Math.sin(-im); temp1Re -= temp2Re; temp1Im -= temp2Im; sinRes = new Complex(0.5 * temp1Re, 0.5 * temp1Im); scalar = Math.exp(re); temp1Re = scalar * Math.cos(im); temp1Im = scalar * Math.sin(im); scalar = Math.exp(-re); temp2Re = scalar * Math.cos(-im); temp2Im = scalar * Math.sin(-im); temp1Re += temp2Re; temp1Im += temp2Im; cosRes = new Complex(0.5 * temp1Re, 0.5 * temp1Im); return sinRes.div(cosRes); }
/** Returns the tangent of this complex number. */ public Complex tan() { // tan(z) = sin(z)/cos(z) double izRe, izIm; double temp1Re, temp1Im; double temp2Re, temp2Im; double scalar; Complex sinResult, cosResult; // sin(z) = ( exp(i*z) - exp(-i*z) ) / (2*i) izRe = -im; izIm = re; // first exp scalar = Math.exp(izRe); temp1Re = scalar * Math.cos(izIm); temp1Im = scalar * Math.sin(izIm); // second exp scalar = Math.exp(-izRe); temp2Re = scalar * Math.cos(-izIm); temp2Im = scalar * Math.sin(-izIm); temp1Re -= temp2Re; temp1Im -= temp2Im; sinResult = new Complex(0.5 * temp1Re, 0.5 * temp1Im); // cos(z) = ( exp(i*z) + exp(-i*z) ) / 2 izRe = -im; izIm = re; // first exp scalar = Math.exp(izRe); temp1Re = scalar * Math.cos(izIm); temp1Im = scalar * Math.sin(izIm); // second exp scalar = Math.exp(-izRe); temp2Re = scalar * Math.cos(-izIm); temp2Im = scalar * Math.sin(-izIm); temp1Re += temp2Re; temp1Im += temp2Im; cosResult = new Complex(0.5 * temp1Re, 0.5 * temp1Im); return sinResult.div(cosResult); }
public Complex atanh() { // atanh(z) = 1/2 * log( (1+z)/(1-z) ) double tempRe, tempIm; Complex result = new Complex(1.0 + re, im); tempRe = 1.0 - re; tempIm = -im; result = result.div(new Complex(tempRe, tempIm)); tempRe = Math.log(result.abs()); tempIm = result.arg(); result.re = 0.5 * tempRe; result.im = 0.5 * tempIm; return result; }
public Complex atan() { // atan(z) = -i/2 * log((i-z)/(i+z)) double tempRe, tempIm; Complex result = new Complex(-re, 1.0 - im); tempRe = re; tempIm = 1.0 + im; result = result.div(new Complex(tempRe, tempIm)); tempRe = Math.log(result.abs()); tempIm = result.arg(); result.re = 0.5 * tempIm; result.im = -0.5 * tempRe; return result; }
private void ift(Complex[] F, byte[] img, int width, int height) { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { Complex c = new Complex(); for (int u = 0; u < height; u++) { for (int v = 0; v < width; v++) { Complex tmp = Complex.fromPolar( 1, 2.0 * Math.PI * (u * x / (double) height + v * y / (double) width)); c = c.plus(tmp.mul(F[u * width + v])); } } c = c.div(height * width); c = c.mul(Math.pow(-1, (x + y))); if (c.getReal() < 0) c.setReal(0.0); System.out.println(c.getReal()); img[x * width + y] = (byte) (c.getReal()); } } }
/** * <u>Berechnen des Kotangens-Hyperbolikus der komplexen Zahl</u><br> * * @return Rückgabe eines Objektes vom Typ Complex mit Lösung aus coth(<u>z</u>) */ public static Complex coth(Complex comp) { return Complex.div(comp.cosh(), comp.sinh()); }
/** * <u>Berechnen des Kotangens-Hyperbolikus der komplexen Zahl</u><br> * * @return Rückgabe eines Objektes vom Typ Complex mit Lösung aus coth(<u>z</u>) */ public Complex coth() { return Complex.div(this.cosh(), this.sinh()); }