You can translate the result of an expression into various types of MathML with the export_mathml command.
xml_print(export_mathml(a+2*b)) |
<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <semantics> <mrow xref='id5'> <mi xref='id1'>a</mi> <mo>+</mo> <mrow xref='id4'> <mn xref='id2'>2</mn> <mo>⁢</mo> <mi xref='id3'>b</mi> </mrow> </mrow> <annotation-xml encoding='MathML-Content'> <apply id='id5'> <plus/> <ci id='id1'>a</ci> <apply id='id4'> <times/> <cn id='id2' type='integer'>2</cn> <ci id='id3'>b</ci> </apply> </apply> </annotation-xml> <annotation encoding='giac'>a+2*b</annotation> </semantics> </math> |
xml_print(export_mathml(a+2*b,content)) |
<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <apply id='id5'> <plus/> <ci id='id1'>a</ci> <apply id='id4'> <times/> <cn id='id2' type='integer'>2</cn> <ci id='id3'>b</ci> </apply> </apply> </math> |
xml_print(export_mathml(a+2*b,display)) |
<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <mrow> <mi>a</mi> <mo>+</mo> <mrow> <mn>2</mn> <mo>⁢</mo> <mi>b</mi> </mrow> </mrow> </math> |
s:=export_mathml(1/(x^2+1),display):; xml_print(s) |
<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <mfrac> <mn>1</mn> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mn>1</mn> </mrow> </mfrac> </math> |