Equations

"Defining Variables" discussed assignments such as which set x equal to y. Here we discuss equations, which test equality. The equation tests whether x is equal to y.

This tests whether and are equal. The result is the symbol True.
In[1]:=
Click for copyable input
Out[1]=

It is very important that you do not confuse with . While is an imperative statement that actually causes an assignment to be done, merely tests whether x and y are equal, and causes no explicit action. If you have used the C programming language, you will recognize that the notation for assignment and testing in the Wolfram Language is the same as in C.

x=yassigns x to have value y
x==ytests whether x and y are equal

Assignments and tests.

This assigns to have value .
In[2]:=
Click for copyable input
Out[2]=
If you ask for , you now get .
In[3]:=
Click for copyable input
Out[3]=
This tests whether is equal to . In this case, it is.
In[4]:=
Click for copyable input
Out[4]=
is equal to , not .
In[5]:=
Click for copyable input
Out[5]=
This removes the value assigned to .
In[6]:=
Click for copyable input

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

The Wolfram Language cannot get a definite result for this test unless you give a specific numerical value.
In[7]:=
Click for copyable input
Out[7]=
If you replace by the specific numerical value , the test gives False.
In[8]:=
Click for copyable input
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, the Wolfram Language knows that the expressions must always be equal.

The two expressions are identical, so the result is True, whatever the value of may be.
In[9]:=
Click for copyable input
Out[9]=
The Wolfram Language does not try to tell whether these expressions are equal. In this case, using Expand would make them have the same form.
In[10]:=
Click for copyable input
Out[10]=

Expressions like represent equations in the Wolfram Language. There are many functions in the Wolfram Language for manipulating and solving equations.

This is an equation in the Wolfram Language. "Solving Equations" discusses how to solve it for .
In[11]:=
Click for copyable input
Out[11]=
You can assign a name to the equation.
In[12]:=
Click for copyable input
Out[12]=
If you ask for , you now get the equation.
In[13]:=
Click for copyable input
Out[13]=