# Scientific Calculator

(modified 2011-11-17 -- Fixed bug in FishF for certain combinations of df1 and df2)

This is a simple but fairly general numeric expression evaluator, with a large number of built-in functions, including statistical distribution functions. It requires a Web browser that supports JavaScript.

Type an expression here, then press the Tab key [NOT the Return or Enter key!]
If that doesn't do anything, click the "Compute" button.
Expression:

Result:

Operators: + - * / and parentheses
Constants: Pi (=3.14...), e (=2.718...), Deg(=180/Pi = 57.2...)
Built-in Functions...
[Unless otherwise indicated, all functions take a single numeric argument, enclosed in parentheses after the name of the function.]
Algebraic: Abs, Sqrt, Power(x,y) for x raised to power of y, Fact for factorial, Gamma for Fact(n-1)
Transcendental: Exp, Ln for natural logarithm, Log10, Log2
Trigonometric: Sin, Cos, Tan, Cot, Sec, Csc
Inverse Trig: ASin, ACos, ATan, ACot, ASec, ACsc
Hyperbolic: SinH, CosH, TanH, CotH, SecH, CscH
Inverse Hyp: ASinH, ACosH, ATanH, ACotH, ASecH, ACscH
Statistical: Norm, Gauss, Erf, ChiSq(x,df), StudT(t,df), FishF(F,df1,df2)
Inverse Stat: ANorm, AGauss, AErf, AChiSq(p,df), AStudT(p,df), AFishF(p,df1,df2)

Note: JavaScript cannot recognize the ^ operator commonly used to indicate "raising to a power".
Instead, you must use the Power function to do this. So, instead of a^b, you must use Power(a,b).
For example, if you want the square of five, do not use 5^2; use Power(5,2), which returns 25.

Note: This calculator is not case-sensitive.  For example, for square roots you can use Sqrt, sqrt, SQRT, SqRt, sQRt, etc.

Note: The trig functions work in radians. For degrees, multiply or divide by the Deg variable (which is equal to 57.2957..., the number of degrees in one radian). For example: Sin(30/Deg) will return 0.5, and ATan(1)*Deg will return 45.

Note: The factorial and gamma functions are implemented for all real numbers. For non-integers its accuracy is about 10 significant figures. For negative integers it returns either a very large number or a division-by-zero error. See the Handbook of Mathematical Functions for a description of the very unusual behavior of the factorials of negative numbers.

Note: The statistical functions Norm and StudT return 2-tail p-values (e.g.: Norm(1.96) returns 0.05), while ChiSq and FishF return 1-tail values. This is consistent with the way these functions are most frequently used in statistical testing. Mathematical purists would probably prefer a "left integral" (representing the area under the curve between minus infinity and z). If you want the left integral of the normal (Gaussian) probability function, use Gauss(z) (e.g.: Gauss(1.96) returns 0.975). I've also provided Erf (the classic "error function"; if you don't know what Erf is, then you don't need it). I've also provided the inverses: AGauss and AErf.

Note: Some of the functions listed above are not currently implemented in JavaScript, so I have programmed them as user-defined functions. You can see the algorithms by 'viewing the document source' for this page. They are not copyrighted, so feel free to copy them if you find them useful. Several of the routines use recursive subroutine calls, where a subroutine calls itself (like Fact), or two subroutines call each other (like Norm and ChiSq). So be careful when translating them into other languages.

Disclaimer: I believe this calculator to be reasonably accurate and reliable, but I make no guarantees and assume no responsibility for any computational inaccuracies or their consequences.