complex tangent function

Complex::tan($z) computes and returns tan($z)


@param mixed $z (Complex, or parsable to Complex)
@retval Complex
970852
public static function tan($z) {
        if (!($z instanceof Complex)) $z = static::parse($z);

        $d = cos($z->x)*cos($z->x) + sinh($z->y)*sinh($z->y);
        return static::create(sin($z->x)*cos($z->x)/$d, sinh($z->y)*cosh($z->y)/$d);
    }
1150066
public static function arcosh($z) {
        if (!($z instanceof Complex)) $z = static::parse($z);

        return static::log(static::add($z, static::sqrt(static::add(-1, static::mul($z, $z)))));
    }
908277
public static ComplexNumber Sin(ComplexNumber z1) {
        ComplexNumber result = new ComplexNumber();

        if (z1.imaginary == 0.0) {
            result.real = Math.sin(z1.real);
            result.imaginary = 0.0;
        } else {
            result.real = Math.sin(z1.real) * Math.cosh(z1.imaginary);
            result.imaginary = Math.cos(z1.real) * Math.sinh(z1.imaginary);
        }

        return result;
    }
1226088
def _g(self, z):
        
        return np.exp(np.multiply(-self.theta, z)) - 1
589668
function() {

      // acot(c) = i / 2 log((c - i) / (c + i))

      var a = this['re'];
      var b = this['im'];

      if (b === 0) {
        return new Complex(Math.atan2(1, a), 0);
      }

      var d = a * a + b * b;
      return (d !== 0)
              ? new Complex(
                      a / d,
                      -b / d).atan()
              : new Complex(
                      (a !== 0) ? a / 0 : 0,
                      (b !== 0) ? -b / 0 : 0).atan();
    }
1202394
@Pure
	public static double toESRI_z(double z) {
		if (Double.isInfinite(z) || Double.isNaN(z)) {
			return ESRI_NAN;
		}
		return z;
	}
34586
public function reverse()
    {
        return new Complex(
            $this->imaginaryPart,
            $this->realPart,
            ($this->realPart == 0.0) ? null : $this->suffix
        );
    }
1023253
def _JzIntegrand(z,Ez,pot):
    """"""
    return nu.sqrt(2.*(Ez-potentialVertical(z,pot)))
567576
function KeyExpansion($z)
    {
        // Rcon is the round constant
        static $Rcon = [
            0x00000000,
            0x01000000,
            0x02000000,
            0x04000000,
            0x08000000,
            0x10000000,
            0x20000000,
            0x40000000,
            0x80000000,
            0x1b000000,
            0x36000000,
            0x6c000000,
            0xd8000000,
            0xab000000,
            0x4d000000,
            0x9a000000,
            0x2f000000
        ];

        $temp = 0; // temporary 32-bit word

        // the first Nk words of w are the cipher key z
        for ($i = 0; $i < $this->Nk; $i++) {
            $this->w[$i] = 0;
            // fill an entire word of expanded key w
            // by pushing 4 bytes into the w[i] word
            $this->w[$i] = ord($z[4 * $i]); // add a byte in
            $this->w[$i] <<= 8; // make room for the next byte
            $this->w[$i] += ord($z[4 * $i + 1]);
            $this->w[$i] <<= 8;
            $this->w[$i] += ord($z[4 * $i + 2]);
            $this->w[$i] <<= 8;
            $this->w[$i] += ord($z[4 * $i + 3]);
        }

        for (; $i < $this->Nb * ($this->Nr + 1); $i++) {
            $temp = $this->w[$i - 1];

            if ($i % $this->Nk == 0) $temp = $this->subWord($this->rotWord($temp)) ^ $Rcon[$i / $this->Nk]; elseif ($this->Nk > 6 && $i % $this->Nk == 4) $temp = $this->subWord($temp);

            $this->w[$i] = $this->w[$i - $this->Nk] ^ $temp;

            $this->make32BitWord($this->w[$i]);
        }
    }
49484
protected boolean intersectsZ (IRay3 ray, double z) {
        IVector3 origin = ray.origin(), dir = ray.direction();
        double t = (z - origin.z()) / dir.z();
        if (t < 0f) {
            return false;
        }
        double ix = origin.x() + t*dir.x(), iy = origin.y() + t*dir.y();
        return ix >= _minExtent.x && ix <= _maxExtent.x &&
            iy >= _minExtent.y && iy <= _maxExtent.y;
    }
