# How to Enter Functions

The applets on this web use a function parser which uses a syntax which should be very familiar to anyone who has done any computer programming or used any computer math software.  Probably the best way to learn how to use this interface is to look at some examples...

### Numbers

 If I wanted... I would enter... 10.5 10.5 negative 150 -150 1.344 x 105 1.344E5 0.000001244 0.000001244 or 1.244E-6

Note that the "E" must be upper case.  1.2E3 works, 1.2e3 doesn't.

### Operators and Parenthesis

 If I wanted... I would enter... 10.5 time 2.3 10.5*2.3 2 plus 4 divided by 12.5 2+4/12.5 2 plus 4 all divided by 12.5 (2+4)/12.5 4 squared 4^2

Valid operators are: + (add), - (subtract), * (multiply), / (divide), and ^ (raise to the power)

### Variables

 If I wanted... I would enter... x x 2 time y plus x 2*y+x x raised to the power of y x^y power times t power*t

Each box will be set up to use one or more specific variables.  Text near the box should tell you which variable you should be using in your equations.  For example, if you were told to enter the function f(x, spam), that would mean that the variables you were allowed to use are x and spam.

### Functions and Constants

 If I wanted... I would enter... sine of x sin(x) natural log of 2 ln(2) the absolute value of time abs(time) the square root of the cosine of 4π sqrt(cos(4*pi))

Valid functions and constants are

 sin(), cos() tan(), asin(), acos() atan() trig and inverse trig functions (note that all angles are assumed to be in radians) sinh(), cosh(), tanh() hyperbolic trig functions ln(), exp() natural logarithm and exponentiation log2(), log10() base 2 and base 10 logarithms sqrt() square root abs() absolute value sign() sign(x) returns +1 if x is positive or -1 if it is negative neg() negation (neg(2) = -2, neg(-4) = 4) round(), ceil(), floor() round to nearest integer, round up, and round down random() random(a) returns a random number between 0 and a step() step function (step(x) returns 0 if x < 0 or 1 if x > 0) squarepulse(), trianglepulse() squarepulse(x) and trianglepulse(x) return zero unless x is between -1 and 1.   If x is in this region squarepulse(x) returns 1, and trianglepulse(x) returns a triangle shape which is 0 at x=+/- 1 and grows linearly to 1 as x approaches zero. squarewave(), trianglewave() squarewave(x) and triangelwave(x) are periodic functions of x, repeating themselves each time that x increases by 1.  They both oscillate between -1 and 1.  squarewave(x) returns 1 at x=0.  At x=0.5 it drops to -1.  trianglewave(x) is equal to 1 at x=0.  It ramps linearly down to -1 at x=0.5, and then ramps linearly back up to 1 at x=1. e, pi the natural number e and the constant π