# JMathLabTutorial:4 Variables

# Variables

## Standard Variables

Variables are declared by supplying a name and value in the format name=value. The name can be any character sequence. With the exception of the first character it may also contain numbers. The value is any number or expression.

You can extract real and imaginary parts as:

## Stored variables

Some variables are predefined (like pi).

The last previous result of a calculation is stored in the variable ans. All variables are displayed by the command **who**. Single variables can be deleted by entering clear variable.

Now let us clear the variable from the memory:

Here is an example of calculation of the skin surface of your body from height $h$ and weight W using DuBois' formula:

## Example

One calculate some elements of the recursively defined sequence

[math] x_0=1, x_{n+1} = \frac{1}{2} (x_n + 3/x_n) [/math]

When does this sequence approach its limit [math]\sqrt{3}[/math] to within 2*eps?

## Symbolic variables

With few exceptions most operations accept any mixture of numeric and symbolic arguments using the same commands and command syntax.

Symbolic variables should not be confused with variables as discussed until now. These latter variables serve as address for an object in memory (the "environment"), while symbolic variables are algebraic objects on their own. That means if x is a conventional variable, entering x in the text input field makes the program to search in the environment for the corresponding object, which then replaces x. If however x is a symbolic variable, the same action will lead to the creation of a first-degree polynomial with variable x and coefficients 1 and 0.

Each symbolic variable x must be declared as symbolic by entering "syms x" before using it. The command clear x deletes the symbolic (actually any) variable x.

This creates a function with a symbolic value "x"

You can output any symbolic variable as well:

The answer is "x+2". Here are a few more examples: