CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Site Help, Feedback & Discussions (
-   -   Guide: Writing Equations in LaTeX on the CFD Online Forums (

pete March 15, 2009 14: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:


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]


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 01:51

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

lordmohit October 30, 2009 02:03



lordmohit October 30, 2009 02:04

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

lordmohit October 30, 2009 02:06

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

ComputerGuy December 31, 2010 01:03

Useful website for generating LaTeX equations


Sha Liu November 6, 2011 22:56

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

stefanbj April 14, 2013 16:11

test test

\frac{1}{2} May 2, 2013 22: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 20:49


a = \sqrt{\gamma R T}

jimbean October 24, 2013 12:58


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

Betta May 6, 2014 21:18

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

Betta May 6, 2014 21:22


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

sorry. it works now.

babakflame December 9, 2014 06:38

k_Sgs= \left(\frac{\mu_Sgs}{\rho \, C_s \, \Delta}\right)^{2}

C_s= 0.1

Gary51075607 January 26, 2015 09:21

{\nabla \bullet \left( \rho c_p \vec u T \right)}={\nabla \bullet \left( \lambda_{e f f} \nabla T \right)}  + T {\nabla \bullet \left( \rho c_p \vec u \right)} - \frac{T}{\rho} \left( \frac{\partial \rho}{\partial t} \right)_p \vec u \bullet {\nabla p}

Jerry L.D. Cheng January 29, 2015 20:51

Just to have a try
\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

flowAlways May 25, 2015 13:49

O + N_2 \rightleftharpoons  N + NO

DA6righthand June 13, 2015 10:18

I cannot figure this out. Where is my syntax error?

\alpha\frac{\partial^2x}{\partial \xi^2}-2\beta \frac{\partial ^2x}{\partial \xi \partial \eta}+\gamma \frac{\partial ^2x}{\partial\eta^2}=0

Here's what I typed between the bracketed math and /math:

\alpha\frac{\partial^2x}{\partial \xi^2}-2\beta \frac{\partial ^2x}{\partial \xi \partial \eta}+\gamma \frac{\partial ^2x}{\partial\eta^2}=0

\alpha\frac{\partial^2y}{\partial\xi^2}-2\beta\frac{\partial^2y}{\partial\xi\partial\eta}+ \gamma\frac{\partial^2y}{\partial\eta^2}=0

Here the images of what displays on the online eqn editor:\eta^2}=0\eta^2}=0

I don't understand why I'm getting an error on the forum. It's frustrating.

pete June 15, 2015 16:39

Seems like the LaTeX functionality is broken after the server move on June 5. We will investigate and post a message in this thread once LaTeX is working again.

DA6righthand June 15, 2015 16:58


Originally Posted by pete (Post 550474)
Seems like the LaTeX functionality is broken after the server move on June 5. We will investigate and post a message in this thread once LaTeX is working again.

Thanks! I ended up posting equations as images obtained from the online LaTeX editor on but I found out I can post a maximum of 10 images.

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