GSoC 2012 Report Bharath M R: Implicit plotting.

catchmrbharath edited this page Aug 28, 2012 · 8 revisions
Clone this wiki locally

About me

My name is Bharath M R. I am a fifth year dual degree student of Electrical Engineering at IIT Madras. My project involved setting up the implicit plotting functions for SymPy and improving the plotting module.


The first part of my project was to implement the implicit plotting module. The implementation of the implicit plotting module closely followed [1]. The implicit plotting module uses interval arithmetic, and this was implemented at the start of my GSoC project. Initially the idea was to implement it in mpmath, but due to speed concerns, the interval arithmetic module was completely implemented in numpy. The interval arithmetic is not completely accurate as it uses floating points, but it was sufficient for plotting. The next part was to extend the algorithm to handle boolean combinations of functions. With small changes to the interval arithmetic module, implicit plotting of boolean combinations of function was implemented.

One of the improvements to the existing plotting module was adaptive sampling. This allowed the plotting module to plot functions which varied heavily, by checking the whether three points were almost collinear, and recursively sampling more, if the points are not almost collinear. This allows the plotting of $sin(10x)$ accurately, which otherwise would represent a different sine wave, due to aliasing.

I spent some of my time trying to get the plotting module working with svgfig. The output from svgfig was highly inconsistent sometimes, and it was also not in active development, hence the idea of adding plotting for the SymPy Live was dropped.

The last few weeks were spent on improving the plotting module, creating specific functions for plotting, and adding more documentation.

Future Work

  • Vector plots, ability to plot the geometry objects in SymPy.
  • A Mayavi backend for 3D plots, the 3D plots look way nicer compared to Matplotlib.
  • Adaptive sampling for 3D surfaces and plots.
  • Matplotlib has a HTML canvas backend. This can be integrated with SymPy Live, if we get Matplotlib support on the Google App Engine.

Looking Back

The GSoC period was one of the most fun project that I have worked on. I am really grateful to Aaron Meurer, my mentor, for providing me with a lot of independence and allowing me to experiment with a lot of things. One of the major things that I learnt was to structure my code, and refractor my code as much as possible. The discussions on the mailing list are really interesting, and I spent a lot of time reading about the things that were discussed.

One of the biggest things I would like to suggest to future GSoC students, is not to hesitate to ask questions. I was hesitant on asking questions on ipython dev list, for a long time and spent a lot of time trying to figure out things on my own. Also, you don't need to know a lot of math, to contribute to SymPy. There are a lot of things in SymPy, where heavy math knowledge is not necessary and small things that you learnt in your discipline can help you contribute to SymPy.