AI math handbook calculator - Fractional Calculus Computer Algebra System software Home | list | math | function | coding | graphics | example | help | 中文
+ + + =

JavaScript Math

JavaScript Arithmetic Operators

JavaScript Arithmetic operators are used to perform arithmetic between variables and/or values.
OperatorDescription
=assignment
** Power operator, instead of ^.
%Modulus (division remainder)

Math Constants

Property Description
e Returns Euler's number (approx. 2.718)
pi Returns PI (approx. 3.14)
degree Returns PI/180 (approx. 0.017453292519943295)
eulerGamma Returns euler Gamma (approx. 0.5772156649015329)

JavaScript Math libery

It is real math. Function in JavaScript Math libery should used as Math.function as Math is object here.

Math Object Properties (Math.Constants)

Property Description
Math.E Returns Euler's number (approx. 2.718)
Math.LN2 Returns the natural logarithm of 2 (approx. 0.693)
Math.LN10 Returns the natural logarithm of 10 (approx. 2.302)
Math.LOG2E Returns the base-2 logarithm of E (approx. 1.442)
Math.LOG10E Returns the base-10 logarithm of E (approx. 0.434)
Math.PI Returns PI (approx. 3.14)
Math.SQRT1_2 Returns the square root of 1/2 (approx. 0.707)
Math.SQRT2 Returns the square root of 2 (approx. 1.414)

Math Object Methods (Math.Functions)

Method Description
abs(x) Returns the absolute value of x
acos(x) Returns the arccosine of x, in radians
acosh(x) Returns the hyperbolic arccosine of x
asin(x) Returns the arcsine of x, in radians
asinh(x) Returns the hyperbolic arcsine of x
atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x) Returns the arctangent of the quotient of its arguments
atanh(x) Returns the hyperbolic arctangent of x
cbrt(x) Returns the cubic root of x
ceil(x) Returns x, rounded upwards to the nearest integer
Math.clz32(x) Returns the number of leading zeros in a 32-bit binary representation of x
cos(x) Returns the cosine of x (x is in radians)
cosh(x) Returns the hyperbolic cosine of x
exp(x) Returns the value of Ex
expm1(x) Returns the value of Ex minus 1
floor(x) Returns x, rounded downwards to the nearest integer
Math.fround(x) Returns the nearest (32-bit single precision) float representation of a number
log(x) Returns the natural logarithmof x
log10(x) Returns the base-10 logarithm of x
log1p(x) Returns the natural logarithm of 1 + x
log2(x) Returns the base-2 logarithm of x
max(x, y, z, ..., n) Returns the number with the highest value
min(x, y, z, ..., n) Returns the number with the lowest value
pow(x, y) Returns the value of x to the power of y
random() Returns a random number between 0 and 1
round(x) Rounds x to the nearest integer
sign(x) Returns the sign of a number (checks whether it is positive, negative or zero)
sin(x) Returns the sine of x (x is in radians)
sinh(x) Returns the hyperbolic sine of x
sqrt(x) Returns the square root of x
tan(x) Returns the tangent of an angle
tanh(x) Returns the hyperbolic tangent of a number
trunc(x) Returns the integer part of a number (x)

Array Object

The Array object is used to store multiple values in a single variable. Array indexes are zero-based: The first element in the array is 0, the second is 1, and so on.

JavaScript Array Methods

x.method() Description
concat() Joins two or more arrays, and returns a copy of the joined arrays
copyWithin() Copies array elements within the array, to and from specified positions
entries() Returns a key/value pair Array Iteration Object
every() Checks if every element in an array pass a test
fill() Fill the elements in an array with a static value
filter() Creates a new array with every element in an array that pass a test
find() Returns the value of the first element in an array that pass a test
findIndex() Returns the index of the first element in an array that pass a test
forEach() Calls a function for each array element
from() Creates an array from an object
includes() Check if an array contains the specified element
indexOf() Search the array for an element and returns its position
isArray() Checks whether an object is an array
join() Joins all elements of an array into a string
keys() Returns a Array Iteration Object, containing the keys of the original array
lastIndexOf() Search the array for an element, starting at the end, and returns its position
map() Creates a new array with the result of calling a function for each array element
pop() Removes the last element of an array, and returns that element
push() Adds new elements to the end of an array, and returns the new length
reduce() Reduce the values of an array to a single value (going left-to-right)
reduceRight() Reduce the values of an array to a single value (going right-to-left)
reverse() Reverses the order of the elements in an array
shift() Removes the first element of an array, and returns that element
slice() Selects a part of an array, and returns the new array
some() Checks if any of the elements in an array pass a test
sort() Sorts the elements of an array
splice() Adds/Removes elements from an array
toString() Converts an array to a string, and returns the result
unshift() Adds new elements to the beginning of an array, and returns the new length
valueOf() Returns the primitive value of an array

