MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / tan

Method tan

src/org/opensourcephysics/numerics/Complex.java:560–596  ·  view source on GitHub ↗

Returns the tangent of this complex number.

()

Source from the content-addressed store, hash-verified

558 * Returns the tangent of this complex number.
559 */
560 public Complex tan() {
561 // tan(z) = sin(z)/cos(z)
562 double izRe, izIm;
563 double temp1Re, temp1Im;
564 double temp2Re, temp2Im;
565 double scalar;
566 Complex sinResult, cosResult;
567 // sin(z) = ( exp(i*z) - exp(-i*z) ) / (2*i)
568 izRe = -im;
569 izIm = re;
570 // first exp
571 scalar = Math.exp(izRe);
572 temp1Re = scalar*Math.cos(izIm);
573 temp1Im = scalar*Math.sin(izIm);
574 // second exp
575 scalar = Math.exp(-izRe);
576 temp2Re = scalar*Math.cos(-izIm);
577 temp2Im = scalar*Math.sin(-izIm);
578 temp1Re -= temp2Re;
579 temp1Im -= temp2Im;
580 sinResult = new Complex(0.5*temp1Re, 0.5*temp1Im);
581 // cos(z) = ( exp(i*z) + exp(-i*z) ) / 2
582 izRe = -im;
583 izIm = re;
584 // first exp
585 scalar = Math.exp(izRe);
586 temp1Re = scalar*Math.cos(izIm);
587 temp1Im = scalar*Math.sin(izIm);
588 // second exp
589 scalar = Math.exp(-izRe);
590 temp2Re = scalar*Math.cos(-izIm);
591 temp2Im = scalar*Math.sin(-izIm);
592 temp1Re += temp2Re;
593 temp1Im += temp2Im;
594 cosResult = new Complex(0.5*temp1Re, 0.5*temp1Im);
595 return sinResult.div(cosResult);
596 }
597
598 //------------------------------------------------------------------------
599 // Inverse trigonometric functions

Callers 7

getSearchPointsMethod · 0.80
getAngleAtRadiusMethod · 0.80
getDerivativeAtRadiusMethod · 0.80
refreshScaleMethod · 0.80
getStretchFactorMethod · 0.80
builtInFunctionMethod · 0.80
builtInFunctionMethod · 0.80

Calls 4

divMethod · 0.95
expMethod · 0.80
cosMethod · 0.45
sinMethod · 0.45

Tested by

no test coverage detected