Exemple #1
0
  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);
  }
Exemple #2
0
  /** 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);
  }
Exemple #3
0
  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;
  }
Exemple #4
0
  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());
     }
   }
 }
Exemple #6
0
 /**
  * <u>Berechnen des Kotangens-Hyperbolikus der komplexen Zahl</u><br>
  *
  * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus coth(<u>z</u>)
  */
 public static Complex coth(Complex comp) {
   return Complex.div(comp.cosh(), comp.sinh());
 }
Exemple #7
0
 /**
  * <u>Berechnen des Kotangens-Hyperbolikus der komplexen Zahl</u><br>
  *
  * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus coth(<u>z</u>)
  */
 public Complex coth() {
   return Complex.div(this.cosh(), this.sinh());
 }