Help:Fractions and functions

= Fractions =

Fractions sometimes occur in regular text, and need proper presentation. Only a limited number are covered in the UTF-8 repertoire: they are ¼ ½ ¾ ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞

A number of these fractions have been added to the characters bar at the bottom of the edit page. The remainder have been left off since they do not render in the font used for Wikisource. They will appear here if your computer has Lucida Sans Unicode. They are overlarge compared with the regular font size.

Other fractions can be done with keyboard figures (like 11/16, 27/32, et cetera), but they are intrusive, being overlarge. More elegant fractions can be made by HTML coding, such as using the superscript/subscript markup.

Thus, 11 / 16 will be displayed by

Template:frac will produce $11/16$;

fits inline:

Template:sfrac will produce vertical fractions fitting in with the Mediawiki typeface. Ex. $11/16$, $11/16$;

fits inline:

Fractions can also be made with the TeX, but they do not match the Mediawiki typeface.

= Functions =

Functions are rendered in Mediawiki by a version of TeX. The following text is from Meta-Wiki.

TeX
MediaWiki uses a subset of TeX markup for mathematical formulae. See MediaWiki math markup

It generates either PNG images or simple HTML markup, depending on user preferences and the complexity of the expression. In the future, as more browsers are smarter, it will be able to generate enhanced HTML or even MathML in many cases.

(More precisely, MediaWiki filters the markup through Texvc, which in turn passes the commands to TeX for the actual rendering. Thus, only a limited part of the full TeX language is supported; see below for details.)

Math markup goes inside  $$ ... $$ . The edit toolbar has a button for this.

MediaWiki templates, variables and parameters cannot be used within math tags, see Demo of attempt to use parameters within TeX.

The PNG images are black on white (not transparent). These colors, as well as font sizes and types, are independent of browser settings or css. Font sizes and types will often deviate from what HTML renders. The css selector of the images is img.tex.

In the case of a non-white page background, the white background of the formula effectively highlights it, which can be an advantage or a disadvantage.

One may want to avoid using TeX markup as part of a line of regular text, as the formulae don't align properly and the font size, as said, usually does not match.

The alt attribute of the TeX images (the text that is displayed if your browser can't display images; Internet Explorer even shows it up in the hover box) is the wikitext that produced them, excluding the $$ and $$.

Discussion, bug reports and feature requests should go to the Wikitech-l mailing list. These can also be filed on Mediazilla under MediaWiki extensions.

General
Spaces and newlines are mostly ignored. Apart from function and operator names, as is customary in mathematics for variables, letters are in italics; digits are not. For other text, (like variable labels) to avoid being rendered in italics like variables, use  or  :   gives $$\mbox{abc}$$

Line breaks help keep the wikitext clear, for instance, a line break after each term or matrix row.

Size
There are some possibilities, to change the size of the formulas. For example, fractions can be made smaller using  instead of. $\frac{10}{100}$ becomes $\tfrac{10}{100}$. In general, formulas can be made even smaller if  is employed: $\sqrt{1-\frac{v^{2}}{c^{2}}}$ becomes $\scriptstyle \sqrt{1-\frac{v^{2}}{c^{2}}}$.|undefined

Functions, symbols, special characters
For producing special characters without math tags, see m:Help:Special characters.

Comparison:
 * gives "α"
 * gives $$\alpha$$,
 * ("" and "" vs. "", in this case the same code word "");
 * gives "√2"
 * gives $$\sqrt{2}$$
 * (the same difference as above, but also another code word, "" vs. ""; in TeX braces);
 * gives √(1-e²),
 * gives $$\sqrt{1-e^2}$$,
 * (parentheses vs. braces, "" vs. "", "" vs. "").

Parenthesizing big expressions, brackets, bars
You can use various delimiters with \left and \right:

Spacing
Note that TeX automatically handles most spacing, but you may sometimes want manual control.

Align with normal text flow
Due to the default css

img.tex { vertical-align: middle; }

an inline expression like $$\int_{-N}^{N} e^x\, dx$$ should look good.

If you need to align it otherwise, use and play with the  argument until you get it right; however, how it looks may depend on the browser and the browser settings.

Forced PNG rendering
To force the formula to render as PNG, add (small space) at the end of the formula (where it is not rendered). This will force PNG if the user is in "HTML if simple" mode, but not for "HTML if possible" mode (math rendering settings in preferences).

You can also use (small space and negative space, which cancel out) anywhere inside the math tags. This does force PNG even in "HTML if possible" mode, unlike.

This could be useful to keep the rendering of formulae in a proof consistent, for example, or to fix formulae that render incorrectly in HTML (at one time, a^{2+2} rendered with an extra underscore), or to demonstrate how something is rendered when it would normally show up as HTML (as in the examples above).

For instance:

This has been tested with most of the formulae on this page, and seems to work perfectly.

You might want to include a comment in the HTML so people don't "correct" the formula by removing it:



Additional help sources

 * Editing a Wiki page
 * Displaying a formula on a Wiki page
 * Sample TeX equations

Quadratic Polynomial
$$x_1 = a^2 + b^2 + c^2$$ $$x_1 = a^2 + b^2 + c^2 $$

Quadratic Formula
$$x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$ $$x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$

Parentheses and fractions
$$\left(3-x\right) \times \left( \frac{2}{3-x} \right) = \left(3-x\right) \times \left( \frac{3}{2-x} \right)$$ $$\left(3-x\right) \times \left( \frac{2}{3-x} \right) = \left(3-x\right) \times \left( \frac{3}{2-x} \right)$$

Tall Parentheses and fractions
$$2 = \left( \frac{\left(3-x\right) \times 3}{2-x} \right)$$ $$2 = \left( \frac{\left(3-x\right) \times 3}{2-x} \right)$$

Force Rendering
$$4-2x = 9-3x \!$$ $$4-2x = 9-3x \!$$

Force Rendering
$$-2x+3x = 9-4 \!$$ $$-2x+3x = 9-4 \!$$

Integrals
$$\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x (y)(x-y)\,dy\,$$ $$\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy\,$$

Summation
$$\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}{3^m\left(m\,3^n+n\,3^m\right)}$$ $$\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n} {3^m\left(m\,3^n+n\,3^m\right)}$$

