I have a large document (around 200 pages) describing a certain line of computations. I want to implement those methods using Wolfram Language. Formulas contain functions and variables that are introduced in the document. In order to implement them in WL I could use a standard notation someSymbleName, but that would mean changing the original mathematical notation which would require extra measures of keeping track of things.

I tried using symbols with subscripts to meet the same notation, but that works weirdly, code highlighting is messed up, and from what I've read it's not recommended. Besides, names like Eouter collide (in some way) with the reserved names.

I thought of using images as the symbols. The notations would be exactly the same, they look good in formulas, but I'd have to copy them everytime. Anyway, I couldn't make WL to treat images like symbols.

My question is what is the right approach here?


As you are likely aware, the symbols themselves are irrelevant in mathematical notation, but serve as a mnemonic for the readers/authors. There are a lot of good, general practices revolving around this topic alone. For example, use descriptive variable and function names, e.g. $E_{total}$ becomes


if it is an energy. This way you limit the cognitive mismatch between implementation and documentation, and go a long way towards creating self-documenting code. Additionally, make use of comments and the notebook features, like Text cells, to provide references to your reference papers. This can be used to document the correspondence between the mathematical variables and the programming variables, if it isn't otherwise clear. Also, limit the use of single letter variables, except in obvious cases like some loop iterators, e.g.

Table[importantFunction[i], {i, 100}]

As I said above, there are a lot of references on good practices like this. I suggest you head over to Software Engineering to have a look.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.