resultAsMathML, resultAsLaTeX Methods and View

This is a question about exporting the math widget data into different data formats (LaTeX, MathML, image). In the MathPad app, how does the app use the data of LaTeX and MathML strings to compute with Wolfram Alpha? How would you integrate Wolfram Alpha to fully utilize the capabilities of LaTeX and MathML strings?
Also, how do you add buttons or additional views on the MAWMathViewController? I tried using:
[_mathViewController.view addSubview: self.redoButton]
in which the _mathViewController and redoButton are declared properly, but it doesn't work.

Thanks for the help.

About MyScript MathPad, it can solve equations through wolframalpha website. To do so, equations must be exported as Latex or Mathml and sent to the Wolframalpha server. This application does not offer a solver feature directly into the application.
About your second question, could you please let us know more details about this issue? Do you mean the button does not work or the action behind the button does not work?
Moreover, the 'redo' method will only work after calling the 'undo' method, so did you add a 'undo' button as well?
On our side we made a test to add an 'undo' button on the Math Widget sample and it works properly using following statements:

UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(300, 300, 10, 10)];
[bu setTitle:@"undo" forState:UIControlStateNormal];
[btn addTarget:_mathViewController action:@selector(undo) forControlEvents:UIControlEventTouchUpInside];
[_mathViewController.view addSubview:btn];

Please let us know if it helps.
Best regards

Hi Cate,
Thanks for the view fix. I realized that the auto-layout views were being distorted and the button wasn't appearing on the view I could see.
About the Wolfram Alpha server, how did you send requests? Did you use HTTP requests or the Wolfram Alpha API (I thought the Wolfram Alpha API didn't have a mobile SDK)? Can you give the process of how you did it? More specifically on how you passed the LaTeX/MathML string to the server, how you derived and displayed the results, and the process of incorporating Wolfram Alpha into the application?
Thanks for all your help,

Thanks for your feedback, Nishanth.
Here are the details about how we send our request in MyScript MathPad. We encode the MathML string given by the MathWidget using CFURLCreateStringByAddingPercentEscapes() and pass it to the server address.
Here is an example, if we want to solve 2/3 through WolframAlpha:
mathMSString = <math xmlns=''><mfrac><mrow><mn>2</mn></mrow><mrow><mn>3</mn></mrow></mfrac></math> (white spaces have been removed)

encodedMathMLString =

requestURL =

It is also possible to load the equation into the WolframAlpha app if it is installed on the device, by calling wolframalpha:// instead.
Unfortunately we cannot provide more details about displaying the result as we didn't develop such feature on our side. The solver of MathWidget does not cover all maths symbol and MathPad only send the converted equation to Wolfram website.
Hope it helps.

Hi Cate,
Thanks for your feedback, and sorry it took so long to get back to you. I was working on this yesterday and got it partially working, but the conversion from the mathMLString to the percent form is not working completely. Here is the below code:

NSString *mathmlString = [_mathViewController resultAsMathML];
CFStringRef mathmlCFString = (__bridge CFStringRef)mathmlString;
NSString *encodedMathMLString = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(nil, mathmlCFString, nil, nil, kCFStringEncodingUTF8));

Can you tell me what is wrong with the conversion? Also, would I need Wolfram Alpha's permission to open their app from mine?

Thanks for all your help,

To encode the URL, this should help you:

-(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding {
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef) self,
(CFStringRef)@"!*'"();:@&=+$,/?%#[]% ",

I recommend you to contact wolfram directly to handle your last request.
Best regards

Hi Cate,
Your code for encoding the string really helped! Thanks so much for following on this topic and helping me on an awesome feature!

Thanks for your feedback!

Login or Signup to post a comment