r/Python • • Aug 05 '19

Python's response to MATLAB

Post image
4.3k Upvotes

372 comments sorted by

View all comments

Show parent comments

10

u/Eurynom0s Aug 05 '19

Again, Matlab is targeted at non-programmers, which is the kind of audience you might expect to assume that the scope of the ijk being used as loop variables is restricted to the loop.

0

u/[deleted] Aug 05 '19

[deleted]

3

u/IcecreamLamp Aug 05 '19

They're often used as counter variables in a loop. If you then later want to use i as the imaginary number, it will instead have the same value it had when you exited the loop.

5

u/Eurynom0s Aug 05 '19

This isn't really specifically about programming. In math and physics textbooks, you often see the unit vectors given as i j and k (instead of x y and z); vector/matrix indices will often be given ijk in a subscript; you'll often see triple summations with i on one, j on the second, and k on the third; etc. So the audience Matlab is intended for is going to want to loop over ijk (xyz) since it matches the notation they're used to using.

1

u/Feminintendo Aug 07 '19

What you are saying is contradictory. If everyone assumes i, j, and k are the orthonormal basis vectors for R3, then they obviously wouldn’t loop over them, because what the hell does it mean to “loop over” a basis vector? On the other hand, if everyone assumes i, j, and k are undistinguished available names for integer variables, they’d happily loop over them but wouldn’t think to use them as an orthonormal basis for R3.

But you’re mixing and matching, it seems. You seem to be saying that since STEM people see i, j, and k in textbooks used as basis vectors, it follows that they would assume i, j, and k are ineger iterators in loops. That’s a total non sequiter.

In a sane language, if i is the imaginary unit, it is write protected. I mean, there are a lot of un-sane languages according to this definition, but most CAS’s get this right, at least.

1

u/[deleted] Aug 05 '19

They are used in looping variables commonly, and correspond in math to imaginary numbers (most folks are familiar with i == sqrt(-1)). The nerdy term is quaternion.

1

u/billsil Aug 07 '19

Quaternions are the 4d version of imaginary numbers, which are 2d. They're used for specifying rotations in a way that don't suffer from gimbal lock. Octonians are the 8d version and are used in quantum physics. At each level, you lose fundamental properties of math (e.g., commutative or associative), which makes them more difficult.

-1

u/mexiKobe Aug 05 '19

They wouldn’t know what scope is.

7

u/Eurynom0s Aug 05 '19

Not knowing what scope is is a pretty good way to make scoping errors.

-4

u/mexiKobe Aug 05 '19

make up your mind

0

u/[deleted] Aug 05 '19

[deleted]

-3

u/mexiKobe Aug 05 '19

Nope. If you don’t know what scope is, you will correctly assume MATLAB’s behavior for FOR loops