MCPcopy Create free account
hub / github.com/arguiot/TheoremJS / tanh

Method tanh

__test__/theorem.js:556–580  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

554 return result.length == 1 ? result[0] : result
555 }
556 tanh(n) {
557 if (n.isComplex) {
558 const Ta = n.a.times(2).toNumber()
559 const Tb = n.b.times(2).toNumber()
560
561 const sin = Math.sin(Tb)
562 const cos = Math.cos(Tb)
563 const cosh = Math.cosh(Ta)
564 const sinh = Math.sinh(Ta)
565
566 const re = sinh / (cos + cosh)
567 const im = sin / (cos + cosh)
568
569 return this.complex(re, im)
570 }
571 if (typeof n != 'object' || BigNumber.isBigNumber(n)) {
572 n = BigNumber.isBigNumber(n) == true ? n.toNumber() : n
573 n = [n]
574 }
575 let result = []
576 for (var i = 0; i < n.length; i++) {
577 result.push(Math.tanh(n[i]).toFixed(15))
578 }
579 return result.length == 1 ? result[0] : result
580 }
581 derivate(poly) {
582 if (poly.type != 'polynomial') {
583 throw "TheoremJS: Derivative: Not a polynomial"

Callers 2

tanh.jsFile · 0.80
test.jsFile · 0.80

Calls 6

complexMethod · 0.95
timesMethod · 0.80
sinMethod · 0.80
cosMethod · 0.80
coshMethod · 0.80
sinhMethod · 0.80

Tested by

no test coverage detected