Help:Math Help part 7: Difference between revisions

From Amateur Radio Wiki
Jump to navigation Jump to search
(added info as per list)
 
Line 169: Line 169:
:''<nowiki><!-- The \,\! is to keep the formula rendered as PNG instead of HTML.  Please don't remove it.--></nowiki>''
:''<nowiki><!-- The \,\! is to keep the formula rendered as PNG instead of HTML.  Please don't remove it.--></nowiki>''


== Color ==


Equations can use color:
*<code>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</code>
*:<math>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</math>
*<code>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</code>
*:<math>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</math>
See here for [http://oregonstate.edu/%7Epeterseb/tex/samples/docs/color-package-demo.pdf all named colours] supported by LaTeX.
Note that color should not be used as the ''only'' way to identify something because color blind people may not be able to distinguish between the two colors.


== Examples ==
== Examples ==

Revision as of 17:31, 7 March 2008

Please note: Math is not completely enabled yet : some script error?

The complete helpfile is over 50kB in size. Some browsers may have difficulty in rendering the page, because many have a notional upper limit of 32kB per page. Please choose from one of the following options to access the help file:

  • Math Help part 1 - contains information on Syntax, Rendering and Pros and Cons of TeX and HTML for math functions
  • Math Help part 2 - contains information on Functions, Symbols and Special characters
  • Math Help part 3 - contains information on Subscripts, Superscripts and Integrals
  • Math Help part 6 - contains information on Parenthesising big exprssions, Brackets and Bars


This wiki uses a subset of TeX markup, including some extensions from LaTeX and AMS-LaTeX, for mathematical formulae. 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.


Spacing

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

Feature Syntax How it looks rendered
double quad space a \qquad b <math>a \qquad b</math>
quad space a \quad b <math>a \quad b</math>
text space a\ b <math>a\ b</math>
text space without PNG conversion a \mbox{ } b <math>a \mbox{ } b</math>
large space a\;b <math>a\;b</math>
medium space a\>b [not supported]
small space a\,b <math>a\,b</math>
no space ab <math>ab\,</math>
small negative space a\!b <math>a\!b</math>

Align with normal text flow

Due to the default css

img.tex { vertical-align: middle; }

an inline expression like <math>\int_{-N}^{N} e^x\, dx = 2 \sinh N</math> should look good.

If you need to align it otherwise, use <font style="vertical-align:-100%;"><math>...</math></font> and play with the vertical-align argument until you get it right; however, how it looks may depend on the browser and the browser settings.

Also note that if you rely on this workaround, if/when the rendering on the server gets fixed in future releases, as a result of this extra manual offset your formulae will suddenly be aligned incorrectly. So use it sparingly, if at all.

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:

Syntax How it looks rendered
a^{c+2} <math>a^{c+2}</math>
a^{c+2} \, <math>a^{c+2} \,</math>
a^{\,\!c+2} <math>a^{\,\!c+2}</math>
a^{b^{c+2}} <math>a^{b^{c+2}}</math> (WRONG with option "HTML if possible or else PNG"!)
a^{b^{c+2}} \, <math>a^{b^{c+2}} \,</math> (WRONG with option "HTML if possible or else PNG"!)
a^{b^{c+2}}\approx 5 <math>a^{b^{c+2}}\approx 5</math> (due to "<math>\approx</math>" correctly displayed, no code "\,\!" needed)
a^{b^{\,\!c+2}} <math>a^{b^{\,\!c+2}}</math>
\int_{-N}^{N} e^x\, dx <math>\int_{-N}^{N} e^x\, dx</math>


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:

<!-- The \,\! is to keep the formula rendered as PNG instead of HTML. Please don't remove it.-->


Examples

Quadratic Polynomial

<math>ax^2 + bx + c = 0</math>
<math>ax^2 + bx + c = 0</math>

Quadratic Polynomial (Force PNG Rendering)

<math>ax^2 + bx + c = 0\,\!</math>

<math>ax^2 + bx + c = 0\,\!</math>

Quadratic Formula

<math>x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math>

<math>x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math>

Tall Parentheses and Fractions

<math>2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)</math>

<math>2 = \left(
 \frac{\left(3-x\right) \times 2}{3-x}
 \right)</math>
<math>S_{new} = S_{old} + \frac{ \left( 5-T \right) ^2} {2}</math>

<math>S_{new} = S_{old} +
 \frac{ \left( 5-T \right) ^2} {2}</math>

Integrals

<math>\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy</math>

<math>\int_a^x \int_a^s f(y)\,dy\,ds
 = \int_a^x f(y)(x-y)\,dy</math>

Summation

<math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}{3^m\left(m\,3^n+n\,3^m\right)}</math>
<math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
 {3^m\left(m\,3^n+n\,3^m\right)}</math>

Differential Equation

<math>u + p(x)u' + q(x)u=f(x),\quad x>a</math>

<math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math>

Complex numbers

<math>|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)</math>

<math>|\bar{z}| = |z|,
 |(\bar{z})^n| = |z|^n,
 \arg(z^n) = n \arg(z)</math>

Limits

<math>\lim_{z\rightarrow z_0} f(z)=f(z_0)</math>

<math>\lim_{z\rightarrow z_0} f(z)=f(z_0)</math>

Integral Equation

<math>\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</math>

<math>\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</math>

Example

<math>\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}</math>

<math>\phi_n(\kappa) = 
 0.033C_n^2\kappa^{-11/3},\quad
 \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}</math>

Continuation and cases

<math>f(x) = \begin{cases}1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\ 1 - x^2 & 0 < x \le 1\end{cases}</math>

<math>
 f(x) =
 \begin{cases}
 1 & -1 \le x < 0 \\
 \frac{1}{2} & x = 0 \\
 1 - x^2 & 0 < x\le 1
 \end{cases}
 </math>

Prefixed subscript

<math>{}_pF_q(a_1,\dots,a_p;c_1,\dots,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!}</math>

 <math>{}_pF_q(a_1,\dots,a_p;c_1,\dots,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!}</math>