# Math-in-HTML Examples

### How to add high-quality, scalable math formulas to web pages.

$$\pi/4 = 1-1/3+1/5-1/7+1/9-1/11+\cdots$$ $$x(t)=\sum_{k=0}^{\infty}a_k \cos(2\pi kt/T)+b_k \sin(2\pi kt/T)$$

Web Development section >

This Math-in-HTML Examples page

! Note !
More MathJax info and examples may be added,


<script type="text/javascript" src="/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>



 in the 'head' section of this web page. You may have to adjust the directory location of 'MathJax.js' to be compatible with your web site structure. Some MathJax (and MathML) Examples : From the Wikipedia page on MathML, the code :


<h4>Example of MathML embedded in an HTML5 file : </h4>

<p>
The area of a circle is
$<mi>&pi;</mi> <mo>&InvisibleTimes;</mo> <msup> <mi>r</mi> <mn>2</mn> </msup>$.
</p>



is rendered as :

#### Example of MathML embedded in an HTML5 file :

The area of a circle is $\pi {r}^{2}$.

You can see from this that MathML is quite 'wordy' --- although it usually does not require the installation (or remote access to) a large group of files. The MathML interpreter is built into most modern (post-2011) web browsers.

On the other hand, the following MathJax examples use a more compact notation --- so that a one-line math formula can usually be coded using one line of MathJax syntax.

A MathJax TeX example :

The TeX-like code :


<p>
When $$a \ne 0$$, there are two solutions to $$ax^2 + bx + c = 0$$
and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</p>



 renders as : When $$a \ne 0$$, there are two solutions to $$ax^2 + bx + c = 0$$ and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ A few MathJax examples from an AMS web page : In the 2015 April ams.org web page www.ams.org/news/math-in-the-media/04-2015-media, we can see MathJax examples like the following (by looking at the web page source HTML). The string $$\pi$$  causes a greek letter pi to be shown ... centered like this $$\pi$$ The line $$\pi/4 = 1-1/3+1/5-1/7+1/9-1/11+\cdots$$  displays a representation of the infinite series that connects all odd numbers to pi, namely $$\pi/4 = 1-1/3+1/5-1/7+1/9-1/11+\cdots$$ The line $$x(t)=\sum_{k=0}^{\infty}a_k \cos(2\pi kt/T)+b_k \sin(2\pi kt/T)$$  presents the equation for a Fourier series of the function x(t): $$x(t)=\sum_{k=0}^{\infty}a_k \cos(2\pi kt/T)+b_k \sin(2\pi kt/T)$$ More examples It is my intent that the discussion and examples above will help people (relatively) quickly understand how to render math formulas in web pages. There are more examples in about 20 '.html' files in the 'test' directory of the MathJax installation. To find more MathJax or MathML examples, you can do WEB SEARCHES on keywords such as: You can find examples involving calculus symbols for integration and differentiation.

Bottom of this
Math-in-HTML Examples page.