CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > CFD Online Community > Site Help, Feedback & Discussions

Guide: Writing Equations in LaTeX on the CFD Online Forums

Register Blogs Community New Posts Updated Threads Search

Like Tree24Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 15, 2009, 15:58
Default Guide: Writing Equations in LaTeX on the CFD Online Forums
  #1
Administrator
 
pete's Avatar
 
Peter Jones
Join Date: Jan 2009
Posts: 682
Rep Power: 10
pete will become famous soon enough
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
pete is offline   Reply With Quote

Old   October 30, 2009, 02:51
Default test
  #2
New Member
 
Mohit Madan
Join Date: Oct 2009
Posts: 4
Rep Power: 17
lordmohit is on a distinguished road
c=sqrt(a^2 + b^2) testing
lordmohit is offline   Reply With Quote

Old   October 30, 2009, 03:03
Default
  #3
New Member
 
Mohit Madan
Join Date: Oct 2009
Posts: 4
Rep Power: 17
lordmohit is on a distinguished road
\lim_{x\to\infty}\frac{1}{x}

lim_{xtoinfty}frac{1}{x-1}
lordmohit is offline   Reply With Quote

Old   October 30, 2009, 03:04
Default
  #4
New Member
 
Mohit Madan
Join Date: Oct 2009
Posts: 4
Rep Power: 17
lordmohit is on a distinguished road
\int^\infty_0 f(x) \, dx
lordmohit is offline   Reply With Quote

Old   October 30, 2009, 03:06
Default
  #5
New Member
 
Mohit Madan
Join Date: Oct 2009
Posts: 4
Rep Power: 17
lordmohit is on a distinguished road
\int^\frac{\Pi}{2}_5 f(x) \, dx
chloegirly likes this.
lordmohit is offline   Reply With Quote

Old   December 31, 2010, 02:03
Default Useful website for generating LaTeX equations
  #6
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Enjoy: http://www.codecogs.com/latex/eqneditor.php

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   November 6, 2011, 23:56
Default
  #7
New Member
 
Sha Liu
Join Date: Nov 2011
Posts: 1
Rep Power: 0
Sha Liu is on a distinguished road
cool. i often use mathematica to write equations. then they can be transform to latex form.
Sha Liu is offline   Reply With Quote

Old   April 14, 2013, 17:11
Default
  #8
New Member
 
Stefan Bjornsson
Join Date: Apr 2013
Posts: 7
Rep Power: 13
stefanbj is on a distinguished road
test test

\frac{1}{2}
stefanbj is offline   Reply With Quote

Old   May 2, 2013, 23:15
Default
  #9
New Member
 
zdong
Join Date: Aug 2011
Posts: 15
Rep Power: 15
abbott.hn is on a distinguished road
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
abbott.hn is offline   Reply With Quote

Old   June 4, 2013, 21:49
Default
  #10
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 849
Rep Power: 18
sharonyue is on a distinguished road
test

a = \sqrt{\gamma R T}
sharonyue is offline   Reply With Quote

Old   October 24, 2013, 13:58
Default
  #11
New Member
 
Zhengbing
Join Date: Apr 2013
Posts: 20
Rep Power: 13
jimbean is on a distinguished road
test

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


jimbean is offline   Reply With Quote

Old   May 6, 2014, 22:18
Default
  #12
New Member
 
Betta Hwang
Join Date: May 2014
Posts: 6
Rep Power: 12
Betta is on a distinguished road
why can't I use \^{\circ}C?
Betta is offline   Reply With Quote

Old   May 6, 2014, 22:22
Default
  #13
New Member
 
Betta Hwang
Join Date: May 2014
Posts: 6
Rep Power: 12
Betta is on a distinguished road
Quote:
Originally Posted by Betta View Post
why can't I use \^{\circ}C?
sorry. it works now.
^{\circ}C
Betta is offline   Reply With Quote

Old   December 9, 2014, 07:38
Default
  #14
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
k_Sgs= \left(\frac{\mu_Sgs}{\rho \, C_s \, \Delta}\right)^{2}

C_s= 0.1

Last edited by babakflame; December 9, 2014 at 08:44.
babakflame is offline   Reply With Quote

Old   January 26, 2015, 10:21
Default
  #15
