Sympy ported to Android

61 views
Skip to first unread message

Dexter

unread,
Mar 9, 2011, 9:58:51 AM3/9/11
to sympy
Hi Guys,
After a month long struggle to learn android and compile python and
then struggling to display equations, I finally managed to port Sympy
to Android.

The app is named as MathScript and you can find it at
https://market.android.com/details?id=com.funmath.mathscript

When reasonable money comes in, I am planning to donate a portion of
it to Sympy group. Keep up the fantastic work guys!!

Shyam

Ondrej Certik

unread,
Mar 9, 2011, 11:25:38 AM3/9/11
to sy...@googlegroups.com
Hi Shyam!

Great job! How do you display the equations? Do you have some ideas
for improvement of SymPy, so that things like your applications are
easier to make?

Ondrej

Aaron S. Meurer

unread,
Mar 9, 2011, 2:21:08 PM3/9/11
to sy...@googlegroups.com
This looks impressive, based on the screenshots (I do not have an Andriod phone to test this with).

I have some questions as well:

- Does this run locally, or on some server. If it is locally, that is surprising, since I know that the iPhone at least does not allow you to run Python in apps.

- What do you use to do the plotting?

- How is the performance?

- In the package description, it says:
"On first installation, the application will download libraries from internet. This is one time only."

How large is the whole thing after doing all that?

Aside from money, please consider "donating" back any improvements you make to SymPy as patches, so that everybody can benefit.

Also, can I request that you mention that it is in fact SymPy that is running in the package description, so that people will be aware of what is powering the CAS and it will increase the awareness of SymPy?

Aaron Meurer

Dexter

unread,
Mar 9, 2011, 10:19:05 PM3/9/11
to sympy
Hi Ondrej,

Displaying the equation was a bit tricky indeed. I use MimeTex
library. But, since it is GPL and I intend to earn money (he heh),
there is a conflict of interest in terms of policies. So, I developed
a mimetex android library, put it in google code and download to
mobile. I then load it dynamically when the code wants to convert
latex equations to GIF.

The one thing I am facing difficulty is the categorization of
functions. Though Sympy documentation gives an overview, it is quite
difficult to automatically categorize the functions based on querying
the Python modules. I am trying to write a categorization myself, and
will post to SymPy once done.

Another thing is calling of functions. Say for example, the
determinant of matrix requies you to call the member function like
M.det(). Same thing for M.subs() etc.. But, in general, the symbolic
packages have a format as det(M) and it is a bit difficult to make
users adopt two different strategies for functions. I am intending to
write some wrapper functions so that the entire library becomes
streamlined in terms of normal users.

The app is in a development stage. I haven't modified the SymPy
library yet and it is being used as it is. Any changes/addons to the
library will be reflected back to here.


On Mar 10, 12:25 am, Ondrej Certik <ond...@certik.cz> wrote:
> Hi Shyam!
>

Dexter

unread,
Mar 9, 2011, 10:31:54 PM3/9/11
to sympy
It runs locally on the Phone. Beleive it or not, its surprisingly
fast beyond my expectations. Takes just a fraction of second for
simple things. But, if you do complicated math, like solving
differential eqns, it will take a bit of time. But still, the recent
phone specs can match closely with the speed of desktops.

The original pythonforandroid has some trouble when I tried to use
Sympy. And thats how the whole project started :) I compiled python
for my use and then created the core which then loads SymPy.

For plotting, I use the achartengine library for android. But, it will
be changed later.

Since the app is in constant development, it is designed to have
smaller sized updates. So, it downloads nearly all its dependencies
from internet. The libraries are Python, Sympy and MimeTex. It comes
to nearly 8MB of download and much more after extracting. But, they
are all done in external storage. So no issues.

I will definitely reflect back and additions/changes I make to the
code. As of now, I use SymPy as it is.

Yes. Included SymPy in the description page. It will also be mentioned
in the help page.


On Mar 10, 3:21 am, "Aaron S. Meurer" <asmeu...@gmail.com> wrote:
> This looks impressive, based on the screenshots (I do not have an Andriod phone to test this with).
>
> I have some questions as well:
>
> - Does this run locally, or on some server.  If it is locally, that is surprising, since I know that the iPhone at least does not allow you to run Python in apps.  
>
> - What do you use to do the plotting?
>
> - How is the performance?
>
> - In the package description, it says:
> "On first installation, the application will download libraries from internet. This is one time only."
>
> How large is the whole thing after doing all that?
>
> Aside from money, please consider "donating" back any improvements you make to SymPy as patches, so that everybody can benefit.  
>
> Also, can I request that you mention that it is in fact SymPy that is running in the package description, so that people will be aware of what is powering the CAS and it will increase the awareness of SymPy?
>
> Aaron Meurer
>
> On Mar 9, 2011, at 9:25 AM, Ondrej Certik wrote:
>
>
>
>
>
>
>
> > Hi Shyam!
>

