What is $x=5$ called??

1k Views Asked by At

I have CS background, and I'm trying to teach fundamentals of programming to students. They seem to have difficulties in understanding the difference between x=5 and x==5. However, trying to explain, made me wonder what the meaning of $x = 5$ is in mathematics.

Is there a concept of assignment in mathematics? Or is this an equation/binding/statement/something else? What is its proper name? And does the use of the $=$ operator differ from its use in the function below?

$$f(x) = \begin{cases} \displaystyle 1 \quad \text{if } x \bmod 2 = 0\\ \displaystyle 0 \quad \text{if } x \bmod 2 = 1\\ \end{cases}$$

Is there a classification of the uses of equality operator in math? Or is it the same in every case, and I just fail to see it?

5

There are 5 best solutions below

5
On

In mathematics, the $=$ sign can be used as a simple statement of fact in a specific case ($x = 5$), to create definitions (let $x=3$), conditional statements (if $x = 2$, then …), or to express an universal equivalence: $$(x^2+2x+1 )= (x+1)^2$$

When used in computer programming, the $==$ is a relational operator testing for equality unlike the $=$ reserved for assignments (w. r. t C programming).

For more, you can see here.

0
On

Normally in mathematics a variable is not variable in the sense that it varies throughout the discussion. This means that there is no real difference between the interpretations. In programmer language the closest analogue would be that mathematical variables are constants.

The statement $x=5$ should be interpreted as a statement claiming that $x$ is equal to $5$. It may be that we haven't defined $x$ yet in which case such a claim would define $x$ (since we assume that there exist such an $x$).

As for assignment the normal way would be to consider a sequence of values that $x$ would take over time and then one normally add index to it. Like when a programmer writes x := x+1 a mathematician would write $x_{n+1} = x_{n}+1$

0
On

For my freshmen, I make the distinction between "identity equals" and "conditional equals." It seems to clear up some confusions. Identity equals means the sentence is always true, and for my context, includes "assignment" and "definition". So if we say "Let $u = x^2+5$" then we mean that this is true for all $x$ (in the current setting.) And if we say "$\cos^2 x+\sin^2 x =1$" we mean this is true for all $x.$

Conditional equals is when we write an equation and want to know when it is true. As in, "Solve $x^2+5x-1=0$."

I've never found a need to split the hairs more finely (in undergrad math classes.)

0
On

It's not just you. Traditional mathematical notation is filled with ambiguous notations that you just have to distinguish on a case by case basis, using the context to guide you.

Without context, I would guess that $x = 5$ is preceded by something like $x^3 - 3 = 122$. Then $x = 5$ is an equation and the student is expected to "solve for $x$."

In the context of an iterated operation, the equals symbol can be used as an initial (or ending) assignment operator, e.g., $$\prod_{x = 5}^{200} \frac{1}{x^2 - 1}.$$ Of course in such a case, most people would prefer to use $i$ or $k$ rather than $x$. But still, the equals sign is used where a programmer might prefer ":=".

As for your negated parity bit function, there is a different symbol you could use to clear up some of the ambiguity, the equivalence symbol. e.g., $f(x) = 1$ if $x \equiv 0 \bmod 2$.

This Wolfram page might be helpful: http://reference.wolfram.com/language/tutorial/Equations.html

0
On

In addition to the "identity equals" and "conditional equals" that B.Goddard suggests, you might also teach "Yoda conditions" so that if an '=' is inadvertently omitted, a syntax error would result.

They are named for the famous Jedi master whose syntax is often reversed. In C-type programming languages, x == 5 and 5 == x are equivalent. Some environments, like WordPress, have programming practices that include Yoda conditions.

For example, if you mean to code

if( x == 5 ) { /* code */ }

but accidentally type

if( x = 5 ) { /* code */ }

you will have hours of pain trying to find your error. However, if you intend to code a Yoda conditional like

if( 5 == x ) { /* code */ }

but on accident type

if( 5 = x ) { /* code */ }

an error will result. No debugging necessary; the system tells you where the error is.

In other words, the difference between x = 5 and x == 5 is unique to CS. Your students simply need practice with it to understand it. In my opinion, Yoda conditions will help avoid a common error until the understanding is deep enough that making such an error will no longer be an issue.