237842
public static function arccos($z) {
        if (!($z instanceof Complex)) $z = static::parse($z);

        $I = new Complex(0,1);
        $temp = static::mul(static::sqrt(static::sub(1, static::mul($z, $z))), $I);
        return static::div(static::log(static::add($z, $temp)), $I);
    }
762615
public static ComplexNumber Divide(ComplexNumber z1, ComplexNumber z2) {

        ComplexNumber conj = ComplexNumber.Conjugate(z2);

        double a = z1.real * conj.real + ((z1.imaginary * conj.imaginary) * -1);
        double b = z1.real * conj.imaginary + (z1.imaginary * conj.real);

        double c = z2.real * conj.real + ((z2.imaginary * conj.imaginary) * -1);

        return new ComplexNumber(a / c, b / c);
    }
403044
function(a, b) {

      var z = new Complex(a, b);

      a = this['re'];
      b = this['im'];

      if (z['isZero']()) {
        return Complex['ONE'];
      }

      // If the exponent is real
      if (z['im'] === 0) {

        if (b === 0 && a >= 0) {

          return new Complex(Math.pow(a, z['re']), 0);

        } else if (a === 0) { // If base is fully imaginary

          switch ((z['re'] % 4 + 4) % 4) {
            case 0:
              return new Complex(Math.pow(b, z['re']), 0);
            case 1:
              return new Complex(0, Math.pow(b, z['re']));
            case 2:
              return new Complex(-Math.pow(b, z['re']), 0);
            case 3:
              return new Complex(0, -Math.pow(b, z['re']));
          }
        }
      }

      /* I couldn't find a good formula, so here is a derivation and optimization
       *
       * z_1^z_2 = (a + bi)^(c + di)
       *         = exp((c + di) * log(a + bi)
       *         = pow(a^2 + b^2, (c + di) / 2) * exp(i(c + di)atan2(b, a))
       * =>...
       * Re = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * cos(d * log(a^2 + b^2) / 2 + c * atan2(b, a))
       * Im = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * sin(d * log(a^2 + b^2) / 2 + c * atan2(b, a))
       *
       * =>...
       * Re = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * cos(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a))
       * Im = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * sin(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a))
       *
       * =>
       * Re = exp(c * logsq2 - d * arg(z_1)) * cos(d * logsq2 + c * arg(z_1))
       * Im = exp(c * logsq2 - d * arg(z_1)) * sin(d * logsq2 + c * arg(z_1))
       *
       */

      if (a === 0 && b === 0 && z['re'] > 0 && z['im'] >= 0) {
        return Complex['ZERO'];
      }

      var arg = Math.atan2(b, a);
      var loh = logHypot(a, b);

      a = Math.exp(z['re'] * loh - z['im'] * arg);
      b = z['im'] * loh + z['re'] * arg;
      return new Complex(
              a * Math.cos(b),
              a * Math.sin(b));
    }
1146765
function(a, b) {

      var z = new Complex(a, b);

      // Infinity + Infinity = NaN
      if (this['isInfinite']() && z['isInfinite']()) {
        return Complex['NAN'];
      }

      // Infinity + z = Infinity { where z != Infinity }
      if (this['isInfinite']() || z['isInfinite']()) {
        return Complex['INFINITY'];
      }

      return new Complex(
              this['re'] + z['re'],
              this['im'] + z['im']);
    }
428644
public static function arctan($z) {
        if (!($z instanceof Complex)) $z = static::parse($z);

        $I = new Complex(0,1);
        $iz = static::mul($z, $I);
        $w = static::div( static::add(1, $iz), static::sub(1, $iz) );
        $logw = static::log($w);
        return static::div($logw, new Complex(0,2));
    }
19883
public static function artanh($z) {
        if (!($z instanceof Complex)) $z = static::parse($z);

        return static::div(static::log(static::div(static::add(1,$z), static::sub(1,$z))),2);
    }
468712
public function jpoint($x, $y, $z, $t = null) {
        return $this->point($x, $y, $z, $t);
    }