Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare {mathematica, latex, sympy, mathml} for storing expressions a database #7

Closed
bhpayne opened this issue Dec 13, 2014 · 13 comments
Assignees
Labels

Comments

@bhpayne
Copy link
Member

bhpayne commented Dec 13, 2014

Produce a report comparing formats

what are we comparing?

  • presentation mathml, content mathml, mathematica, latex, abstract syntax tree

what is the evaluation?

  • can it describe all the notation necessary for physics
  • how easy is the input method? (character count)
  • can it be transformed to other representations

In general, we need to evaluate

  • ability to input
  • ability to transform between representations
  • ability to audit correctness

Not a problem:

  • storage

consumer cares about:

  • speed
  • ease of use
  • presentation
  • accessibility - multi-device, multi-OS
  • easy setup

To start, evaluate:

  • character count
  • rendering
@bhpayne bhpayne self-assigned this Dec 13, 2014
@bhpayne
Copy link
Member Author

bhpayne commented Dec 13, 2014

A set of test cases for flexing the capability of syntax, provided in Latex

  1. polynomial
    Latex:
a x^2 + b x + c = 0
  1. Stoke's theorem
    Latex:
 \int \int_{\sum} \vec{\nabla} \times \vec{F} \dot d\sum = \oint_{\partial \sum} \vec{F}\dot d\vec{r}

Source: https://en.wikipedia.org/wiki/Stokes'_theorem

  1. Tensor analysis
    Latex:
Y^i(X_j) = \Delta^i_{\ j}

Einstein notation: contravariant = superscript, covariant = subscript

4a) creation operator
Latex:

 \hat{a}^+ |n\rangle = \sqrt{n+1} |n+1\rangle

https://en.wikipedia.org/wiki/Creation_and_annihilation_operators

4b) uncertainty principle
Latex:

\sigma_x \sigma_p \geq \frac{\hbar}{2}

4c) Lüders projection
Latex:

 |\psi\rangle \rightarrow \sum_n  |c_n|^2 P_n,\; P_n = \sum_i |\psi_{ni}\rangle \lang \psi_{ni}|

wikipedia:

 <math> |\psi\rang \rightarrow \sum_n |c_n|^2 P_n,\; P_n = \sum_i |\psi_{ni}\rang \lang \psi_{ni}|</math>

https://en.wikipedia.org/wiki/Measurement_in_quantum_mechanics

https://www.physicsforums.com/threads/formulae-of-various-topics.102736/

@bhpayne
Copy link
Member Author

bhpayne commented Dec 13, 2014

Content MathML for 1:

<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<apply>
  <plus/>
    <apply><ci>a</ci> <power/><ci> x </ci><ci> 2 </ci></apply>
    <apply><ci>b</ci> <ci> x </ci>                    </apply>
    <apply><ci>c</ci>                                 </apply>
</apply>
<apply>
  <cn>0</cn>
</apply>
</apply>
</math>

http://www.w3.org/TR/REC-MathML/chapter2.html

@bhpayne
Copy link
Member Author

bhpayne commented Dec 13, 2014

Presentation MathML for 1:

<mrow>
<mrow>
 <mn>a</mn>
 <msup>
  <mi>x</mi>
  <mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
  <mn>b</mn>
  <mo>&InvisibleTimes;</mo>
  <mi>x</mi>
</mrow>
<mo>+</mo>
<mn>c</mn>
 </mrow>
<mo>=</mo>
<mn>0</mn>
</mrow>

Stokes' Theorem for 2

<mo>&#x222B;</mo>
<msub>
    <mo>&#x222B;</mo>
    <mo>&#x3A3;</mo>
</msub>
<mover>
  <mo>&#x2207;</mo>
  <mo>&rarr;</mo>
</mover>
<mo>&#x2A2F;</mo>
<mover>
<mi>F</mi>
<mo>&rarr;</mo>
 </mover>
<mi>&#xB7;</mi>
<mi>d</mi>
<mo>&#x3A3;</mo>
<mo>=</mo>
<msub>
    <mo>&#x222E;</mo>
    <mrow>
        <mo>&#x2202;</mo>
        <mo>&#x3A3;</mo>
    </mrow>
</msub>
 <mover>
<mi>F</mi>
<mo>&rarr;</mo>
 </mover>
<mi>&#xB7;</mi>
<mi>d</mi>   
<mover>
<mi>r</mi>
<mo>&rarr;</mo>
</mover>

