Posted on 5th January 2010No Responses
jQuery and Quadratic Functions

As x changes in value, the quadratic function: f(x) = ax2+bx+c describes a parabola – an arc through space – in terms of a two dimensional axis where x describes the vertical and f(x) describes the horizontal points at intervals.

The graphic result of a quadratic function

The graphic result of a quadratic function

Quadratic functions also allow for a fun afternoon combining the jQuery form plugin with the jpgraph PHP library. I started out with a simple PHP function to produce a range of f(x) values for any set of values x. I then built a form to allow any value for a, b and c to be input as well as the maximum and minimum for x and the steps that x takes. Once that was working, I passed the results into two arrays and passed those to jpgraph which produces a graphical image on the fly and stores it on the server. Finally, to avoid page refreshes, I wrapped the form around the jQuery ‘plugin’ (can these properly be called plugins? I suppose so…) The result is a simple and relatively intuitive visual demonstration of the relationship between mathematics and geometry. In fact, expanding that out, the relationship is actually between mathematical logic, computation and optics – but that gets us into a kind of crazy Turing territory and lines have to be drawn somewhere.

Try it out here

For the future, I would like to be able to produce more accurate and extensible graphs for larger number ranges, and to plug the whole thing into calculus, to really push the spatial theme. But this is something of a start and it is perhaps the simplest demonstration of the more general relationship.

Comments
Leave a Response
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>