CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Site Help, Feedback & Discussions (http://www.cfd-online.com/Forums/site-help-feedback-discussions/)
-   -   Guide: Writing Equations in LaTeX on the CFD Online Forums (http://www.cfd-online.com/Forums/site-help-feedback-discussions/62625-guide-writing-equations-latex-cfd-online-forums.html)

pete March 15, 2009 16:58

Guide: Writing Equations in LaTeX on the CFD Online Forums
 
This is a brief introduction about how to write equations in the CFD Online discussion forums. The equation functionality is based on LaTeX, a versatile mathematical typesetting system which is often used to write scientific papers and books. With LaTeX mathematical equations are written using normal text and this makes it very suitable for a text-based forum like this. The forum will automatically generate images of the LaTeX codes it finds and display them properly. LaTeX often gives very nice looking formulas. LaTeX can be a bit difficult to get started with, but those who know it tend to like it very much. Here is a simple example to illustrate how it works:
  • If you in your message write: [math]a = \sqrt{\gamma R T}[/math]

  • The forum will display: a = \sqrt{\gamma R T}
A usefull feature in the forum is that the LaTeX code used to write an equation can be seen when you hoover with the pointer over it. If you click on an equation a window will be opened displaying the LaTeX code used to write it. This makes it easy to learn from other people and to copy-and-paste equations from other posts.

You can see how all equations on this page have been written either by hoovering over them with the pointer or by clicking on them!

LaTeX can be used in two ways:
  • Normal equations written separately away from normal text: [math]LaTeX code[/math]

  • Inlined equations or symbols to be used inside a text: [imath]LaTeX code[/imath]
The difference is that inlined equations are scaled to fit better in normal text whereas normal equations are scaled to look good when written separately.

There is a special LaTeX reference tool avalable in the advanced editor which helps you to find the codes needed to write symbols, relations, operators etc. in LaTeX. To open the LaTeX reference click on the \sum symbol to the right just above the editor window.

Below follows a summary of the most commonly used symbols, relations, operators and functions as well as a few other frequently asked questions. To see how these symbols or equations were created just click on the one you are interested in and a window will be opened showing the code used to create it:


Symbols

Lowercase Greek letters: \alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega

Capital Greek letters: \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega

Operators and relations: \pm \mp \times \div \ast \star \bullet \circ \cdot \leq \ll \subset \geq \gg \equiv \sim \simeq \approx \neq \propto

Misc: \leftarrow \Leftarrow \rightarrow \Rightarrow \leftrightarrow \Leftrightarrow \forall \exists \partial \infty


Bracketing - () {} []

You can simply write the brackets you want. To get the correct size of the brackets you sometimes have to use the \left and \right keywords in front of the bracket.
For example, just writing parentheses gives (\frac{1}{2})^{n}, but with \left and \right keywords you would get \left(\frac{1}{2}\right)^{n}.


Exponents and Subscripts

a_i^n - [math]a_i^n[/math]

x_{i+1}^{2^{n+1}} - [math]x_{i+1}^{2^{n+1}}[/math]


Functions - Fractions, Radicals, Integrals, Sums, Limits, ...

\frac{1}{2} - [math]\frac{1}{2}[/math]

\sqrt{x+y} - [math]\sqrt{x+y}[/math]

\sqrt[n]{x} - [math]\sqrt[n]{x}[/math]

\int^\infty_0 f(x) \, dx - [math]\int^\infty_0 f(x) \, dx[/math]

\oint_\Gamma f(x) \, ds - [math]\oint_\Gamma f(x) \, ds[/math]

\sum_{i=1}^{\infty}\frac{1}{i} - [math]\sum_{i=1}^{\infty}\frac{1}{i}[/math]

\lim_{x\to\infty}\frac{1}{x} - [math]\lim_{x\to\infty}\frac{1}{x}[/math]


Trigonometric and Logarithmic Functions

Please use these instead of simply typing in "sin". That ensures that the function is typeset properly with the right font and spacing.

\cos^2 x + \sin^2 x = 1 - [math]\cos^2 x + \sin^2 x = 1[/math]

\tanh(c) - [math]\tanh(c)[/math]

\log n^2 - [math]\log n^2[/math]

\ln(e) - [math]\ln(e)[/math]


Spacing

Sometime you may want to add extra horizontal space between characters. The following codes can be used to add extra space:
  • a whitespace or no space at all gives a normal space (\alpha \beta)
  • \quad - a large space to separate equations or write conditions (i = 1, 2, 3) on the same line (\alpha \quad \beta)
  • \; - a thick space (\alpha \; \beta)
  • \: - a medium space (\alpha \: \beta)
  • \, - a thin space (\alpha \, \beta)
  • \! - a negative thin space (\alpha \! \beta)
Fluid Dynamics and CFD Related Examples
  • Navier-Stokes Equations using Tensor Notation:
\frac{\partial \rho}{\partial t} +
\frac{\partial}{\partial x_j}\left[ \rho u_j \right] = 0

\frac{\partial}{\partial t}\left( \rho u_i \right) +
\frac{\partial}{\partial x_j}
\left[ \rho u_i u_j + p \delta_{ij} - \tau_{ji} \right] = 0, \quad i=1,2,3

\frac{\partial}{\partial t}\left( \rho e_0 \right) +
\frac{\partial}{\partial x_j}
\left[ \rho u_j e_0 + u_j p + q_j - u_i \tau_{ij} \right] = 0
  • \bf{k - \epsilon} Equations:
\frac{\partial}{\partial t} (\rho k) + \frac{\partial}{\partial x_i} (\rho k u_i) = \frac{\partial}{\partial x_j} \left[ \left(\mu + \frac{\mu_t}{\sigma_k} \right) \frac{\partial k}{\partial x_j}\right] + P_k + P_b - \rho \epsilon - Y_M + S_k

\frac{\partial}{\partial t} (\rho \epsilon) + \frac{\partial}{\partial x_i} (\rho \epsilon u_i) = \frac{\partial}{\partial x_j} \left[\left(\mu + \frac{\mu_t}{\sigma_{\epsilon}} \right) \frac{\partial \epsilon}{\partial x_j} \right] + C_{1 \epsilon}\frac{\epsilon}{k} \left( P_k + C_{3 \epsilon} P_b \right) - C_{2 \epsilon} \rho \frac{\epsilon^2}{k} + S_{\epsilon}
  • Reynolds Averaging:
\overline{\Phi} \equiv \frac{1}{T} \int_T \Phi(t) dt

\Phi' \equiv \Phi - \overline{\Phi}
  • Boussinesq Eddy Viscosity Assumption:
\tau_{ij} = 2 \, \mu_t \, S_{ij}^* - \frac{2}{3} k \delta_{ij} , or written more explicitly:

-\rho \overline{u'_i u'_j} = \mu_t \, \left( \frac{\partial u_i}{\partial x_j} + \frac{\partial u_j}{\partial x_i} - \frac{2}{3} \frac{\partial u_k}{\partial x_k} \delta_{ij} \right) - \frac{2}{3} k \delta_{ij}
  • Rhie-Chow Interpolation:
a_p \vec v_P = \sum\limits_{neighbours} {a_l } \vec v_l - \frac{\nabla p}{V}

\sum\limits_{faces} \left[ {\frac{1}{a_p}\,H} \right]_{face} = \sum\limits_{faces} \left[ {\frac{1}{a_p }\,\frac{{\nabla p}}{V}} \right]_{face}

H = \sum\limits_{neighbours} {a_l } \vec v_l
  • Realisability and Schwarz' Inequality:
\left\langle{u'_\alpha u'_\alpha}\right\rangle \geq 0

\frac{\left\langle{u'_\alpha u'_\beta}\right\rangle}{ \left\langle{u'_\alpha u'_\beta}\right\rangle \left\langle{u'_\alpha u'_\beta}\right\rangle} \leq 1

lordmohit October 30, 2009 03:51

test
 
c=sqrt(a^2 + b^2) testing

lordmohit October 30, 2009 04:03

\lim_{x\to\infty}\frac{1}{x}

lim_{xtoinfty}frac{1}{x-1}

lordmohit October 30, 2009 04:04

\int^\infty_0 f(x) \, dx

lordmohit October 30, 2009 04:06

\int^\frac{\Pi}{2}_5 f(x) \, dx

ComputerGuy December 31, 2010 02:03

Useful website for generating LaTeX equations
 
Enjoy: http://www.codecogs.com/latex/eqneditor.php

ComputerGuy

Sha Liu November 6, 2011 23:56

cool. i often use mathematica to write equations. then they can be transform to latex form.

stefanbj April 14, 2013 17:11

test test

\frac{1}{2}

abbott.hn May 2, 2013 23:15

let me have a try:
-\frac{1}{2}\rho\overline{u'_i u'_j}+\overline{p' u'_j}=\frac{\mu_t}{\sigma_k}\frac{\partial k}{\partial x_j}

and this " -\frac{1}{2}\rho\overline{u'_i u'_j}+\overline{p' u'_j}=\frac{\mu_t}{\sigma_k}\frac{\partial k}{\partial x_j} "inline equation

sharonyue June 4, 2013 21:49

test

a = \sqrt{\gamma R T}

jimbean October 24, 2013 13:58

test

\frac{\partial c} {\partial t} + \nabla . ({\vec u - u_s \frac{\vec g} {| g |}}) c=\nabla . ( {\nu_t \nabla c} )



Betta May 6, 2014 22:18

why can't I use \^{\circ}C?

Betta May 6, 2014 22:22

Quote:

Originally Posted by Betta (Post 490228)
why can't I use \^{\circ}C?

sorry. it works now.
^{\circ}C


All times are GMT -4. The time now is 05:37.