Variables, Expressions, and Functions




Getting Started


Editing Formulas


Variables, Expressions, and Functions


Vectors


Graphs


Programming


Control Key Map


Samples

   


Defining Variables

Built-in Functions

User Defined Functions

Differentiation

Algebra of Functions

Defining Variables

A variable is name to which you can assign a value. The variable name is a text string that must begin with a letter and it is case sensitive, so the strings "Avar" and "avar" could be used to represent different variables.

A variable name can contain digits but it cannot start with a digit. You may also use subscripts on variable names.

To define a variable, type the name followed by <ctrl> x, then the value followed by <ctrl> z.

<ctrl> x produces the string := and is the signal that you are defining something. <ctrl> z causes the applet to evaluate the expression, thus assigning the value to the name.

Example: The key strokes

abc <ctrl> x 7 <ctrl> z

produce the following result.

Note that when the applet evaluates the expression, it prints another equal sign followed by the value associated with the variable. This can be useful if the value assigned to a variable contains another variable. For example, try clicking in an open area in the applet above and typing v <ctrl> x 3*abc <ctrl>z

The result is to assign the value 21 to the variable name v. To see the value of a variable, type the name followed by <ctrl> z.

Example: The three lines below are made by typing

a <ctrl> j <up arrow> 1 <ctrl> x 11 <ctrl> z

Then start a new formula by clicking and typing

a <ctrl> j <up arrow> 2 <ctrl> x 19 <ctrl> z

Do the last calculation by clicking and typing

a <ctrl> j 1<up arrow> + a <ctrl> j 2<ctrl>z

Note: The applet defines the variables e and

The symbol for pi is obtained by typing <ctrl>p.

Built-in Functions

sin sine
cos cosine
tan tangent
asin inverse sine
acos inverse cosine
atan inverse tangent
sinh hyperbolic sine
cosh hyperbolic cosine
tanh hyperbolic tangent
exp exponential
ln natural logarithm (base e)
log common logarithm (base 10)
|*| absolute value
random random number between 0.0 and 1.0

Example

User Defined Functions

You may define functions of any number of variables, and the function may return a real number or a vector.

Example

Example

Differentiation

Evaluating the expression yields the partial derivative with respect to x of the function f. The symbol is made with the key strokes

D <ctrl> j x <up arrow> f

Example

If a function f is defined using local variables named a and b, then differentiating f with respect to x will yield 0. However, the local variables can be renamed, as illustrated below.

Example

The built-in functions such as sin and cos do not have a named local variable. Differentiating a built-in function with respect to a variable has the effect of naming the local variable and then taking the derivative.

Example

Evaluating the expression yields the nth partial derivative of f with respect to x, and the symbol is made with the key strokes

D <ctrl> k n <right arrow> x <up arrow> f

The expression first takes the partial with respect to x, then with respect to y, and that symbol is made by typing

D <ctrl> j x , y <up arrow> <up arrow> f

Example: Three ways to compute the second derivative of sine

Example

Algebra of Functions

Functions may be added, subtracted, multiplied and divided like numbers.

Example

Functions may also be composed, as in the following example. (Composition symbol is obtained by typing <ctrl> c.)

Example

Functions of more than one variable and vector valued functions may also be combined by these operations, provided the dimensions of the dimensions of the domains and codomains are such that the operation is defined.