Understanding Mathematical Notation as Code
github.com
github.com
[1]: http://www.jsoftware.com/papers/tot.htm
[3]: http://www.cs.trinity.edu/About/The_Courses/cs301/math-for-t...
How so, and in which cases would it be ambiguous to write X_i, but not X[i]?
Unlike programming languages, math notation evolved without being constrained by monospace ASCII characters and text lines.
PS: For typesetting Just capitalize the first letter. Radious ^ 2 * Pi = Area is common and unambiguous.
I believe that's the pseudocode format? I grew up in physics before the web took off and am now teaching myself bioinformatics, transcribing problem statements and pseudocode into working python.
There's several hundred years of pencil and paper math where these forms developed natively, unconstrained by $MY_KEYBOARD, which offers a far more limited range of expression. I am quite grateful for LaTeX, but I also understand the utility of suppressing that degree of expressiveness in code, where getting the point down quickly with a few more keys is a reasonable trade for the power of the machine that $MY_KEYBOARD interacts with.
Personally, I find iPython's web notebook to be an amazing environment.
In math, x_i is i-th element in a set/list and X[i] is the ring of polynomials.
And x_i could for example mean 'x in base i' (http://mathforum.org/library/drmath/view/57226.html)
Mathematicians invent notation to suit them in whatever problem they are working on. That notation doesn't have to be globally consistent.
EDIT: for a less trivial example, 2 is a unit in the integers mod 9, but 3 isn't.
This is a feature of math, not a bug. The potential for ambiguity is the cost that one pays to have a flexible and extensible notation which can be adapted to concepts yet undiscovered. This is generally not the case with code [1]. When you are exploring new ideas you want the ability to redefine your notation to match the nature and structure of the abstactions you are examining.
There is a finite number of symbols in the set of all human languages, and thus far we know of no reason that there should be a finite set of concepts in mathematics. Enforcing a one-to-one mapping from a given sequence of symbols to a given concept forces you to either limit the space of concepts you can consider or to eventually deal with impractically large sequences of symbols for relatively simple concepts.
[1] Yes, Lisp and DSLs are a thing, but you still have to define what a given sequence of symbols means. In an interpreted language, the interpreter computes the meaning using inputs and any necessary state. In math, the meaning is necessarily dependent on context as well.
I don't think they would ever have to be impractically large.
Right now they are just impractically weird.
I've always thought (ever since university) that code should take inspiration from math notation.
Instead of writing:
for (int i = 0; i < limit; i++) { acc += 1; }
just write: acc = ∑_(int i=0)^(limit);
I think maybe one should do some more math before telling a world of mathematicians what to do. Besides, it's far easier to create computer languages than the change math notation the world over.The mathematical meaning of x = 2kj isn't var x = 2 * k * j but var x = function(k, j) { return 2 * k * j; };
To say nothing of "var determinant = require('gl-mat2/determinant'); determinant(matrix)"! I guess the point is to go read the source code of the library, but I can't imagine many worse ways of learning linear algebra than reading the source code of optimized linear algebra routines.
[0] https://upload.wikimedia.org/wikipedia/commons/6/6e/Cross_pr...
The audience is hobbyists and self-taught developers with no formal background in mathematic notation. This audience might have no problem with a for loop, but the Summation symbol is (literally) just Greek to them.
Also keep in mind, that the whole thing is created maybe yesterday, so it's ok if it's not perfect yet.
Practically speaking, using ":=" removes any doubt when quickly skimming over old notes. It is nice to be able to easily separate what is defined and what is asserted in each of dozens of statements.
Might be what you were getting at with "doesn't compile or run".