How to use the pow function from mathjs
Find comprehensive JavaScript mathjs.pow code examples handpicked from public code repositorys.
GitHub: hollaex/hollaex-kit
28 29 30 31 32 33 34 35 36 37
if (number === 0 || number === Infinity || isNaN(number)) { return 0; } else if (decimals > 0) { const multipliedNumber = math.multiply( math.fraction(number), math.pow(10, decimals) ); const dividedNumber = math.divide( math.floor(multipliedNumber), math.pow(10, decimals)
211
236
0
+ 3 other calls in file
13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644
return circ.circuitMatrix(); }; QuantumCircuit.prototype.eulerAnglesZYZ = function(inputMatrix) { var eulerAngles = {theta: null, phi: null, lambda: null, phase: null}; var coeff = math.pow(math.det(inputMatrix), -0.5); eulerAngles.phase = -1 * math.complex(coeff).toPolar().phi; var su_mat = math.multiply(coeff, inputMatrix); eulerAngles.theta = 2 * math.atan2(math.abs(su_mat[1][0]), math.abs(su_mat[0][0])); var phiplambda = 2 * math.complex(su_mat[1][1]).toPolar().phi;
43
207
14
+ 2369 other calls in file
10 11 12 13 14 15 16 17 18 19
const creciprocal = z => math.divide(1, z); const csin = math.sin; const cexp = math.exp; const clog = math.log; const csqrt = math.sqrt; const cpow = math.pow; const csquare = z => cmul(z, z); const ccis = z => cexp(cmul_i(z)); const gamma_right = math.gamma;
8
29
3
+ 3 other calls in file
37 38 39 40 41 42 43 44 45 46
exports.inflate = function inflate(A, factor) { return this.normalizeColumns(math.dotPow(A, factor)); }; exports.expand = function expand(A, factor) { return math.pow(A, factor); }; exports.addDiagonal = function addDiagonal(A, value) { const diag = math.eye(A.size());
2
6
2
79 80 81 82 83 84 85 86 87 88
```js let math = require('mathjs'); let base = 2, exp = 3, n = math.pow(base,exp); // 8 console.log( math.log(n,base) ); // 3 console.log( math.log(n,base) === exp ) // true ```
0
5
1
GitHub: jly36963/notes
40 41 42 43 44 45 46 47 48 49
math.exp(8) // exponent (e ** x) math.log(a) // ln math.log(a, 2) // log base 2 math.mod(a, b) // modulus (remainder) math.multiply(a, b) // multiply math.pow(a, b) // a ** b math.sqrt(a) // square root math.subtract(a, b) // subtract // abs
0
3
1
+ 2 other calls in file
GitHub: matanbroner/Bingo
132 133 134 135 136 137 138 139 140 141 142
} return commitments; } function shareVerfication(i, g, coefficients, P) { let verification = math.pow(g, coefficients[0]); for (let j = 1; j < coefficients.length; j++) { verification = (verification * Math.pow(Math.pow(share, coefficients[j])), Math.pow(i, j));
0
1
0
41 42 43 44 45 46 47 48 49 50
* @param {Boolean|Complex} [inclusive=true] - Wheter or not the endpoint exponent should be included. * @return {Array<(Number|Complex)>} The array of equidistant points in logspace. */ logspace: function(start, end, num, inclusive, base) { base = base || 10; return this.linspace(start, end, num, inclusive).map(function(exponent) { return math.pow(base, exponent); }); }, /** * Evaluates a list of (Complex) numbers in s as if the list containes zeros/poles.
1
0
15
GitHub: kukawski/mathjs
71 72 73 74 75 76 77 78 79
```js var math = require('mathjs'); // use methods and types available in the math object var a = math.sin(math.pi / 4); // 0.7071067811865476 var b = math.pow(a, 2); // 0.5 var c = math.complex(3, -4); // 3 - 4i math.sqrt(c); // 2 - i
0
0
0
+ 15 other calls in file
81 82 83 84 85 86 87 88 89 90
* @return {[type]} [description] */ function gamma_correction(value) { let result = value; if (value > 0.04045) { result = math.pow(((value + 0.055) / (1.0 + 0.055)), 2.4); } else { result = value / 12.92; } return result;
0
0
9
GitHub: gravaman/fleish
81 82 83 84 85 86 87 88 89 90
let [ dividend, divisor ] = biggify(args) return math.divide(dividend, divisor) }, pow(...args) { let [ base, exp ] = biggify(args) return math.pow(base, exp) }, neg(num) { num = math.bignumber(num) return math.unaryMinus(num)
0
0
1
176 177 178 179 180 181 182 183 184 185
// calculate error errorVector = math.squeeze(outputError); var error = 0.0; if (typeof errorVector === 'number') error = 0.5 * math.pow(errorVector, 2); else error = 0.5 * math.dot(errorVector, errorVector); return error;
0
0
0
27 28 29 30 31 32 33 34 35 36 37
/** * derivative of sigmoid function * @param {number} y value */ var dsigmoid = (y) => (sigmoid(y) * (1 - sigmoid(y)));//(1.0 - math.pow(y, 2)); // var dsigmoid = (y) => (1.0 - math.pow(y, 2)); /** * Neural Network class * @param {number} inputNum node count of input layer
0
0
0
+ 2 other calls in file
26 27 28 29 30 31 32 33 34 35 36
// var sigmoid = (x) => math.tanh(x); /** * derivative of sigmoid function * @param {number} y value */ var dsigmoid = (y) => ((y > 0.0)? 1 : 0.01);//(1.0 - math.pow(y, 2)); // var dsigmoid = (y) => (1.0 - math.pow(y, 2)); /** * Neural Network class
0
0
0
+ 2 other calls in file
GitHub: geofree-tze/HomophilyHub
2745 2746 2747 2748 2749 2750 2751 2752 2753 2754
lat2 = lat2 * mathjs.pi / 180; // Haversine formula let dlon = lon2 - lon1; let dlat = lat2 - lat1; let a = mathjs.pow(mathjs.sin(dlat / 2), 2) + mathjs.cos(lat1) * mathjs.cos(lat2) * mathjs.pow(mathjs.sin(dlon / 2), 2); let c = 2 * mathjs.asin(mathjs.sqrt(a));
0
0
0
+ 5 other calls in file
GitHub: vfp2/mindfind-backend
151 152 153 154 155 156 157 158 159 160
} // Generate the index let index = 0; for (let k = 0, l = 9; k < numStages; k++, l--) { index += math.pow(nl, l) * math.floor(nl * ps[k]); } // Interpolate // interpolated index = Floor[3.464 x 10^9 * index/(nl^10)
0
0
0
+ 3 other calls in file
mathjs.evaluate is the most popular function in mathjs (87200 examples)