Ondrej Certik

unread,
Mar 10, 2011, 1:34:34 AM3/10/11
to sy...@googlegroups.com
Hi Shyam,

On Wed, Mar 9, 2011 at 7:31 PM, Dexter <shyamd...@gmail.com> wrote:
> It runs locally on the Phone.  Beleive it or not, its surprisingly
> fast beyond my expectations. Takes just a fraction of second for
> simple things. But, if you do complicated math, like solving
> differential eqns, it will take a bit of time. But still, the recent
> phone specs can match closely with the speed of desktops.
>
> The original pythonforandroid has some trouble when I tried to use
> Sympy. And thats how the whole project started :) I compiled python
> for my use and then created the core which then loads SymPy.
>
> For plotting, I use the achartengine library for android. But, it will
> be changed later.
>
> Since the app is in constant development, it is designed to have
> smaller sized updates. So, it downloads nearly all its dependencies
> from internet. The libraries are Python, Sympy and MimeTex. It comes
> to nearly 8MB of download and much more after extracting. But, they
> are all done in external storage. So no issues.
>
> I will definitely reflect back and additions/changes I make to the
> code. As of now, I use SymPy as it is.
>
> Yes. Included SymPy in the description page. It will also be mentioned
> in the help page.

Thanks for that. Indeed, that's why we use the BSD license for SymPy,
so that it allows people to build products like you did and it allows
you to "own" all your work that you did on top of sympy.

As Aaron said, if you send us some of your improvements back to SymPy,
it would benefit everyone.

In any case, keep in touch and keep us posted how it goes.

Ondrej

Aaron S. Meurer

unread,
Mar 10, 2011, 12:10:52 PM3/10/11
to sy...@googlegroups.com

On Mar 9, 2011, at 8:19 PM, Dexter wrote:

> Hi Ondrej,
>
> Displaying the equation was a bit tricky indeed. I use MimeTex
> library. But, since it is GPL and I intend to earn money (he heh),
> there is a conflict of interest in terms of policies. So, I developed
> a mimetex android library, put it in google code and download to
> mobile. I then load it dynamically when the code wants to convert
> latex equations to GIF.
>
> The one thing I am facing difficulty is the categorization of
> functions. Though Sympy documentation gives an overview, it is quite
> difficult to automatically categorize the functions based on querying
> the Python modules. I am trying to write a categorization myself, and
> will post to SymPy once done.

Thanks. That would be useful. Ideally, where the directory and file structure of the functions should be a good categorization. In what cases does this not suit your needs?

>
> Another thing is calling of functions. Say for example, the
> determinant of matrix requies you to call the member function like
> M.det(). Same thing for M.subs() etc.. But, in general, the symbolic
> packages have a format as det(M) and it is a bit difficult to make
> users adopt two different strategies for functions. I am intending to
> write some wrapper functions so that the entire library becomes
> streamlined in terms of normal users.

We have already tried to do the reverse, so that most common functions have a method version, like x.simplify(), x.expand(), x.factor(), etc.

Aaron Meurer

>
> The app is in a development stage. I haven't modified the SymPy
> library yet and it is being used as it is. Any changes/addons to the
> library will be reflected back to here.
>
>
> On Mar 10, 12:25 am, Ondrej Certik <ond...@certik.cz> wrote:
>> Hi Shyam!
>>
>> On Wed, Mar 9, 2011 at 6:58 AM, Dexter <shyamdsun...@gmail.com> wrote:
>>> Hi Guys,
>>> After a month long struggle to learn android and compile python and
>>> then struggling to display equations, I finally managed to port Sympy
>>> to Android.
>>
>>> The app is named as MathScript and you can find it at
>>> https://market.android.com/details?id=com.funmath.mathscript
>>
>>> When reasonable money comes in, I am planning to donate a portion of
>>> it to Sympy group. Keep up the fantastic work guys!!
>>
>> Great job! How do you display the equations? Do you have some ideas
>> for improvement of SymPy, so that things like your applications are
>> easier to make?
>>
>> Ondrej
>

> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>

Aaron S. Meurer

unread,
Mar 10, 2011, 12:32:01 PM3/10/11
to sy...@googlegroups.com
On Mar 9, 2011, at 11:34 PM, Ondrej Certik wrote:

> Hi Shyam,
>
> On Wed, Mar 9, 2011 at 7:31 PM, Dexter <shyamd...@gmail.com> wrote:
>> It runs locally on the Phone. Beleive it or not, its surprisingly
>> fast beyond my expectations. Takes just a fraction of second for
>> simple things. But, if you do complicated math, like solving
>> differential eqns, it will take a bit of time. But still, the recent
>> phone specs can match closely with the speed of desktops.

That is the same thing that I saw on my jailbroken iPod touch, where I installed SymPy in the command line. Considering the CPU speed is less than one-fifth that of my laptop, it is pretty decent. But I think we are always being surprised at how fast a computer algebra system written in pure Python can be.

>>
>> The original pythonforandroid has some trouble when I tried to use
>> Sympy. And thats how the whole project started :) I compiled python
>> for my use and then created the core which then loads SymPy.
>>
>> For plotting, I use the achartengine library for android. But, it will
>> be changed later.

We hope to modularize the plotting in SymPy at some point in the future. And pointers on difficulties you had or things you think should be done would be welcome.

>>
>> Since the app is in constant development, it is designed to have
>> smaller sized updates. So, it downloads nearly all its dependencies
>> from internet. The libraries are Python, Sympy and MimeTex. It comes
>> to nearly 8MB of download and much more after extracting. But, they
>> are all done in external storage. So no issues.
>>
>> I will definitely reflect back and additions/changes I make to the
>> code. As of now, I use SymPy as it is.
>>
>> Yes. Included SymPy in the description page. It will also be mentioned
>> in the help page.

Thank you.

Here are some more ideas. Note that as I said, I don't have an Android phone, so I don't know if you really haven't done these things yet or not:

- The iPhone app for Wolfram Alpha (http://products.wolframalpha.com/iphone/) has a nice custom keyboard that makes entering mathematical notation easier. I have a friend with an iPod touch who bought the app just for the keyboard (otherwise, you could just do everything from a web browser). So you might consider doing the same.

- How are the docs for SymPy in your app? Is it at least easy for you to get to the docstrings. Anyway, I would make it easy for the user to access them.

- I would make the Gotchas and Pitfalls page (http://docs.sympy.org/dev/gotchas.html) and maybe also the FAQ page prominent in whatever help system you have. In particular, I think that most people who try your app will not be used to ** for exponentiation.

>
> Thanks for that. Indeed, that's why we use the BSD license for SymPy,
> so that it allows people to build products like you did and it allows
> you to "own" all your work that you did on top of sympy.
>
> As Aaron said, if you send us some of your improvements back to SymPy,
> it would benefit everyone.
>
> In any case, keep in touch and keep us posted how it goes.
>
> Ondrej

That is exactly right. I think you will find that it is to your advantage as well as ours to submit your changes back to SymPy. Otherwise, you have to reapply them on top of every new version, and they might not apply cleanly. On the other hand, if they are part of the main repo, we will handle any merge conflicts with further patches, and you changes will become supported by the SymPy development team. This actually holds true for most open source software libraries. It's also why I think that BSD is a perfectly suitable choice of licensee for a library like SymPy (as opposed to GPL), because I think that even if people don't necessarily open source what they base SymPy on (which can be fine if they do something like you did and make it work with a lot of other libraries and want to make a little money on it), they will open source their changes to SymPy in the form of submitting them back to the project, because it's perfectly to their advantage to do so.

Aaron Meurer

Ondrej Certik

unread,
Mar 10, 2011, 1:20:42 PM3/10/11
to sy...@googlegroups.com, Aaron S. Meurer
On Thu, Mar 10, 2011 at 9:32 AM, Aaron S. Meurer <asme...@gmail.com> wrote:
[...]

>
> That is exactly right.  I think you will find that it is to your advantage as well as ours to submit your changes back to SymPy.  Otherwise, you have to reapply
> them on top of every new version, and they might not apply cleanly.  On the other hand, if they are part of the main repo, we will handle any merge conflicts
> with further patches, and you changes will become supported by the SymPy development team.  This actually holds true for most open source software
> libraries.  It's also why I think that BSD is a perfectly suitable choice of licensee for a library like SymPy (as opposed to GPL), because I think that even if
> people don't necessarily open source what they base SymPy on (which can be fine if they do something like you did and make it work with a lot of other
> libraries and want to make a little money on it), they will open source their changes to SymPy in the form of submitting them back to the project, because it's

Or a lot of money.

> perfectly to their advantage to do so.


Yes. Important is, that it is up to them, whether and when/how to
opensource their own work. And if they do so, it is because they want,
not because they have to. So I like this model, and it is exciting to
see the first commercial application build upon SymPy.

I hope more will come. :)

Ondrej

Reply all
Reply to author
Forward
0 new messages