Using math expressions in github markdown

This blog explores using and creating some standard mathematical expressions using github markdown. I was motivated to try this out after reading this blog. If you know the TEX Commands available in MathJax, then creating math documentation in github is a breeze. Github markdown uses MathJax.

Code: https://github.com/damienbod/math-docs

I decided to try out some basic math functions.

Quadratic equations examples

$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}$$

$(a+b)^2$

$$\eqalign{
(a+b)^2 &= (a+b)(a+b) \\
        &= a^2 + ab + ba + b^2 \\
        &= a^2 + 2ab + b^2
}$$

$(a-b)^2$

$$\eqalign{
(a-b)^2 &= (a-b)(a-b) \\
        &= a^2 - ab - ba + b^2 \\
        &= a^2 - 2ab + b^2
}$$

$(a-b)(a+b)$

$$\eqalign{
(a+b)(a-b)  &= a^2 - ab + ba - b^2 \\
        &= a^2 - b^2
}$$

Produces https://github.com/damienbod/math-docs#quadratic-equations

Functions

$$ f(x) = {\sqrt{5x^2+2x-1}+(x-2)^2 } $$

$$ g(x) = {\\frac{a}{1-a^2} }$$

$$ f(x) = {(x + 2) \over (2x + 1)} $$   

$$ f(x) = { \sqrt[3]{x^2} }$$
  
$$ \sqrt[5]{34}$$

Trigonometry examples

$$ cos^2 \theta + sin^2 \theta  = 1  $$

$$ tan 2 \theta = {2tan \theta  \over 1 - tan^2 \theta}  $$

$$\eqalign{
cos 2 \theta = cos^2 \theta - sin^2 \theta \\
                       &=  2 cos^2  \theta -1 \\
                       &= 1 - 2sin^2 \theta 
}$$

Prove $ \sqrt{ 1 - cos^2 \theta \over 1- sin^2 \theta} = tan \theta $

$$ \sqrt{ 1 - cos^2 \theta \over 1- sin^2 \theta} 
= \sqrt{ sin^2 \theta \over cos^2 \theta} 
= {sin \theta \over cos \theta} = Tan \theta 
$$

Calculus examples

$$\eqalign{
f(x) = {3x^4} \implies {dy \over dx} = 12x^3
}$$

$$\eqalign{
f(x) = {2x^{-3/2}} \implies {dy \over dx} = -3x^{-5/2} &= -{3 \over \sqrt{x^5}}
}$$

If $x = 2t + 1$ and $ y = t^2$ find ${dy \over dx}$ ?

$$\eqalign{
x = 2t + 1 \implies  {dx \over dt} = 2 \\
        y = t^2 \implies  {dy \over dt} = 2t \\
        {dy \over dx} = {dy \over dt} \div {dx \over dt} \\
         \implies 2t \div 2 = t
}$$

Integration examples

Evaluate $\int_1^2 (x + 4)^2 dx $

$$\eqalign{
\int_1^2 (x + 4)^2 dx = \int_1^2 (x^2 + 8x + 16) dx \\
  &= \left\lbrack {x^3 \over 3} + {8x^2 \over 2} + 16x \right\rbrack_1^2 \\
  &= \left\lbrack {8 \over 3} + {8 * 4 \over 2} + 16 * 2 \right\rbrack 
   - \left\lbrack {1 \over 3} + {8 \over 2}  + 16  \right\rbrack 
}$$

Matrix example

$$ {\left\lbrack \matrix{2 & 3 \cr 4 & 5} \right\rbrack} 
* \left\lbrack \matrix{1 & 0 \cr 0 & 1} \right\rbrack 
= \left\lbrack \matrix{2 & 3 \cr 4 & 5} \right\rbrack 
$$

Sum examples

$$\sum_{n=1}^n n = {n \over 2} (n + 1) $$

$$\sum_{n=1}^n n^2 = {n \over 6} (n + 1)(2n + 1) $$

Notes

It is super easy to create great mathematical documentation now using github markdown. This is super useful for many use cases, schools, students and reports. This blog provides great help in finding the correct code to produce the docs.

Links

Render mathematical expressions in Markdown

https://www.mathjax.org/

http://docs.mathjax.org/en/latest/

https://docs.mathjax.org/en/v2.7-latest/tex.html

https://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: