I was wondering if there is an easy way to implement the rendering of math equations into an iOS app. It doesn't have to be interactive. All it should do is display the equation in traditional ways so when the user is dealing with complex equations it makes it easier to follow.
ex. 2^(2/(6^(1/2))) gives:
Wolfram Alpha does this along with other apps that I have seen. It doesn't have to deal with variables either.
Right-click (Mac: ctrl+click) the equation and choose Copy as MathML from the contextual menu.
Tap the Document tab, tap Document Setup, then double-tap the equation. Move an inline equation within the text: Select the equation and drag it to a new position. Equations in the header or footer can be moved within the header or footer when your document is in Document Setup view.
Tip: To set MathType as the default equation editor, choose Keynote > Preferences (from the Keynote menu at the top of your screen), click General, then select “Insert equations with MathType.”
A UIWebView can display mathML since iOS5. Your example:
<math title="2^(2/(sqrt(6))" xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle mathcolor="blue" fontfamily="sanserif" displaystyle="true">
<msup>
<mn>2</mn>
<mrow>
<mfrac>
<mn>2</mn>
<mrow>
<msqrt>
<mrow>
<mn>6</mn>
</mrow>
</msqrt>
</mrow>
</mfrac>
</mrow>
</msup>
</mstyle>
</math>
This will render in a UIWebView on iOS.
There are javascript libraries that can convert for you - eg mathjax can accept ASCIIMath input such as this example 2^(2/(sqrt(6))
There is a good discussion of these issues here Tradeoff between LaTex, MathML, and XHTMLMathML in an iOS app?
For simple expressions, the easiest way is probably to use HTML and display the expression in a UIWebView. This will work especially well if the expression part of other content that can also be displayed using HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With