Tensor notation for number 3 in MathML

<msup>
    <mi>Y</mi>
    <mi>i</mi>
</msup>
<mo maxsize='1'>(</mo>
<msub>
    <mi>X</mi>
    <mi>j</mi>
</msub>
<mo maxsize='1'>)</mo>
<mo>=</mo>
<msubsup>
    <mtext>&#x394;</mtext>
    <mrow>
        <mspace width='1em'></mspace>
        <mi>j</mi>
    </mrow>
    <mi>i</mi>
</msubsup>

4a, creation operator

<msup>
<mover>
    <mtext>a</mtext>
<mo>&#x5E;</mo>
</mover>
    <mo>&#x2020;</mo>
</msup>
<mo maxsize='1'>|</mo>
<mi>n</mi>
<mo maxsize='1'>&#x232A;</mo>
<mo>=</mo>
<msqrt>
    <mi>n</mi>
    <mo>+</mo>
    <mn>1</mn>
</msqrt>
<mo maxsize='1'>|</mo>
<mi>n</mi>
<mo>+</mo>
<mn>1</mn>
<mo maxsize='1'>&#x232A;</mo>

quantum mechanics in Presentation MathML

<mfenced open="&#x2329;" close="&#x232A;" separators="|">
<mi>p</mi>
<mo>a</mo>
<mi>p+</mi>
</mfenced>

Presentation MathML for 4b) uncertainty principle

<msub>
    <mtext>&#x3C3;</mtext>
    <mi>x</mi>
</msub>
<msub>
    <mtext>&#x3C3;</mtext>
    <mi>p</mi>
</msub>
<mo>&#x2265;</mo>
<mfrac>
    <mtext>&#x210F;</mtext>
    <mn>2</mn>
</mfrac>

http://www.fmath.info/java/latex-mathml-converter/

Following works in Firefox but not Chrome to render the presentation MathML
http://www.tutorialspoint.com/cgi-bin/practice.cgi?file=html5-21.htm
http://www-archive.mozilla.org/projects/mathml/demo/tester.html

Following works in all browsers and uses MathJax
http://www.tutorialspoint.com/try_mathml_online.php

Following works in all browsers and generates GIF
http://www.mathmlcentral.com/Tools/FromMathML.jsp

MathML examples
http://www.tutorialspoint.com/html5/html5_mathml.htm

@bhpayne bhpayne changed the title compare {mathematica, latex, sympy, mathml, abstract syntax tree} for holding content compare {mathematica, latex, sympy, mathml} for holding content Dec 25, 2014
@bhpayne
Copy link
Member Author

bhpayne commented Dec 25, 2014

Correction: MathML = abstract syntax tree

@bhpayne
Copy link
Member Author

bhpayne commented Dec 25, 2014

@bhpayne
Copy link
Member Author

bhpayne commented Dec 25, 2014

Mathematica to MathML

http://www.mathmlcentral.com/Tools/ToMathML.jsp

@bhpayne
Copy link
Member Author

bhpayne commented Dec 26, 2014

@bhpayne
Copy link
Member Author

bhpayne commented Dec 26, 2014

@bhpayne
Copy link
Member Author

bhpayne commented Jan 2, 2015

Report started in doc/syntax_comparison/syntax_comparison.pdf

@bhpayne bhpayne changed the title compare {mathematica, latex, sympy, mathml} for holding content compare {mathematica, latex, sympy, mathml} for holding content in storage database Mar 15, 2015
@bhpayne bhpayne changed the title compare {mathematica, latex, sympy, mathml} for holding content in storage database compare {mathematica, latex, sympy, mathml} for storing expressions a database Mar 15, 2015
@bhpayne
Copy link
Member Author

bhpayne commented Jun 2, 2018

http://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.1.pdf
Subscripts and superscripts are supported.
The Dirac notation is used as an example in the PDF.

https://www.johndcook.com/blog/2013/02/18/unicode-to-latex/

@bhpayne
Copy link
Member Author

bhpayne commented Feb 17, 2020

Sticking with latex for now

@bhpayne bhpayne closed this as completed Feb 17, 2020
@bhpayne
Copy link
Member Author

bhpayne commented Feb 26, 2020

See also "Towards semantic mathematical editing"
https://www.texmacs.org/joris/semedit/semedit.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant