Offline math program for iPhone

Hi, I have got an iPod Touch and I’ve always wanted a good math program for my iPod. I wanted one with all the things that I needed to calculate: integrals, diffs, limits, matrices, … but there was nothing for the iPhone. I looked up and in the AppStore and I found Wolfram Alpha, but it has two things I don’t like: it’s online and it has no memory.

So I looked up in Cydia an over the Internet and I didn’t find anything. I decided to try to compile GNU Octave, but it was very difficult, then I found that I could install python from Cydia. I did it and I found a module called sympy that does everything I wanted, it’s like a small matlab for your iPhone. You can see all the things this module does here. It’s really easy to get it working, here there are the requirements:

- Jailbroken iPhone
- Python (you can download it form Cydia)

And the steps:

Installation

1. In your iPhone, you need the Telesphoreo Tangelo source, that comes by default, anyway, it’s: http://apt.saurik.com and if you don’t have it a package called Terminal.

2. Now, in Cydia click into search and type python and download “Python” (not “iPhone/Python”).
3. From your computer download the .tar.gz file of Sympy from here. You should download the latest one, in this case it’s sympy-0.6.6.tar.gz
4. You’ll find a folder called sympy-version where version is the version, i.e.: sympy-0.6.6. To avoid problems extract the folder in your desktop and rename it to sympy.

5. From your computer copy the folder sympy directly inside your Media folder inside your iPhone. To copy files in your iPhone use iFuse if you are not on Lucid (if you’re on Lucid you don’t need anything!), and iPhone Explorer if you’re on Windows or on a Mac. The media folder is the default folder when you browse your iPhone with this programs. Some folders inside of Media are DCIM, iTunes_Control, or Photos.

(Note: The next steps: 6-8 may not be needed, if you want, try the manual without them and tell me if it worked.)

6. It’s almost done, now open your iPhone Terminal and type su. Type your root password, if you don’t have changed it, it should be alpine, if you have problems look up in google, I also don’t know if this step is needed or not, if you have problems try to avoid this part.

7. Now put this code in your Terminal:

cd /var/mobile/Media/sympy

And this one:

chmod +x setup.py

8. Now type this in your Terminal:

python setup.py

Running Sympy (after installation)

Even if you get errors executing setup.py don’t worry, as I don’t know if steps 6-8 are needed, I’ve done them but I doubt if they were needed. Ok, the point is that you have sympy installed. Now let’s see how you can open it. Close your terminal and open it again. Then put this code:

cd /var/mobile/Media/sympy

And then this one:

python

And… finally this one:

from sympy import *

You’re done, everything is fine. You can use the program, let’s do an example:

x=symbol('x')
pprint(integrate(1/(x**3+1),x))

Enjoy!

How to open Sympy faster

If you want to open Sympy faster, download this bash file I’ve created. Put it in /bin and give it executing permissions. To do this, just copy the file to Media in your iPhone and then, in your iPhone Terminal:

cd Media
su
cp 'sympy' '/bin'
cd /bin
chmod +x sympy

Then, to run Sympy, open your Terminal, type sympy and then inside the Python prompt type:

from sympy import *

6 Responses to “Offline math program for iPhone”


  • But can you *develop* for SymPy with Cydia? In other words, is there a good text editor for Python, and is there command line/git support? If so, I may consider jailbreaking my 1st gen iPod touch just for this.

    It would be interesting if you could get plotting to work. And does unicode pretty printing work?

  • Aaron Meurer, you can use a program called iFile on the iPhone in order to browse files.iFile also has a file editor. The file editor “just works”, you can edit the file but it has nothing else like automatic spaces, automatic brackets, … Maybe there are others, but I don’t know, if you want to do small edits that is ok, but if you want to make big files you may use your computer.

    The python in the iPhone is full, it has everything the computer version has. For me it’s not so much important the plotting part, as there are free programs in the App Store that do 2D and 3D plots.

    The jailbreak is really simple, google it, but maybe in 30-40 minutes you can have it jailbroken, although you should do a backup as everything in your iPod is deleted.

  • Actually, I am not too worried about finding a decent text editor for Python scripts. I haven’t looked into it, but I imagine that they are abundant.

    The main thing I am wondering about is if it would be possible to use git. Otherwise, I would just be wasting my time, because I would need to be able to pull the most recent changes from the development repository as well as sync with my own branches at github.

    Right now, I can use TouchSSH (free) to login to a remote machine that has all of this, but it is command-line only, and, more importantly, it only works when I have internet access.

    On the other hand, I may end up jailbreaking just because Apple’s built-in music app sucks so much. :)

    And I know that there are good plotting apps in the app store. I am just wondering if the sympy plotting works as a sympy developer. The same with unicode pretty-printing.

  • Aaron Meurer, I don’t know if you can use GIT, but I know there a lot stuff in Cydia. You can browse Cydia or also you can put this in the terminal:

    su
    apt-get install application

    if ‘application’ is in your cydia list it will install it, so maybe you can also install git, wait, let me try this:

    apt-get install git

    Yes, there’s a version of git for the iPhone (git_1.5.6.rc0-2_iphoneos-arm.deb)

    Some git commands that are in the git for the iPhone:

    add,bisect,branch,checkout,clone,commit,diff,fetch,grep,init,log,merge,mv,pull,push,rebase,resetrm,show,status,tag

  • Nice. I’ll have to check it out when I get some free time.

  • I do agree with all the ideas you have presented in your post. They’re really convincing and will definitely work. Still, the posts are very short for beginners. Could you please extend them a little from next time? Thanks for the post.

Leave a Reply