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: [...]
Posts Tagged ‘math’
Math case definitions in LaTeX
Posted: 12th December 2011 by Tim in LaTeXTags: amsmath, case, cases, definition, document, environment, function, LaTeX, layout, math, package
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 LaTeXTags: document, equation, LaTeX, layout, math, mode, text
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 [...]
Using gnuplot with LaTeX
Posted: 28th July 2011 by Tim in Gnuplot, LaTeXTags: document, function, gnuplot, graph, graphicx, include, input, LaTeX, layout, math, maths, plot
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 [...]
My third LaTeX document
Posted: 30th August 2010 by Tim in LaTeXTags: address, clickable, document, include, integral, LaTeX, layout, limit, math, package, page, programming, require, summation, tutorial, url, walkthrough, website
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
Posted: 22nd May 2010 by Tim in LaTeXTags: cap, cup, document, intersection, LaTeX, layout, math, maths, SET, sets, union
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:
Math blackboard (double-barred) font in LaTeX
Posted: 28th April 2010 by Tim in LaTeXTags: amssymb, black board, blackboard, code, document, environment, font, forall, LaTeX, layout, math, syntax
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 [...]
Checking if a float is not a number (nan) in C / C++
Posted: 10th March 2010 by Tim in C, C++Tags: C, divide by zero, double, float, fraction, math, nan, not a number, zero
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> [...]
Integrals and Limits in LaTeX
Posted: 19th September 2009 by Tim in LaTeXTags: calculus, document, formatting, infinity, integral, integrals, LaTeX, layout, limits, math, page
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 LaTeXTags: brackets, display, document, LaTeX, layout, math, page
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 LaTeXTags: align, document, LaTeX, layout, math, page, symbol
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 LaTeXTags: document, LaTeX, math, page, symbol, therefore
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 LaTeXTags: document, LaTeX, layout, math, page, sigma, style, sum, summation
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 [...]