Live data from Hacker News

For mathematicians, = does not mean equality

jeremykun.com

41–50 of 206 posts

Re: For mathematicians, = does not mean equality

#41
post #27

There are few more examples that come to mind, like statements about intervals (π = 3.14 ± 0.01) and the usual notation for modular arithmetic; 3 * 3 = 1 (mod 4). Oh, and the wonderful notation for integrals, ∫ 2x dx = x² + C

The usual notation for modular arithmetic uses three dashes, not two, to denote congruence.

In my experience, mathematicians tend to drop the third dash.

I should also add that, as generally presented in higher level math, modular arithmetic actually does use literal equality. The abuse is in the numbers.

That is to say, when we write "9" in modular arithmetic, we mean the set of all numbers congruent to 9. In this case in "9=1 mod 4" the equality is literal because the set of numbers congruent to 9 is literally the same set as the set of numbers congruent to 1.

Re: For mathematicians, = does not mean equality

#44
post #31

(I assume this was inspired by https://news.ycombinator.com/item?id=16803874 ) The use of ‘=’ for assignment in programming languages comes, not directly from mathematics, but indirectly from the use of mathematics in science and engineering. As an example, consider the formula for kinetic energy, commonly written 𝑚𝑣² 𝐾 = ─── 2 Why isn't it written 2 K = m v ², which expresses the same mathematical equality in a s…

I believe it comes directly from conventional math exposition. In a general form it’s about emphasis.

“The change of subject from “The dog bit the boy” to “the boy was bitten by the dog” is similar to the change of subject in a formula, as for example … In each case, the two sentences state the same relationship, but with different emphasis.” [1]

[1] https://medium.com/q-e-d/that-loser-woman-mathematician-who-...

Re: For mathematicians, = does not mean equality

#46
When I learnt programming, i was confused by x=x+1;

After I understood what it really meant, I wondered why they didn’t use some other symbol to capture this semantic. Say something like x <- x+1 ; Which implies assignment rather than equality - That way this would be unambiguous and I feel is more clear. I now guess the choice of using ‘=‘ was probably an attempt at making a (compromised) choice given the limited symbols that were available back when High level languages were first written?

Re: For mathematicians, = does not mean equality

#47

Can someone explain why the JavaScript example equals 2?

The JS code in question:

console.log([1,2,3,4,5,6,7] ^ 2);

This produces 2 because ^ is the bitwise XOR operator in Javascript. Arrays are not numeric types, so they appear to be coerced to 0 for this comparison. In short, they are effectively logging "0 XOR 2", which is 2.

Re: For mathematicians, = does not mean equality

#48

Can someone explain why the JavaScript example equals 2?

^ is XOR. The author’s “translation” to JavaScript made inconsistent changes in the notation. Here we’re XOR between 2 and a non numeric value, which is coerced into a Number (NaN I think here), and NaN bitshifted with anything gives that thing.

Re: For mathematicians, = does not mean equality

#50
post #47

Can someone explain why the JavaScript example equals 2?

The JS code in question: console.log([1,2,3,4,5,6,7] ^ 2); This produces 2 because ^ is the bitwise XOR operator in Javascript. Arrays are not numeric types, so they appear to be coerced to 0 for this comparison. In short, they are effectively logging "0 XOR 2", which is 2.

I think it is actually NaN since it should be equivalent to Number([1,2,3])
Post reply on HN