Wednesday, August 12, 2020

Latex math expressions that case Sympy's Latex parser to fail

$ git clone https://github.com/allofphysicsgraph/proofofconcept.git
$ cd proofofconcept/v7_pickle_web_interface/flask
$ make dockerlive
$ python
>>> import sympy
>>> sympy.__version__
'1.5.1'
>>> from sympy.parsing.latex import parse_latex
>>> import json
>>> with open('data.json') as json_file:
...     dat = json.load(json_file)

>>> for expr_id, expr_dict in dat['expressions'].items():
...     print(expr_dict['latex'])

>>> for expr_id, expr_dict in dat['expressions'].items():
    try:
        x = parse_latex(expr_dict['latex'])
    except Exception as er:
        print('expr ID =', expr_id)
        print(er)

Using that approach, I found the following problems in the current (valid) Latex expressions used in the Physics Derivation Graph.


Subscripts with spaces

expr ID = 8871333437
I don't understand this
PE_{\rm Earth\ surface}
~~~~~~~~~~~~~^

expr ID = 7053449926
I don't understand this
r_{\rm geostationary\ orbit}
~~~~~~~~~~~~~~~~~~~~^


Use of "\left."

expr ID = 0439492440
I don't understand this
\frac{1}{a^2} = \frac{1}{2}W - \frac{1}{2}\left. \frac{W}{2n\pi}\sin\left(\frac{2n\pi}{W} x\right) \right|_0^W
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Spaces in subscript

expr ID = 7575859306
I don't understand this
\left( \delta^{l}_{\ \ j} \delta^{m}_{\ \ k} - \delta^{l}_{\ \ k} \delta^{m}_{\ \ h} \right) \hat{x}_i \nabla_j \nabla^m E^n = \vec{ \nabla}( \vec{ \nabla} \cdot \vec{E} - \nabla^2 \vec{E})
~~~~~~~~~~~~~~~~~~~^

expr ID = 7575859308
I don't understand this
\left( \delta^{l}_{\ \ j} \delta^{m}_{\ \ k} \hat{x}_i \nabla_j \nabla^m E^n\right)-\left( \delta^{l}_{\ \ k} \delta^{m}_{\ \ h} \hat{x}_i \nabla_j \nabla^m E^n \right)  = \vec{ \nabla}( \vec{ \nabla} \cdot \vec{E} - \nabla^2 \vec{E})
~~~~~~~~~~~~~~~~~~~^


Apostrophe

expr ID = 4662369843
I don't understand this
x' = \gamma (x - v t)
~^

expr ID = 2983053062
I don't understand this
x = \gamma (x' + v t')
~~~~~~~~~~~~~^

expr ID = 3426941928
I don't understand this
x = \gamma ( \gamma (x - v t) + v t' )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Comma in subscript

expr ID = 9973952056
I expected something else here
-g t = v_y - v_{0, y}
~~~~~~~~~~~~~~~~~^


expr ID = 7391837535
I expected something else here
\cos(\theta) = \frac{v_{0, x}}{v_0}
~~~~~~~~~~~~~~~~~~~~~~~~~^

expr ID = 8949329361
I expected something else here
v_0 \sin(\theta) = v_{0, y}
~~~~~~~~~~~~~~~~~~~~~~~^

Spaces

expr ID = 3920616792
I don't understand this
T_{\rm geostationary orbit} = 24\ {\rm hours}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Much greater than


expr ID = 9674924517
I don't understand this
K >> G
~~~^

No comments:

Post a Comment