/**
* to demonstrate the Math object, which provides static members and functions.
*/
//Eulers constants
console.log("Eulers constant ::" + Math.E);
//LN2 - natural log of 2
console.log("LN2 ::"+Math.LN2);
//LN10 - natural log of 10
console.log("LN10 ::"+Math.LN10);
//LOG2E
console.log("LOG2E ::"+Math.LOG2E);
//LOG10E
console.log("LOG10E ::"+Math.LOG10E);
//PI
console.log("PI ::"+Math.PI);
//SQRT1_2 - square root of 1/2
console.log("SQRT1_2 ::"+Math.SQRT1_2);
//SQRT2
console.log("SQRT2 ::"+Math.SQRT2);
//Math.pow(X,Y) - value of X raised to Y
console.log("2 raised to 4 ::" + Math.pow(2,4));
//Math.sqrt(X) - square root of X
console.log("square root of 16 ::" + Math.sqrt(16));
//Math.cbrt(X) - cube root of X
console.log("cube root of 125 ::" + Math.cbrt(125));
//Math.exp(X) - Math.E raised to X
console.log("Eulers constant raised to 4 ::"+ Math.exp(4));
//Math.log(X) - natural algorithm of X
console.log("log of 20 ::"+Math.log(20));
//Math.log10(X) - Base 10 log of X
console.log("Log10 of 10 ::"+Math.log10(10));
//Math.log2(X) - Base 2 log of X
console.log("Log2 of 2 ::"+Math.log2(2));
//Math.abs(X) - absolute value of X
console.log("absolute value of -12.22 ::"+Math.abs(-12.22));
//Math.Sign(X) - returns sign of X
console.log("Sign of -12.22" + Math.sign(-12.22));
//Math.ceil(X) - ceil value of X
console.log("ceil value of 12.22 ::"+ Math.ceil(12.22));
console.log("ceil value of -12.22 ::"+ Math.ceil(-12.22));
//Math.floor(X) - floor value of X
console.log("floor value of 12.22 ::"+Math.floor(12.22));
console.log("floor value of -12.22 ::"+Math.floor(-12.22));
//Math.trunc(X) - integer part of X
console.log("integer part of 12.22 ::"+Math.trunc(12.22));
//Math.round(X) - round to nearest integer
console.log("round of 12.22 :: " + Math.round(12.22));
console.log("round of -12.22 :: " + Math.round(-12.22));
console.log("round of 12.92 ::" + Math.round(12.92));
//Math.min(X1,X2,...Xn) - return minimal value
console.log("Minimum of -2, 4, -8,5 ::"+Math.min(-2,4,-8,5));
//Math.max(X1,X2,...Xn) - return maximal value
console.log("Maximum of -2, 4, -8,5 ::"+Math.max(-2,4,-8,5));
//Math.random()
console.log("random value ::"+Math.random());
//Math.sin(X)
console.log("sin of PI ::" + Math.sin(Math.PI));
//Math.cos(X)
console.log("cos of PI ::" + Math.cos(Math.PI));
//Math.tan(X)
console.log("tan of PI ::" + Math.tan(Math.PI));
//Math.asin(X)
console.log("asin of PI/2 ::" + Math.asin(Math.PI/2));
//Math.acos(X)
console.log("acos of PI/2 ::" + Math.acos(Math.PI/2));
//Math.atan(X)
console.log("atan of PI/2 ::" + Math.atan(Math.PI/2));
//Math.atan2(X,Y) - returns value between -PI to PI representing angle theta of point X,Y
console.log("atan2 of (0,1) ::" + Math.atan2(0,1));
Output
Eulers constant ::2.718281828459045 LN2 ::0.6931471805599453 LN10 ::2.302585092994046 LOG2E ::1.4426950408889634 LOG10E ::0.4342944819032518 PI ::3.141592653589793 SQRT1_2 ::0.7071067811865476 SQRT2 ::1.4142135623730951 2 raised to 4 ::16 square root of 16 ::4 cube root of 125 ::5 Eulers constant raised to 4 ::54.598150033144236 log of 20 ::2.995732273553991 Log10 of 10 ::1 Log2 of 2 ::1 absolute value of -12.22 ::12.22 Sign of -12.22-1 ceil value of 12.22 ::13 ceil value of -12.22 ::-12 floor value of 12.22 ::12 floor value of -12.22 ::-13 integer part of 12.22 ::12 round of 12.22 :: 12 round of -12.22 :: -12 round of 12.92 ::13 Minimum of -2, 4, -8,5 ::-8 Maximum of -2, 4, -8,5 ::5 random value ::0.11633567101339315 sin of PI ::1.2246467991473532e-16 cos of PI ::-1 tan of PI ::-1.2246467991473532e-16 asin of PI/2 ::NaN acos of PI/2 ::NaN atan of PI/2 ::1.0038848218538872 atan2 of (0,1) ::0