Differential Equation
$$u'' + p(x)u' + q(x)u=f(x),\,\,\,x>a$$ $$u'' + p(x)u' + q(x)u=f(x),\,\,\,x>a$$

Example
$$|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,$$ $$|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,$$

Limits
$$\lim_{z\rightarrow z_0} f(z)=f(z_0)\,$$ $$\lim_{z\rightarrow z_0} f(z)=f(z_0)\,$$

Integral Equation
$$\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR\,$$ $$\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR\,$$

Example
$$\int_0^\infty x^\alpha \sin(x)\,dx = 2^\alpha \sqrt{\pi}\, \frac{\Gamma(\frac{\alpha}{2}+1)}{\Gamma(\frac{1}{2}-\frac{\alpha}{2})}\,$$ $$\int_0^\infty x^\alpha \sin(x)\,dx = 2^\alpha \sqrt{\pi}\, \frac{\Gamma(\frac{\alpha}{2}+1)}{\Gamma(\frac{1}{2}-\frac{\alpha}{2})}\,$$

Example
$$\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\,\,\,\frac{1}{L_0}<\!\!<\kappa<\!\!<\frac{1}{l_0}\,$$ $$\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\,\,\,\frac{1}{L_0}<\!\!<\kappa<\!\!<\frac{1}{l_0}\,$$

Example
$$f(x) = {a_0\over 2} + \sum_{n=1}^\infty a_n\cos\left({2n\pi x \over T}\right) + b_n\sin\left({2n\pi x\over T}\right)\,$$ $$f(x) = {a_0\over 2} + \sum_{n=1}^\infty a_n\cos\left({2n\pi x \over T}\right) + b_n\sin\left({2n\pi x\over T}\right)\,$$

Continuation and cases
$$f(x) = \begin{cases}1 & -1 \le x < 0\\ \frac{1}{2} & x = 0\\x&0<x\le 1\end{cases}$$ f(x) = \begin{cases}1 & -1 \le x < 0\\ \frac{1}{2} & x = 0\\x&0<x\le 1\end{cases}

Example
$$\Gamma(z) = \int_0^\infty e^{-t} t^{z-1} \,dt\,$$ $$\Gamma(z) = \int_0^\infty e^{-t} t^{z-1} \,dt\,$$

Example
$$J_p(z) = \sum_{k=0}^\infty \frac{(-1)^k\left(\frac{z}{2}\right)^{2k+p}}{k!\Gamma(k+p+1)}\,$$ $$J_p(z) = \sum_{k=0}^\infty \frac{(-1)^k\left(\frac{z}{2}\right)^{2k+p}}{k!\Gamma(k+p+1)}\,$$

Example
$${}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty \frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,$$ $${}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty \frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,$$

Gamma Function
$$\Gamma(n+1) = n \Gamma(n), \; n>0$$ $$\Gamma(n+1) = n \Gamma(n), \; n>0$$

Example
$$\int_0^1 \frac{1}{\sqrt{-\ln x}} dx\,$$ $$\int_0^1 \frac{1}{\sqrt{-\ln x}} dx\,$$

Example
$$\int_0^\infty e^{-st}t^{x-1}\,dt,\ s>0\,$$ $$\int_0^\infty e^{-st}t^{x-1}\,dt,\ s>0\,$$

Example
$$B(u) = \sum_{k=0}^N {P_k}{N! \over k!(N - k)!}{u^k}(1 - u)^{N-k}\,$$ $$B(u) = \sum_{k=0}^N {P_k}{N! \over k!(N - k)!}{u^k}(1 - u)^{N-k}\,$$

Example
$$u(x,y) = \frac{1}{\sqrt{2\pi}}\int_0^\infty f(\xi)\left[g(|x+\xi|,y)+g(|x-\xi|,y)\right]\,d\xi\,$$ $$u(x,y) = \frac{1}{\sqrt{2\pi}}\int_0^\infty f(\xi)\left[g(|x+\xi|,y)+g(|x-\xi|,y)\right]\,d\xi\,$$