{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#Tutorial Brief\n", "\n", "**Video Tutorial:** https://www.youtube.com/user/roshanRush\n", "\n", "Jupyter has an implementation of markdown language that can be used in in markdown cells to create formatted text and media documentation in your notebook. LaTeX is also implemented to create high quality mathematical typeset.\n", "\n", "#Markdown\n", "\n", "##Headings\n", "\n", "#H1\n", "##H2\n", "###H3\n", "####H4\n", "#####H5\n", "######H6\n", "\n", "**Code:**\n", "```markdown\n", "#H1\n", "##H2\n", "###H3\n", "####H4\n", "#####H5\n", "######H6\n", "```\n", "\n", "##Alternative Headings\n", "\n", "Heading 1\n", "=========\n", "\n", "Heading 2\n", "----------\n", "\n", "**Code:**\n", "```markdown\n", "Heading 1\n", "=========\n", "\n", "Heading 2\n", "---------\n", "```\n", "\n", "##Font Styles\n", "\n", "**Bold Font** or __Bold Font__\n", "\n", "*Italic* or _Italic Font_\n", "\n", "~~Scratched Text~~\n", "\n", "Markdown doesn't support underline. but you can do that using HTML Text\n", "\n", "**Code:**\n", "```markdown\n", "**Bold Font** or __Bold Font__\n", "\n", "*Italic* or _Italic Font_\n", "\n", "~~Scratched Text~~\n", "\n", "Markdown doesn't support underline. but you can do that using HTML Text\n", "```\n", "\n", "##Lists\n", "\n", "- item\n", "- item\n", " - subitem\n", " - subitem\n", "- item\n", "\n", "\n", "1. item\n", "2. item\n", " 1. sub item\n", " 2. sub item\n", "3. item\n", "\n", "**Code:**\n", "```markdown\n", "- item\n", "- item\n", " - subitem\n", " - subitem\n", "- item\n", "\n", "\n", "1. item\n", "2. item\n", " 1. sub item\n", " 2. sub item\n", "3. item\n", "```\n", "\n", "##Links\n", "\n", "http://www.github.com/\n", "\n", "[Github](http://www.github.com/)\n", "\n", "\n", "**Code:**\n", "```\n", "http://www.github.com/\n", "\n", "[Github](http://www.github.com/)\n", "```\n", "\n", "##Images\n", "![Turing's Device](http://www.google.com/logos/2012/turing-doodle-static.jpg \"Alan Turing's 100th Birthday\")\n", "\n", "**Code:**\n", "```markdown\n", "![Turing's Device](http://www.google.com/logos/2012/turing-doodle-static.jpg \"Alan Turing's 100th Birthday\")\n", "```\n", "\n", "##Quotes\n", "\n", "> Why, oh why, Javascript??? Wars, famine, planetary destruction... I guess as a species, we deserve this abomination...\n", ">\n", "> [Fernando Perez](https://twitter.com/fperez_org)\n", "\n", "**Code:**\n", "```\n", "> Why, oh why, Javascript??? Wars, famine, planetary destruction... I guess as a species, we deserve this abomination...\n", ">\n", "> [Fernando Perez](https://twitter.com/fperez_org)\n", "```\n", "\n", "##Horizontal Line\n", "\n", "---\n", "\n", "**Code:**\n", "```markdown\n", "---\n", "```\n", "\n", "##Tables\n", "\n", "| Tables | Are | Cool |\n", "| ------------- |:-------------:| -----:|\n", "| col 3 is | right-aligned | 1600 |\n", "| col 2 is | centered | 12 |\n", "| zebra stripes | are neat | 1 |\n", "\n", "**Code:**\n", "\n", "```\n", "| Tables | Are | Cool |\n", "| ------------- |:-------------:| -----:|\n", "| col 3 is | right-aligned | 1600 |\n", "| col 2 is | centered | 12 |\n", "| zebra stripes | are neat | 1 |\n", "```\n", "\n", "##HTML\n", "\n", "You can render almost any HTML code you like.\n", "\n", "**Code:**\n", "\n", "```\n", "You can render almost any HTML code you like.\n", "```\n", "\n", "##Code\n", "\n", "You can add in line code like this `import numpy as np`\n", "\n", "Or block code:\n", "\n", "Python Code:\n", "```python\n", "x = 5\n", "print \"%.2f\" % x\n", "```\n", "\n", "Java Script Code:\n", "```javascript\n", "x = 5\n", "alert(x);\n", "```\n", "\n", "**Code:**\n", "\n", "
\n",
    "Python Code:\n",
    "```python\n",
    "x = 5\n",
    "print \"%.2f\" % x\n",
    "```\n",
    "\n",
    "Java Script Code:\n",
    "```javascript\n",
    "x = 5\n",
    "alert(x);\n",
    "```\n",
    "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#LaTeX\n", "\n", "**References:**\n", "\n", "- [LaTeX Wiki](http://en.wikibooks.org/wiki/LaTeX/Mathematics)\n", "- [Duke University, Department of Statistical Science](https://stat.duke.edu/resources/computing/latex)\n", "- [Equation Sheet](http://www.equationsheet.com/)\n", "\n", "LaTeX is a large typeset system for scientific documentation which symbols for mathematics, statistics, physics, quantum mechanics, and computer science. It is beyond the scope of this tutorial to cover everything, but we will go over the basics of writing high quality mathematical equations using LaTeX.\n", "\n", "You can use LaTeX in line by like this $y = x^2$ or in block like this $$y = x^2$$\n", "\n", "**Code:**\n", "```markdown\n", "You can use LaTeX in line by like this $y = x^2$ or in block like this $$y = x^2$$\n", "```\n", "\n", "##Operators:\n", "\n", "- Add:\n", " - $x + y$\n", "- Subtract:\n", " - $x - y$\n", "- Multiply\n", " - $x * y$\n", " - $x \\times y$ \n", " - $x . y$ \n", "- Divide\n", " - $x / y$\n", " - $x \\div y$\n", " - $\\frac{x}{y}$\n", "\n", "**Code:**\n", "```markdown\n", "- Add:\n", " - $x + y$\n", "- Subtract:\n", " - $x - y$\n", "- Multiply\n", " - $x * y$\n", " - $x \\times y$ \n", " - $x . y$ \n", "- Divide\n", " - $x / y$\n", " - $x \\div y$\n", " - $\\frac{x}{y}$\n", "```\n", "\n", "##Relations\n", "\n", "- $\\pi \\approx 3.14159$\n", "- ${1 \\over 0} \\neq \\inf$\n", "- $0 < x > 1$\n", "- $0 \\leq x \\geq 1$\n", "\n", "**Code:**\n", "```\n", "- $\\pi \\approx 3.14159$\n", "- ${1 \\over 0} \\neq \\inf$\n", "- $0 < x > 1$\n", "- $0 \\leq x \\geq 1$\n", "```\n", "\n", "##Fractions\n", "\n", "- $^1/_2$\n", "- $\\frac{1}{2x}$\n", "- ${3 \\over 4}$\n", "\n", "\n", "**Code:**\n", "```\n", "- $^1/_2$\n", "- $\\frac{1}{2x}$\n", "- ${3 \\over 4}$\n", "```\n", "\n", "##Greek Alphabet\n", "\n", "| Small Letter | Capical Letter | Alervative |\n", "| --------------------- | -------------------- | --------------------------- |\n", "| $\\alpha$ `\\alpha` | $A$ `A` | |\n", "| $\\beta$ `\\beta` | $B$ `B` | |\n", "| $\\gamma$ `\\gamma` | $\\Gamma$ `\\Gamma` | |\n", "| $\\delta$ `\\delta` | $\\Delta$ `\\Delta` | |\n", "| $\\epsilon$ `\\epsilon` | $E$ `E` | $\\varepsilon$ `\\varepsilon` |\n", "| $\\zeta$ `\\zeta` | $Z$ `Z` | |\n", "| $\\eta$ `\\eta` | $H$ `H` | |\n", "| $\\theta$ `\\theta` | $\\Theta$ `\\Theta` | $\\vartheta$ `\\vartheta` |\n", "| $\\iota$ `\\zeta` | $I$ `I` | |\n", "| $\\kappa$ `\\kappa` | $K$ `K` | $\\varkappa$ `\\varkappa` |\n", "| $\\lambda$ `\\lambda` | $\\Lambda$ `\\Lambda` | |\n", "| $\\mu$ `\\mu` | $M$ `M` | |\n", "| $\\nu$ `\\nu` | $N$ `N` | |\n", "| $\\xi$ `\\xi` | $Xi$ `\\Xi` | |\n", "| $\\omicron$ `\\omicron` | $O$ `O` | |\n", "| $\\pi$ `\\pi` | $\\Pi$ `\\Pi` | $\\varpi$ `\\varpi` |\n", "| $\\rho$ `\\rho` | $P$ `P` | $\\varrho$ `\\varrho` |\n", "| $\\sigma$ `\\sigma` | $\\Sigma$ `\\Sigma` | $\\varsigma$ `\\varsigma` |\n", "| $\\tau$ `\\tau` | $T$ `T` | |\n", "| $\\upsilon$ `\\upsilon` | $\\Upsilon$ `\\Upsilon`| |\n", "| $\\phi$ `\\phi` | $\\Phi$ `\\Phi` | $\\varphi$ `\\varphi` |\n", "| $\\chi$ `\\chi` | $X$ `X` | |\n", "| $\\psi$ `\\psi` | $\\Psi$ `\\Psi` | |\n", "| $\\omega$ `\\omega` | $\\Omega$ `\\Omega` | |\n", "\n", "##Power & Index\n", "\n", "You can add power using the carrot `^` symbol. If you have more than one character you have to enclose them in a curly brackets.\n", "\n", " $$f(x) = x^2 - x^{1 \\over \\pi}$$\n", "\n", "For index you can use the underscore symbol:\n", "\n", "$$f(X,n) = X_n + X_{n-1}$$\n", "\n", "**Code:**\n", "```markdown\n", "$$f(x) = x^2 - x^{1 \\over \\pi}$$\n", "$$f(X,n) = X_n + X_{n-1}$$\n", "\n", "```\n", "\n", "##Roots & Log\n", "\n", "You can express a square root in LaTeX using the `\\sqrt` and to change the level of the root you can use `\\sqrt[n]` where `n` is the level of the root.\n", "\n", "$$f(x) = \\sqrt[3]{2x} + \\sqrt{x-2}$$\n", "\n", "To represent a log use `\\log[base]` where `base` is the base of the logarithmic term.\n", "\n", "$$\\log[x] x = 1$$\n", "\n", "**Code:**\n", "```markdown\n", "$$f(x) = \\sqrt[3]{2x} + \\sqrt{x-2}$$\n", "```\n", "\n", "##Sums & Products\n", "\n", "You can represent a sum with a sigma using `\\sum\\limits_{a}^{b}` where a and b are the lower and higher limits of the sum.\n", "\n", "$$\\sum\\limits_{x=1}^{\\infty} {1 \\over x} = 2$$\n", "\n", "Also you can represent a product with `\\prod\\limits_{a}^{a}` where a and b are the lower and higher limits.\n", "\n", "$$\\prod\\limits_{i=1}^{n} x_i - 1$$\n", "\n", "**Code:**\n", "```\n", "$$\\sum\\limits_{x=1}^{\\infty} {1 \\over x} = 2$$\n", "$$\\prod\\limits_{i=1}^{n} x_i - 1$$\n", "```\n", "\n", "##Statistics\n", "\n", "To represent basic concepts in statistics about sample space `S`, you can represent a maximum:\n", "\n", "$$max(S) = \\max\\limits_{i: S_i \\in S} S_i$$\n", "\n", "In the same way you can get the minimum:\n", "\n", "$$min(S) = \\min\\limits_{i: S_i \\in S} S_i$$\n", "\n", "To represent a [binomial coefficient](http://en.wikipedia.org/wiki/Binomial_coefficient) with n choose k, use the following:\n", "\n", "$$\\frac{n!}{k!(n-k)!} = {n \\choose k}$$\n", "\n", "for :\n", "\n", "**Code:**\n", "```\n", "$$max(S) = \\max\\limits_{i: x_i \\in \\{S\\}} x_i$$\n", "$$min (S) = \\min\\limits_{i: x_i \\in \\{S\\}} x_i$$\n", "$$\\frac{n!}{k!(n-k)!} = {n \\choose k}$$\n", "```\n", "\n", "##Calculus\n", "\n", "Limits are represented using `\\lim\\limits_{x \\to a}` as `x` approaches `a`.\n", "\n", "$$\\lim\\limits_{x \\to 0^+} {1 \\over 0} = \\infty$$\n", "\n", "For integral equations use `\\int\\limits_{a}^{b}` where `a` and `b` are the lower and higher limits.\n", "\n", "$$\\int\\limits_a^b 2x \\, dx$$\n", "\n", "\n", "**Code:**\n", "```markdown\n", "$$\\lim\\limits_{x \\to 0^+} {1 \\over 0} = \\inf$$\n", "$$\\int\\limits_a^b 2x \\, dx$$\n", "```\n", "\n", "##Function definition over periods\n", "\n", "Defining a function that is calculated differently over a number of period can done using LaTeX. There are a few tricks that we will use to do that:\n", "\n", "- The large curly bracket `\\left\\{ ... \\right.` Notice it you want to use `(` or `[` you don't have to add a back slash(`\\`). You can also place a right side matching bracket by replacing the `.` after `\\right` like this `.right}`\n", "- Array to hold the definitions in place. it has two columns with left alignment. `\\begin{array}{ll} ... \\end{array}`\n", "- Line Breaker `\\\\`\n", "- Text alignment box ` \\mbox{Text}`\n", "\n", "$f(x) =\\left\\{\\begin{array}{ll}0 & \\mbox{if } x = 0 \\\\{1 \\over x} & \\mbox{if } x \\neq 0\\end{array}\\right.$\n", "\n", "**Code:**\n", "```\n", "$f(x) =\n", "\\left\\{\n", "\t\\begin{array}{ll}\n", "\t\t0 & \\mbox{if } x = 0 \\\\\n", "\t\t{1 \\over x} & \\mbox{if } x \\neq 0\n", "\t\\end{array}\n", "\\right.$\n", "```\n", "\n", "**Note:** If you are planning to show your notebook in NBViewer write your latex code in one line. For example you can write the code above like this:\n", "\n", "```\n", "$f(x) =\\left\\{\\begin{array}{ll}0 & \\mbox{if } x = 0 \\\\{1 \\over x} & \\mbox{if } x \\neq 0\\end{array}\\right.$\n", "```\n", "\n", "#Quick Quiz (Normal Distribution)\n", "\n", "Try to replicate the [Normal Distribution](http://en.wikipedia.org/wiki/Normal_distribution) formula using LaTeX. If you solve it, leave the LaTeX code in the comments below. $Don't\\ cheat$.\n", "\n", "$$P(x,\\sigma,\\mu) = \\frac{1}{{\\sigma \\sqrt {2\\pi } }}e^{{-(x - \\mu)^2 } / {2\\sigma ^2}}$$\n", "\n", "Tips to help with the quiz:\n", "\n", "- $\\mu$ is `\\mu`\n", "- $\\sigma$ is `\\sigma`\n", "- $e$ is `e`" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }