Distinguish between variable names a_b and indexing a_1
See original GitHub issueSometimes, there are variables with a subscript. For example, when one has a triangle and a square and wants to calculate their areas: A_tri
and A_squ
. In this case, they’re clearly two different variables.
However, in a different context, one has matrices. To index the first row/column (depending on convention), one would write a_1
. To index the second one, it would be a_2
. In that case, they’re referring to the same variable.
The same thing applies to
- function
f(x) = 3x^2 + 2x
, thenf'
means “the first derivative of f” - but it’s also possible to define a variable
a'
Is there a general way of distinguishing between those two options?
As in, something along the lines of ["Symbol/Variable/Function/..", ["Subscript", "a", "t"]]
vs ["Subscript", "a", "1"]
. The former would mean “this entire thing is the variable name” while the latter would mean “the subscript probably has a special meaning”
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
By default (i.e. the version that’s in the Compute Engine default dictionary), the
OverTilde
is an “inert” function, that is it is used to “decorate” another expression, and provide some information about it. However, evaluating it does not change it, that isce.box(["OverTilde", "f"]).evaluate().json
is["OverTilde", "f"]
.The
Hold
function is useful to prevent an evaluation, but in this case, since the evaluation doesn’t do anything, theHold
function is not necessary.You have two options:
The parser can parse these LaTeX expressions (presumably, the first one is something like
\overset{\triangle}f
and the other one\tilde{f}
and map them to whatever symbol name you’d like, perhapsf_with_triangle_above
andf_with_tilde_above
, or something more semantic if appropriate (which would be preferred)Represent the “decorations” around the symbol as function applications, so
\tilde{f}
would become["OverTilde", "f"]
. This is how the Compute Engine currently handles it, although of course you can override it to implement the first solution if you prefer (with a custom parsing dictionary). The default Compute Engine dictionary does not have a definition for the delta-above, though, so one would need to be added.