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

Method sqrt

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

Source from the content-addressed store, hash-verified

129 return new BigNumber(new BigNumber(1).div(this.pow(this.c("e", n), x).plus(1)).toFixed(n))
130 }
131 sqrt(n) {
132 if (typeof n != 'object' || BigNumber.isBigNumber(n)) {
133 n = [n]
134 }
135 let result = []
136 for (var i = 0; i < n.length; i++) {
137 if (new BigNumber(n[i]).lt(0)) {
138 result.push(this.complex(0, new BigNumber(n[i]).abs().sqrt()))
139 } else {
140 result.push(new BigNumber(new BigNumber(n[i]).sqrt()))
141 }
142 }
143 return result.length == 1 ? result[0] : result
144 }
145 apply(n, f) {
146 if (typeof n != 'object') {
147 n = [n]

Callers 14

goldenRatioMethod · 0.95
findRoots.jsFile · 0.80
abs.jsFile · 0.80
correlation.jsFile · 0.80
goldenRatio.jsFile · 0.80
leastFactor.jsFile · 0.80
gamma.jsFile · 0.80
sqrt.jsFile · 0.80
gammaMethod · 0.80
correlationMethod · 0.80
findRootsMethod · 0.80
leastFactorMethod · 0.80

Calls 2

complexMethod · 0.95
absMethod · 0.45

Tested by

no test coverage detected