Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

render users' equations in Python

I am a very new/inexperienced Python programmer. I teach maths and am trying to create a GUI graph-plotting package suitable for schoolchildren.

As well as plotting a graph, I would ideally like to render the equation a user enters [eg. y = (x^2)/3] in a nicely formatted style - ideally updating in real-time as the user enters their expression.

I have looked into the capabilities of such as matplotlib, but it seems like the user would have to enter the above expression as something like frac{x^2,3}, which is not ideal for schoolchildren.

Many thanks in advance if anyone can help - sorry if it's a difficult question!

best wishes, Geddes

like image 532
Geddes Avatar asked Feb 11 '10 21:02

Geddes


3 Answers

You could look at how Lybniz does it. Or you could use Lybniz. Just saying.

like image 129
Ignacio Vazquez-Abrams Avatar answered Oct 22 '22 22:10

Ignacio Vazquez-Abrams


Perhaps you could make use of SymPy's printing capabilities.

like image 25
Craig McQueen Avatar answered Oct 22 '22 22:10

Craig McQueen


I am not sure whether you intend to have your students build this plotting tool in python or you want to build the tool yourself so they can use it to e.g., visualize changes in function behavior as inputs are varied. If the latter, then perhaps it's not important which language the tool is implemented in, so i'll mention one app i think is fits your brief description almost perfectly.

As well as plotting a graph, I would ideally like to render the equation a user enters [eg. y = (x^2)/3] in a nicely formatted style - ideally updating in real-time as the user enters their expression.

A free App called "Grapher." It comes packaged with the Mac OS X (10.4 and above). The fact that it is Mac-only might be a deal-breaker, still i wanted mention it in case your students are using Macs in a computer lab, as many grade-school students are. (Note: not to be confused with "AP Grapher"--also a Mac app but it's a wireless hotspot finder or something like that).

The basic feature set: fully interactive, enter an equation (intuitive--uses a subset of the mac key bindings) to create fairly complex equations from calculus, linear algebra, statistics, differential equations, and the like. Once entered, along with a range of values, the equation is beautifully plotted. Grapher has both a 2D and a 3D mode. Here's a screenshot of Grapher's main app window showing an equation plotted in 3D.

Is there a windows version? I've heard rumors that one exits, but i wasn't able to find any definitive information about it from a few quick Web searches just now.

like image 2
doug Avatar answered Oct 22 '22 22:10

doug