JavaScript Math Evaluator


Modified from a free JavaScript provided
by The JavaScript Source


JavaScript Math functions:
absAbsolute value
sin, cos, tanStandard trigonometric functions; argument in radians
acos, asin, atan, atan2  Inverse trigonometric functions; return values in radians
exp, logExponential and natural logarithm, base e
ceilReturns least integer greater than or equal to argument
floorReturns greatest integer less than or equal to argument
min, maxReturns greater or lesser (respectively) of two arguments 
powExponential; first argument is base, second is exponent
randomReturns a random number between 0 and 1.
roundRounds argument to nearest integer
sqrtSquare root
 

JavaScript Seismology Functions:

distEnter S minus P time, press "Go" for distance in degrees
SPEnter distance in degrees; press "Go" for S minus P in seconds


JavaScript Math constants:
EEuler's constant and the base of natural logarithms, approximately 2.718.
LN2Natural logarithm of 2, approximately 0.693
LN10Natural logarithm of 10, approximately 2.302.
LOG2EBase 2 logarithm of E (approximately 1.442).
LOG10EBase 10 logarithm of E (approximately 0.434).
PIRatio of the circumference of a circle to its diameter, approximately 3.14159 
SQRT1_2  Square root of 1/2; approximately 0.707.
SQRT2Square root of 2, approximately 1.414.

This is a calculator that you can program by pasting in JavaScript language formulas in the top text space. You can use the keyboard to paste in simple formulas; or you can compose a multi-line function in Javascript, save it in a text file, an paste it in. The calculator uses the "eval" function to solve the equations. Use semicolons to separate the lines of a multiline function. After entering the function and clicking on "Go", a number will appear on the third text space. The values for all variables can be displayed by entering the variable name on the top line, and clicking on "Go".

The second text space serves only as a scratch storage space for whatever text you might want to enter by the usual text editing methods, or by clicking on "sav" or "txt".

The text of this file contains the line "var x,y,z,a,b,c,i,j". To set up other names of variables or arrays, just modify this line, using NotePad and save.

For further reading:

http://javascript.internet.com/tutorials/

http://javascript.internet.com/tutorials/CoreGuideJS15.zip

http://javascript.internet.com/tutorials/CoreReferenceJS15.zip

http://www.webreference.com/

http://www.webreference.com/programming/javascript/diaries/1/