Posts Tagged ‘math’

The lattice multiplication method is a way of multiplying two numbers in a simple, concise form. It works a lot like the traditional method taught in schools but can be easier and faster for multiplying large numbers. Let’s go through it step by step, using the example of 64 x 17: 1) Draw a box, […]

Min and max functions in Perl

Posted: 1st February 2012 by Tim in Perl
Tags: , , , , ,

Min and max functions are available in perl, but you need to load them first. To do this, add use List::Util qw[min max]; to the top of the script. These functions take a list of numbers and return the min/max of that list. The list can have 1 number or 100 – it doesn’t matter: […]

When writing a math definition of a function, for example, the function may have different results depending on the value of the inputs. These are called cases and are grouped together with a large left curly brace. If you’re trying to typeset this in LaTeX, the cases environment makes this nice and easy. It’s easiest […]

Adding text in math mode in LaTeX

Posted: 4th December 2011 by Tim in LaTeX
Tags: , , , , , ,

Occasionally you’ll want to add some text to a maths equation in LaTeX. By default, any text is written in italics, and white space is ignored. The solution is quite simple; put the text in a \text{…} block like so: $$x = \sqrt{x^2} \text{ : where $x$ is positive}$$ As you can see, you can […]

Gnuplot is a great tool for creating plots. LaTeX is a great tool for creating documents. Both are (or at least can be) created using a text editor and compiling the source. Both work with Windows, linux/unix and Mac. Wouldn’t it be great if you could include a gnuplot plot in a LaTeX document without […]

This tutorial is for those who have gone through the first and second LaTeX tutorials, and should give you the knowledge required to understand more specific LaTeX tips both on this site and on other websites. This tutorial will cover Packages and the basics of math mode. Packages Much like in programming, additional functionality can […]

Union (∪) and Intersection (∩) symbols in LaTeX can be produced via the \cup and \cap definitions while in math mode. No extra packages are required to use these symbols. For example: Let $L_C = L_A \cap (L_B \cup L_C)$ will produce:

In math, certain blackboard (double-barred) letters Z, N, R, etc. represent sets of numbers (integers, natural numbers, rational numbers, etc). These can be included in a LaTeX document using the \mathbb{[letter]} tag from within the math environment. Note that this requires the amssymb package to be included (ie: add \usepackage{amssymb} to the top of the […]

Occasionally you need to check whether a float is a valid number. There are times, such as when the number is read in to a function as an argument, when you can’t assume that the check has already been done. This check can be done using the isnan(number) function from math.h. For example: #include <math.h> […]

If you’re doing calculus, you’re going to want to print out the integral symbol, and talk about limits. LaTeX makes that easy for you. In math mode (ie: between $…$, \[…\], etc), integral symbols may be added using the \int_{lower}^{upper} command. Adding \displaystyle beforehand will make the symbol large and easier to read. Limits are […]

Large brackets in LaTeX math equations

Posted: 23rd August 2009 by Tim in LaTeX
Tags: , , , , , ,

There are times when you need to print large brackets in equations, such as around fractions and such. Simply type \left( and \right) instead of the normal brackets. For example: \displaystyle\sum_{k=1}^\infty \left(\frac{16}{5}\right)^k would be displayed as follows:

Lining up equations in LaTeX

Posted: 16th August 2009 by Tim in LaTeX
Tags: , , , , , ,

When writing up math equations, it looks much nicer if all of the equals signs are under each other. This cannot be done in the default LaTeX environment, but can be done with the amsmath package included. In order to get the equations lined up, place the group of equations between align* tags. Then, simply […]

Therefore symbol in LaTeX

Posted: 16th August 2009 by Tim in LaTeX
Tags: , , , , ,

There is no therefore symbol in the default LaTeX packages. There are (at least) two ways of getting the symbol: The package amssymb contains the \therefore symbol definition. To use, do something like: \usepackage{amssymb} … $\therefore 1 \neq 2$ Alternatively, you can create your own therefore definition: \def\therefore{ \leavevmode \lower0.1ex\hbox{$\bullet$} \kern-0.2em\raise0.7ex\hbox{$\bullet$} \kern-0.2em\lower0.2ex\hbox{$\bullet$} \thinspace} The amssymb […]

Math summation symbol in LaTeX

Posted: 15th August 2009 by Tim in LaTeX
Tags: , , , , , , , ,

LaTeX is great in that it can display all those strange math symbols for you.  Summation is a common symbol in math and really useful to know how to display in LaTeX. There are two ways of displaying the symbol: compressed to fit onto one line (useful when printing long equations or proofs) or in […]