Last updated February 17, 2010. Created by LeeHunter on November 28, 2007.
Edited by bekasu, dwees. Log in to edit this page.

The Mathfilter module creates a filter which allows a user to enter equations and simple function graphs into their posts. For documentation on the equations, see the documentation on the CGI that Mathfilter uses, at John Forkosh's information page.

Unlike other solutions for entering equations online, this does not require Latex to be installed on your server, and is much easier to configure overall as a result. It does require a Mimetex (or Mathtex) CGI to be installed on a server to which your website server has access. It is reasonably straight forward to install Mimetex.cgi on your own server, and failing that, there are some publicly available Mimetex servers. The syntax of the equations is very similar to latex, and complete documentation on it is available here.

For the function graphs to work, they require a modified version of Walter Zorn's online JavaScript function grapher, which is included in the module files. Some people have noted configuration problems, especially with the graphs, as a result of not being able to enable 'clean-urls'. These graphs require JavaScript to be enabled in the end user's browser, and can cause a performance hit on a high traffic site because they use an iframe to an included php file, which uses a full Drupal bootstrap to gather some necessary information about the configuration of the graphs.

The filter uses a BBCode style syntax where equations are entered between [tex] and [/tex] tags, and graphs are either entered in [graph]function[/graph] tags or [graph xmin="-10" xmax="10" ymin="-10" ymax="10"]function[/graph] tags. The second of the two graphs tags allows the editor of the post to change the domain and range of the function being displayed.

Some examples of use include:

Text entered Result
[tex]x^n+y^n=z^n[/tex] x^n+y^n=z^n
[graph]sin(x)[/graph] sin(x)
[graph xmin="-7" xmax="11" ymin="-10" ymax="20"]x^2+4x[/graph] x^2

Some future goals of this project include:

1. Rendering the graphs as images, and caching the results. This will dramatically improve the overall performance of this module.
2. Allowing 3D function graphs to be entered.
3. A random number filter (for use with quiz style question creation).

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.