Showing posts with label mathematical expressions. Show all posts
Showing posts with label mathematical expressions. Show all posts

Tuesday, April 14, 2015

Horizontal distances in equations

I was wondering for a while how to set the horizontal distances inside the equations.
Well, here is a fairly goo description. See the original source here.


Monday, December 15, 2014

Maple output to LaTeX

Maple can produce latex source using the ... wait for it ... latex( . ) command :-D




latex(expr, options)

latex(expr, filename, options)

See here for more details.
Works on Windows and Linux as well, no experience with OSX (yet).

Tuesday, January 21, 2014

How to change fonts in beamer equations

For a long time it was really annoying that the default fonts for the beamer template is just not right. I wanted to have the default fonts back for the equations, that look the same as in articles. Then I found this:

http://tex.stackexchange.com/questions/41572/setting-math-fonts-in-beamer

The solution that was working best for me was:
\usefonttheme[onlymath]{serif}

Monday, April 1, 2013

How to write the set of real numbers

For an n dimensional vector I use
$\mathbb{R}^n$
Do not forget to include the amssymb or amsfonts package
Similarly \mathbb{Z} for integer, \mathbb{N} for natural and \mathbb{C} for complex and so on...

Monday, March 18, 2013

Fractions in latex

The easiest way to write fractions in an equation is to use the \frac command as
\frac{a}{b}

Tuesday, March 5, 2013

Write transpose of a matrix

Transpose of a matrix (switching rows with columns), I like to write with "T" in exponent, where the exponent is not italic, like 
$A^{\rm T}$

Thursday, February 28, 2013

How to write Ordo for complexity in latex

Ordo (or the big-O notation) is used to describe computational complexity, in technical writing. I found the best way to write it is 
$\mathcal{O}(x^2 + ...)$

Tuesday, June 19, 2012

How to leave open parenthesis in equations

If you use \left( and \right) the syntax checker will not allow you not to close (or not to open) the parenthesis. To get your LaTeX code correct you have to use \left. or \right. to have it closed.

This is useful for instance when you want to add new lines with parenthesis open or write cases like 
$\left\{
   \begin{array}{l c l}
      x &\rightarrow& y \\
      z &\rightarrow& w
    \end{array}

\right.$

Monday, June 18, 2012

Sunday, June 17, 2012

Vertical spaces in equations

This might not be the most sophisticated way to do this, but it works:
simply escape the spaces using \ (backslash)
$x_{k+1}\ =\ x_k+w_k$

Thursday, May 31, 2012

How to write integral from minus infinity to plus infinity in LaTeX

Lower and higher limits to integrals can be set as
$ \int^{+\infty}_{-\infty} x \, dx $

How to write argmax and argmin

$ \operatorname{arg\,max}_a f(a) \operatorname*{arg\,max}_b f(b)$

Note that the first version is more for inline code, while the second is rather for equation. Naturally, arg min is written analogously. Don't forget to use the amsmath package

For more info see
http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics

Monday, May 21, 2012

How to write different cases in equations

Many times we need to write different cases like      
a= {0.6 if t <= 100
      {0.9 it t > 100
The easiest, and most elegant way to do this is to use \case command, as
 $a = \begin{cases}
     0.6, & \textnormal{if } t\le100 \\
     0.9 & \textnormal{if } t>100
\end{cases}$

Thursday, May 17, 2012

How to write sum in the equations

The easiest way to write a sum of an expression (i=[1 .. n]) in equations is
$\sum_{i=1}^n expression$
Note that in inline code this will put lower and upper bound next to the sum sign, not over and under. To  display lower and upper bound under and over the sum sign use the \displaystyle command before the sum.

To specify directly that the upper and lower bound are over and under the sum symbol, simply write
$\sum\limits_{i=1}^n expression$

Wednesday, May 16, 2012

How to write fraction

I usually use the \frac command as

$x = \frac{numerator}{denominator}$

This will render numerator over the denominator, alternatively in inline codes \dfrac can be used instead from the amsmath package with the same syntax.

Monday, March 26, 2012

How to create matrices

Generally the easiest way is:
$
  L = \left[
    \begin{array}{cc}
       x & y \\
       z & w
    \end{array} \right]
$
A good reference about the topic can be found here:

http://www.rizauddin.com/2009/05/how-to-create-a-matrix-in-latex/

An even easier way to do this is to use pmatrix as
$
  \begin{pmatrix}
     x & y \\
     z &  w
  \end{pmatrix}
$
 However this latter will always put the matrix inside round  parenthesis.