• 08/02/13 09:59 PM
    Sign in to follow this  

    Embedding Math Equations in Articles

    Archive

    Michael Tanczos

    Introduction

    It's no secret that we at Gamedev.net have always been pretty heavy on the programming side of game development. The purpose of this article is to share some quick information on how to beef up your articles with all sorts of fancy pants math equations and formulas that will help others to understand your article topic better.

    Background

    First we want to give a special thanks to Tim Bright for pointing out MathJax to us. MathJax is a LaTeX and MathML javascript-based display engine that works in all browsers. We currently use the standard configuration of MathJax, so all examples will closely follow the documentation on their site.

    Tutorial

    Most of this article is based off of the tex samples located at http://www.mathjax.org/demos/tex-samples/ . The key to using formulas inside of your articles is to wrap any LaTeX or MathML formula in one of two special wrappers. For multiline formulas use this: \[ multiline formula goes here \] For inline formulas and equations such as \(\sqrt{3x-1}+(1+x)^2\) you can use the following: \( inline formula goes here \)

    Quick Demo

    The Lorenz Equations \[\begin{aligned} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{aligned} \] The Cauchy-Schwarz Inequality \[ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \] A Cross Product Formula \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \end{vmatrix} \] The probability of getting \(k\) heads when flipping \(n\) coins is \[P(E) = {n \choose k} p^k (1-p)^{ n-k} \] An Identity of Ramanujan \[ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\ldots} } } } \] A Rogers-Ramanujan Identity \[ 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for $|q|<1$}. \] Maxwell's Equations \[ \begin{aligned} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned} \]

    Demo Source

    The Lorenz Equations \[\begin{aligned} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{aligned} \] The Cauchy-Schwarz Inequality \[ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \] A Cross Product Formula \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\ \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \end{vmatrix} \] The probability of getting \(k\) heads when flipping \(n\) coins is \[P(E) = {n \choose k} p^k (1-p)^{ n-k} \] An Identity of Ramanujan \[ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\ldots} } } } \] A Rogers-Ramanujan Identity \[ 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for $|q|<1$}. \] Maxwell???????s Equations \[ \begin{aligned} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned} \]

    Conclusion

    We hope this helps to build stronger, better, faster mathematics-based articles. Good luck and let us know if you come up with any issues.

    Article Update Log

    2 Aug 2013: Initial release


      Report Article
    Sign in to follow this  


    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now


    Liuqahs15

    Report ·

      

    Share this review


    Link to review
    Bacterius

    Report ·

      

    Share this review


    Link to review
    Bummel

    Report ·

      

    Share this review


    Link to review
    All8Up

    Report ·

      

    Share this review


    Link to review
    AngleWyrm

    Report ·

      

    Share this review


    Link to review
    pizzafan

    Report ·

      

    Share this review


    Link to review
    ifthen

    Report ·

      

    Share this review


    Link to review