Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  The Teacher's Book /  Basic Calculations /  Solving Equations /

7.1 Equations

Section 3.1 discussed assignments such as x = y that set x equal to y. This section discusses equations, which test equality. The equation x == y tests whether x is equal to y.

This tests whether 2 + 2 and 4 are equal. The result is the symbol True.

In[1]:= 2 + 2 == 4

Out[1]=

It is very important that you do not confuse x = y with x == y. While x = y is an imperative statement that actually causes an assignment to be done, x == y merely tests whether x and y are equal, and causes no explicit action.

Assignments and tests.

This assigns x to have value 4.

In[2]:= x = 4

Out[2]=

If you ask for x, you now get 4.

In[3]:= x

Out[3]=

This tests whether x is equal to 4. In this case, it is.

In[4]:= x == 4

Out[4]=

x is equal to 4, not 6.

In[5]:= x == 6

Out[5]=

This removes the value assigned to x.

In[6]:= x =.

The tests used so far involve only numbers, and always give a definite answer, either True or False. You can also do tests on symbolic expressions.

Mathematica TE cannot get a definite result for this test unless you give x a specific numerical value.

In[7]:= x == 5

Out[7]=

If you replace x by the specific numerical value 4, the test gives False.

In[8]:= % /. x -> 4

Out[8]=

Even when you do tests on symbolic expressions, there are some cases where you can get definite results. An important one is when you test the equality of two expressions that are identical. Whatever the numerical values of the variables in these expressions may be, Mathematica TE knows that the expressions must always be equal.

The two expressions are identical, so the result is True, whatever the value of x may be.

In[9]:= 2 x + x^2 == 2 x + x^2

Out[9]=

Mathematica TE does not try to tell whether these expressions are equal. In this case, using Expand would make them have the same form.

In[10]:= 2 x + x^2 == x (2 + x)

Out[10]=

Expressions like x == 4 represent equations in Mathematica TE. There are many functions in Mathematica TE for manipulating and solving equations.

This is an equation in Mathematica TE.

In[11]:= x^2 + 2 x - 7 == 0

Out[11]=

You can assign a name to the equation.

In[12]:= eqn = %

Out[12]=

If you ask for eqn, you now get the equation.

In[13]:= eqn

Out[13]=