JavaScript Array Properties

Property Description
constructor Returns the function that created the Array object's prototype
length Sets or returns the number of elements in an array
prototype Allows you to add properties and methods to an Array object

JavaScript mathjs libery

It is real and complex math. Function in JavaScript mathjs libery should used as math.function as math is object here.

List, vector, matrix and array

They are as same as array in JavaScript.

Category Functions
constantsE, Infinity, LN10, LN2, LOG10E, LOG2E, NaN, PI, SQRT1_2, SQRT2, e, false, i, null, phi, pi, tau, true
operator +, -, *, /, ^, .*, ./, .^, %, mod
operator add(x,y), divide(x,y), dotDivide(x,y), dotMultiply(x,y), dotPow(x,y), mod(x,y), multiply(x,y), pow(x,y), subtract(x,y), unaryMinus(x), unaryPlus(x)
Algebra derivative, lsolve, lsolveAll, lup, lusolve, qr, rationalize, simplify, slu, usolve, usolveAll
Arithmetic abs(x), cbrt(x), ceil(x), cube(x), exp(x), expm(x), expm1(x), fix(x), floor(x), gcd(x), hypot(x), lcm(x), log(x), log10(x), log1p(x), log2(x), norm(x), nthRoot(x), nthRoots(x), round(x), sign(x), sqrt(x), sqrtm(x), square(x), xgcd(x)
Bitwise bitAnd, bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
Combinatorics bellNumbers, catalan, composition, stirlingS2
complexarg(x), conj(x), im(x), re(x)
matrix column(x), concat(x), cross(x), ctranspose(x), det(x), diag(x), diff(x), dot(x), eigs(x), filter(x), flatten(x), forEach(x), getMatrixDataType(x), identity(x), inv(x), kron(x), map(x), ones(x), partitionSelect(x), reshape(x), resize(x), rotationMatrix(x), row(x), size(x), sort(x), squeeze(x), subset(x), trace(x), transpose(x), zeros(x)
Bitwise bitAnd, bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
Construction bignumber, boolean, complex, createUnit, fraction, index, matrix, number, sparse, splitUnit, string, unit
Bitwise bitAnd, bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
Expression evaluate, help
Geometry distance, intersect
Logical and, not, or, xor
Probability combinations(x), combinationsWithRep(x), factorial(x), gamma(x), kldivergence(x), multinomial(x), permutations(x), pickRandom(x), random(x), randomInt(x)
Relational compare, compareNatural, compareText, deepEqual, equal, equalText, larger, largerEq, smaller, smallerEq, unequal
Set setCartesian(x), setDifference(x), setDistinct(x), setIntersect(x), setIsSubset(x), setMultiplicity(x), setPowerset(x), setSize(x), setSymDifference(x), setUnion(x)
Statistics mad(x), max(x), mean(x), median(x), min(x), mode(x), prod(x), quantileSeq(x), std(x), sum(x), variance(x)
special erf(x), gamma(x), lgamma(x), zeta(x)
Trigonometry acos, acosh, acot, acoth, acsc, acsch, asec, asech, asin, asinh, atan, atan2, atanh, cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, tanh
Utils bin, clone, format, hasNumericValue, hex, isInteger, isNaN, isNegative, isNumeric, isPositive, isPrime, isZero, numeric, oct, typeOf, range, to

help(name) shows name of function meaning by the matrix calculator. e.g.
help(sin) shows sin content.

details in mathjs libery.

JavaScript complex math libery

It is real and complex math , but it needs to convert complex operation by tocomplex(x).

Calculation

There are many ways to do:
  1. The button calculates JavaScript numeric.
  2. JavaScript function calculator calculates JavaScript math and plots function, and runs JavaScript code.
  3. Matrix calculator calculates JavaScript matrix, and runs JavaScript code.
  4. JavaScript calculator can run more JavaScript or mathHandbook code.
  5. Webpage editor can run more JavaScript + html + CSS codes.
    example :
    g=[2,1]; sort(g)
Examples are in JavaScript function calculator . More are in calculator and help.

Coding

  • Front-end webpage is coding with HTML + JavaScript.
  • Back-end server is coded with Java.

    Graphcis

    Graphcis are coded with JavaScript.

    References

    1. Java Math
    2. mathjs
    
    See Also

    
    DrHuang.com | list | wiki | about | donate | index | forum | help | chat | translated from Chinese | 中文