New Member
 
Join Date: Jan 2015
Posts: 14
Rep Power: 11
Gary51075607 is on a distinguished road
{\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}

Last edited by Gary51075607; January 26, 2015 at 22:01.
Gary51075607 is offline   Reply With Quote

Old   January 29, 2015, 21:51
Default
  #16
New Member
 
Join Date: Jan 2015
Location: Shanghai,China
Posts: 13
Rep Power: 11
Jerry L.D. Cheng is on a distinguished road
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
Jerry L.D. Cheng is offline   Reply With Quote

Old   May 25, 2015, 14:49
Default
  #17
New Member
 
Ali Kadar
Join Date: Oct 2014
Location: Delft
Posts: 25
Rep Power: 12
flowAlways is on a distinguished road
O + N_2 \rightleftharpoons  N + NO
__________________
A good solution is one which does justice to the inner nature of the problem- Cornelius Lanczos in a letter to Albert Einstein on March 9, 1947

Last edited by flowAlways; May 25, 2015 at 18:42.
flowAlways is offline   Reply With Quote

Old   June 13, 2015, 11:18
Default
  #18
New Member
 
Justin
Join Date: Jan 2015
Posts: 28
Rep Power: 11
DA6righthand is on a distinguished road
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
\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'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 codehogs.com online eqn editor:





I don't understand why I'm getting an error on the forum. It's frustrating.
DA6righthand is offline   Reply With Quote

Old   May 22, 2018, 12:35
Default
  #19
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
In the liquid gas interface

\dot{q}={\left.k\frac{\partial{}T}{\partial{}n}\right]}_g-{\left.k\frac{\partial{}T}{\partial{}n}\right]}_l   \ \ \ \ (eq.4)

u_{g,n}-u_{l,n}=\dot{m\ \ \ }(\frac{1}{{\rho{}}_g}-\frac{1}{{\rho{}}_l})\ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (eq.2)
\dot{m}=\ -\frac{K}{L}\frac{\partial{}T}{\partial{}n}\ \ \ \ \

or\ \ \ \ \ \ \dot{m}=\
\frac{D_v{\rho{}}_g}{1-Y_v}\frac{\partial{}Y_v}{\partial{}n}\ \ \ \ \

\ \ \ \ \ \ or\ in\ some\ resources\ \ \ \ \ \ \dot{m}=\
\frac{D_v{\rho{}}_g}{1-Y_v}\frac{\partial{}Y_v}{\partial{}n}-\frac{K}{L}\frac{\partial{}T}{\partial{}n}\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (eq.3)

\left[[-\rho{}\textbf{U}\textbf{U}-p\textbf{n}+\mu{}(\nabla{}\textbf{U}+\nabla{}\textbf{U}^T)\right]]=\ \sigma{}\kappa{}\textbf{n}\ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (eq.1)


P_{v,sat}=\frac{P_c{*T}_c}{T}*
\left[a*{\left(1-\frac{T}{T_c}\right)}^{1.5}+b*{\left(1-\frac{T}{T_c}\right)}^3+c*{\left(1-\frac{T}{T_c}\right)}^3+d*{\left(1-\frac{T}{T_c}\right)}^6\right]\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \left(eq.5\right)\ in\ which,P_c\ \ \ and\ T_c\
are\ critical\ presure\ \&\ temperature,\ respectively.

Last edited by Asghari_M; May 26, 2018 at 16:44.
Asghari_M is offline   Reply With Quote

Old   May 26, 2018, 11:36
Default Is the bold letters & fonts in Latex possible.?
  #20
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Hi all,

Is it possible to use bold fonts in the Latex

Thanks for any answer.
Asghari_M is offline   Reply With Quote

Reply

Tags
equations, formulas, latex, symbols


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide: Getting Started with the CFD Online Discussion Forums pete Site Help, Feedback & Discussions 8 July 29, 2016 06:00
Writting equations on cfd-online.com Guillermo Marraco CFD-Wiki 2 September 11, 2006 19:12
latex and dvi Hong Main CFD Forum 1 March 31, 2000 11:27
Latex chaker Main CFD Forum 3 October 27, 1999 10:19


All times are GMT -4. The time now is 07:13.