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

Method cos

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

Returns the cosine of this complex number.

()

Source from the content-addressed store, hash-verified

534
535 */
536 public Complex cos() {
537 double izRe, izIm;
538 double temp1Re, temp1Im;
539 double temp2Re, temp2Im;
540 double scalar;
541 // cos(z) = ( exp(i*z) + exp(-i*z) ) / 2
542 izRe = -im;
543 izIm = re;
544 // first exp
545 scalar = Math.exp(izRe);
546 temp1Re = scalar*Math.cos(izIm);
547 temp1Im = scalar*Math.sin(izIm);
548 // second exp
549 scalar = Math.exp(-izRe);
550 temp2Re = scalar*Math.cos(-izIm);
551 temp2Im = scalar*Math.sin(-izIm);
552 temp1Re += temp2Re;
553 temp1Im += temp2Im;
554 return new Complex(0.5*temp1Re, 0.5*temp1Im);
555 }
556
557 /**
558 * Returns the tangent of this complex number.

Callers 15

builtInFunctionMethod · 0.45
cartesianMethod · 0.45
powerMethod · 0.45
powMethod · 0.45
expMethod · 0.45
sinMethod · 0.45
tanMethod · 0.45
sinhMethod · 0.45
coshMethod · 0.45
tanhMethod · 0.45
rotationXMethod · 0.45
rotationYMethod · 0.45

Calls 2

expMethod · 0.80
sinMethod · 0.45

Tested by

no test coverage detected