User:Wogga62/Sandbox

From Wikipedia, the free encyclopedia

The Math object is always available. (Note that it is an object, not a constructor like Array or Date.) It has a number of Properties which return useful constants and also a number of Methods which provide access to mathematical functions such as Cosine and Square Root. All the trigonometric functions use angles expressed in radians; not degrees or grads. (One Radian is about 57.296°.)

More information Property, Value Returned rounded to 5 digits ...
PROPERTIES of the Math object
PropertyValue Returned
rounded to 5 digits
Description
Math.E2.7183Euler's constant, also known as e
Math.LN20.69315Natural logarithm of 2
Math.LN102.3026Natural logarithm of 10
Math.LOG2E1.4427Logarithm to the base 2 of e
Math.LOG10E0.43429Logarithm to the base 10 of e
Math.PI3.1416π : circumference/diameter of a circle
Math.SQRT1_20.70711Square root of a half
Math.SQRT21.4142Square root of 2
Close
More information Example, Value Returned rounded to 5 digits ...
METHODS of the Math object
ExampleValue Returned
rounded to 5 digits
Description
Math.abs(-2.3)2.3Absolute value : (x < 0) ? -x : x
Math.acos(Math.SQRT1_2)0.78540 rad. = 45°Arc Cosine
Math.asin(Math.SQRT1_2)0.78540 rad. = 45°Arc Sine
Math.atan(1)0.78540 rad. = 45°Half Circle Arc Tangent. -Pi/2 to +Pi/2
Math.atan2(-3.7, -3.7)-2.3562 rad. = -135°Whole Circle Arc Tangent. -Pi to +Pi
Math.ceil(1.1)2Ceiling : next integer >= argument
Math.cos(Math.PI/4)0.70711Cosine trigonometric function : rad. input
Math.exp(1)2.7183Exponential Function : e raised to this power
Math.floor(1.9)1Floor : next integer <= argument
Math.log(Math.E)1Natural Logarithm, base e
Math.max(1, -2)1Maximum : (x > y) ? x : y
Math.min(1, -2)-2Minimum : (x < y) ? x : y
Math.pow(-3, 2)9To the power of : Math.pow(x, y) gives xy
Math.random()0.17068Random number from 0 to 1
Math.round(1.5)2Round to the nearest counting number
Math.sin(Math.PI/4)0.70711Sine trigonometric function : rad. input
Math.sqrt(49)7Square Root
Math.tan(Math.PI/4)1Tangent trigonometric function : rad. input
Close

There are one or two other Methods available in some recent software. See http://www.w3schools.com/jsref/jsref_obj_math.asp

Example of uses of the Math object

where = ( a*Math.sin(ang) + b*Math.cos(ang) > Math.sqrt(r2) ) ? "outside" : "inside"

Related Articles

Wikiwand AI