2

I have a mathml expression suppose:

<math><msup><mi>x</mi><mn>2</mn></msup></math>

I need to make x^2 from this say math notation.

I checked a lot and find out certain solutions but all refers the opposite thing, ie, making mathml from math notation.

Reference

I need just the opposite.

Making math notation from mathml.

Note: I need a generalised thing that should work on all conditions of mathml?

Python version: 3.4

6
  • 3
    possible duplicate of Alternative for python-mathdom Commented Aug 24, 2015 at 11:37
  • My python version is 3.4. Sadly that library support only on 2.6 and 2.7 Commented Aug 24, 2015 at 13:25
  • @Santhucool do you or your colleagues have the skill to port this library to Python 3.4? Commented Aug 24, 2015 at 15:11
  • @shuttle87 it will be a tedious task!! Why python does not have version compatibility? Thats y java is still the best!! Commented Aug 25, 2015 at 4:10
  • @Santhucool, if it's worth it to your team you could always port if need be, there's tools to help that, for example the 2to3 tool. This particular library happens to interest me and I'd be happy to port it given the means (translation: some nominal amount of money). The reason Python 3 broke backwards compatibility was to fix core problems with the language that couldn't otherwise be fixed. As someone who uses Java professionally the backwards compatibility is great but we have to recognize that it does come with a very real cost, that being the enormous amount of cruft in the language. Commented Aug 25, 2015 at 14:21

1 Answer 1

2

The answer below assumes that you have Maple installed. Maple can parse MathML code that can be converted later using the CodeGeneration package to the following programming languages:

C, CSharp, Fortran, IntermediateCode, Java, JavaScript,
Julia, LanguageDefinition, Matlab, Names, Perl,
Python, R, Save, Swift, Translate, VisualBasic

Here is an example:

  • Copy the MathML code.
  • Open Maple, and paste. You will see this message box:

enter image description here

  • Clicking on Yes, you will see:

enter image description here

  • Load the CodeGeneration package, and call the Python function:
with(CodeGeneration)
Python(cos(x)^2 + sin(x)^2 = 1, resultname = "expr1")

The result will be:

expr1 = math.cos(x) ** 2 + math.sin(x) ** 2 == 1

You can adjust the result accordingly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.