Tuesday, September 27, 2011

Some information about LaTeX math environments (amslatex) in general and in MathJax - array, align, cases, dcases*, etc.

So I was trying to display a "case" or piecewise array of an equation like this:

 \[ \dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \cases{ 0 & \text{Laplace's Equation} \\ -4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation}} \]

 However, when I used the code:

 \dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \left\{ \begin{array}{cr} 0 & \text{Laplace's Equation} \\ -4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation} \end{array} \right.

MathJax would not render. So I tried the cases environment since I saw that "array" is not preferred anymore.

Avoid eqnarray! - Lars Madsen - The PracTeX Journal - http://www.tug.org/pracjourn/2006-4/madsen/

Welcome to the TeXblog by Stefan Kottwit - eqnarray vs. align - April 12th, 2008 - http://texblog.net/latex-archive/maths/eqnarray-align-environment/

LaTeX tips: Displayed Math - http://www.math.uiuc.edu/~hildebr/tex/displays.html
eqnarray/eqnarray* and array. Avoid these. Before the advent of amslatex, multiline displays and cases constructs had to be typeset with "eqnarray" and "array". However, the above (amslatex) environments "align/align*" and "cases" are easier too use, provide greater functionality, and generate better looking output. There is no reason whatsoever to use "eqnarray" instead of "align", and, except in very rare situations, "array" is unnecessary.
 Which I found here: http://www.physicsforums.com/showthread.php?p=3510955
If you were using it for equations, actually "align" is recommended. With the AMS math environments (align, gather, multline, matrix, etc.) there's almost never any reason to use array or especially eqnarray anymore.
The other user then asked:
What is the reasoning behind this recommendation? Since I mostly post equations on forums, I'd prefer the environment that "always works". Meaning I don't want to be dependent of (parts of) an AMS environment or another environment that may or may not be available. As far as I can tell matrix, pmatrix, array, eqnarray, align all seem to work in various environments, so they are all eligible. What I haven't yet figured out is why one would be preferable over another.
In which the reply was:
Reasons why eqnarray is deprecated: http://www.tug.org/pracjourn/2006-4/madsen/, http://texblog.net/latex-archive/mat...n-environment/, http://www.math.uiuc.edu/~hildebr/tex/displays.html (and much of the same reasoning applies to array). Basically it's because of layout problems - though to be fair, those aren't as much of an issue when rendering to MathML, as MathJax does. It might even be the case that MathJax implements array and eqnarray as synonyms for matrix and align (with slightly different syntax). Still, it's pretty common knowledge throughout the LaTeX community that the AMS environments are strictly better than array and eqnarray when you're typesetting a paper, and no worse anywhere else, so you're unlikely to find any environment where they are not supported. (MathJaX supports all the AMS environments natively, and every LaTeX distribution includes the AMS packages, so I can't think of a legitimate reason you would be unable to use them. The website administrator would have had to explicitly disable them, which would be silly.)
However, the cases command like this does not work either:

\dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \begin{dcases*} 0 & Laplace's Equation \\ -4 \pi \rho \left( \mathbf{x} \right) & Poisson's Equation \end{dcases*}

(I used dcases* which can be found and described here: http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics)

It wasn't until I stumbled upon this site did I figure out what was wrong. TEX Commands available in MathJax - Dr. Carol J.V. Fisher - http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm#C

When uses environmetns like array or cases in MathJax you must use, well I should say it works if you use:




I think this is because the delimiters "back-slash plus the square brace/bracket" are used, \ [ \ ]. It could work if I used \ begin{equation} maybe. I'll test and see because they are showing this in the Physics Forum thread:
\frac {\partial}{\partial a^1} = \cdots \cdots \\
\frac {\partial}{\partial a^2} = \cdots \\
\frac {\partial}{\partial a^3} = \cdots


\frac {\partial}{\partial a^1} &= \cdots \\
\frac {\partial}{\partial a^2} &= \cdots \\
\frac {\partial}{\partial a^3} &= \cdots

because there isn't an \ align{} environment according to Dr. Fisher's well done site. If you go to "environments" on the site it does show \ begin{align} etc. environments.

Hmmm, maybe I need to use some of these to get it to work properly. From here: http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
There are also few environments that don't form a math environment by themselves and can be used as building blocks for more elaborate structures: 
gathered - Allows to gather few equations to be set under each other and assigned a single equation number 
split - Similar to align*, but used inside another displayed mathematics environment 
aligned - Similar to align, to be used inside another mathematics environment. 
alignedat - Similar to alignat, and just as it, takes an additional argument specifying number of columns of equations to set.
I also like these notes from the same page:
eqnarray and eqnarray* - Similar to align and align*; Not recommended since spacing is inconsistent 
multline and multline* - First line left aligned, last line right aligned; Equation number aligned vertically with first line and not centered as with other other environments. 
gather and gather* - Consecutive equations without alignment 
flalign and flalign* - Similar to align, but left aligns first equation column, and right aligns last column 
alignat and alignat* - Takes an argument specifying number of columns. Allows to control explicitly the horizontal space between equations; You can calculate the number of columns by counting & characters in a line, adding 1 and dividing the result by 2
Anyways, I didn't like how the \ cases{}, \ begin{cases}, or any of the cases environments do not center the numbers where you can set this in array since it requires the c, l, r or whatever column justification like: \ begin{array}{lcr}.

 \[ \dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \cases{ 0 & \text{Laplace's Equation} \\ -4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation}} \]

Ok, I can't figure this out since you should be able to use \ begin{array} and many other LaTeX math environments.  Tired of working on it.  I will look at later.  This is my problem:

\dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \left\{
0 & \text{Laplace's Equation}\\
-4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation}


\begin{equation} \dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \left\{ \begin{array}{cr} 0 & \text{Laplace's Equation}\\ -4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation} \end{array} \right. \end{equation}

Ok, well it works now!  I must just be an idiot.  :P

TeX Commands available in MathJax

TeX Commands available in MathJax: "TEX Commands available in MathJax"

Uhhhh, all I can say is WOW! Check this site out! This is a VERY detailed and well done (very readable) site which shows what it says, the available TeX commands in MathJax. Bravo!!

I think this is by Dr. Carol J.V. Fisher.  They even have a setup where you can test your TeX to MathJax!!

Saturday, September 24, 2011

Numerical Math - Square wire problem - finite difference method

The square-wire problem is described by the 2-D Laplace and Poisson equations [1].

\begin{equation} \dfrac{\partial^2 U \left( x, y \right)}{\partial x^2} + \dfrac{\partial^2 U \left( x, y \right)}{\partial y^2} = \left\{ \begin{array}{cr} 0 & \text{Laplace's Equation}\\ -4 \pi \rho \left( \mathbf{x} \right) & \text{Poisson's Equation} \end{array} \right. \end{equation}

Next, in order to obtain the second order derivatives a Taylor series expansion with steps of positive and negative values in both \( x \) and \( y \) are executed for \( U \).

\begin{equation} U \left( x + \Delta x, y \right) = U \left( x, y \right) + \dfrac{\partial U}{\partial x} \Delta x + \dfrac{1}{2} \dfrac{\partial^2 U}{\partial x^2} \left( \Delta x \right)^2 + \cdots, \end{equation}

\begin{equation} U \left( x - \Delta x, y \right) = U \left( x, y \right) - \dfrac{\partial U}{\partial x} \Delta x + \dfrac{1}{2} \dfrac{\partial^2 U}{\partial x^2} \left( \Delta x \right)^2 - \cdots, \end{equation}

\begin{equation} U \left( x, y + \Delta y \right) = U \left( x, y \right) + \dfrac{\partial U}{\partial y} \Delta y + \dfrac{1}{2} \dfrac{\partial^2 U}{\partial y^2} \left( \Delta y \right)^2 + \cdots, \end{equation}

\begin{equation} U \left( x, y - \Delta y \right) = U \left( x, y \right) - \dfrac{\partial U}{\partial y} \Delta y + \dfrac{1}{2} \dfrac{\partial^2 U}{\partial y^2} \left( \Delta y \right)^2 - \cdots, \end{equation}

Now, adding both equations each for \( x \) and \( y \) the odd terms cancel, and truncating at \( O \left( \Delta^4 \right) \) obtains

\begin{equation} U \left( x + \Delta x, y \right) + U \left( x - \Delta x, y \right) = 2 U \left( x, y \right) + \dfrac{\partial^2 U}{\partial x^2} \left( \Delta x \right)^2 + O \left( \Delta x^4 \right) \end{equation}

\begin{equation} U \left( x, y + \Delta y \right) + U \left( x, y - \Delta y \right) = 2 U \left( x, y \right) + \dfrac{\partial^2 U}{\partial y^2} \left( \Delta y \right)^2 + O \left( \Delta y^4 \right) \end{equation}

Rearranging to segregate the second derivative engenders

\begin{equation}  \dfrac{\partial^2 U}{\partial x^2} \left( \Delta x \right)^2 = U \left( x + \Delta x, y \right) + U \left( x - \Delta x, y \right) - 2 U \left( x, y \right) \end{equation}

\begin{equation} \dfrac{\partial^2 U}{\partial y^2} \left( \Delta y \right)^2 = U \left( x, y + \Delta y \right) + U \left( x, y - \Delta y \right) - 2 U \left( x, y \right) \end{equation}

Finally, dividing produces

\begin{equation} \dfrac{\partial^2 U}{\partial x^2} = \dfrac{U \left( x + \Delta x, y \right) + U \left( x - \Delta x, y \right) - 2 U \left( x, y \right)}{\Delta x^2} \end{equation}

\begin{equation} \dfrac{\partial^2 U}{\partial y^2} = \dfrac{U \left( x, y + \Delta y \right) + U \left( x, y - \Delta y \right) - 2 U \left( x, y \right)}{\Delta y^2} \end{equation}

Next, substituting the second order derivatives into the Poisson equation produces

\begin{equation} \begin{array}{l} \dfrac{U \left( x + \Delta x, y \right) + U \left( x - \Delta x, y \right) - 2 U \left( x, y \right)}{\Delta x^2} \\ \hspace{1.15 in} + \dfrac{U \left( x, y + \Delta y \right) + U \left( x, y - \Delta y \right) - 2 U \left( x, y \right)}{\Delta y^2} = -4 \pi \rho \left( x, y \right) \end{array} \end{equation}

If the grid spacing is the same in both the \( x \) and \( y \) coordinates, that is \( \Delta x = \Delta y \), then the equation reduces to

\begin{equation} \begin{array}{l} U \left( x + \Delta, y \right) + U \left( x - \Delta, y \right) + U \left( x, y + \Delta \right) \\ \hspace{2 in} + \hspace{1 mm} U \left( x, y - \Delta \right) - 4 U \left( x, y \right) = -4 \pi \rho \left( x, y \right) \Delta^2 \end{array} \end{equation}

Algebraically, the solution \( U \left( x, y \right) \) can be shown as

\begin{equation} \begin{array}{l} U \left( x, y \right) \simeq \dfrac{1}{4} \left[ U \left( x + \Delta, y \right) + U \left( x - \Delta, y \right) \right. \\ \hspace{2 in} \left. + \hspace{1 mm} U \left( x, y + \Delta \right) + U \left( x, y - \Delta \right) \right] + \pi \rho \left( x, y \right) \Delta^2 \end{array} \end{equation}

Lattice spacings can be identified as \( x = x_0 \pm \Delta \) and \( y = y_0 \pm \Delta \) which correspond to \(i \pm 1 \) and \( j \pm 1 \) where \( i, j = 0, 1, \ldots, N_{max - 1} \).  Thus, the finite difference algorithm appears as

\begin{equation} U_{i, j} = \dfrac{1}{4} \left( U_{i + 1, j} + U_{i - 1, j} + U_{i, j + 1} + U_{i, j - 1} \right) + \pi \rho_{i, j}\Delta^2 \end{equation}

However, for simplicity Landau et al just ask to solve for the homogeneous equation

\begin{equation} U_{i, j} = \dfrac{1}{4} \left( U_{i + 1, j} + U_{i - 1, j} + U_{i, j + 1} + U_{i, j - 1} \right) \end{equation}

A few notes here from Landau et al.  For one a direct solution cannot be obtain from this algorithm.  That is, a process must be repeated several times in order for a solution to converge!  Thus, this is where efficiency and proficiency becomes very important in numerical methods.

First, a guess is imposed then swept over the domain which finds values for all variables at each point or node.  The solution has "converged" when the current generation does not change compared to the previous generation of values within a "tolerance" or error/precision (absolute value of the difference between old values and new) specified by the user or technique.  Another outcome could be that the values emerge as not expected which at that point the user must go back and figure out from where the error is coming.  Landau et al give the definition of relaxed as when the first guess has converged into a solution.

Landau et al pose "Does it always converge, and if so, does it converge fast enough to be useful?"

Another important note is the coordinate system used.  This problem was done in rectangular Cartesian coordinates.  Other problems may work better in other coordinate systems such as cylindrical or spherical depending upon the geometry of the problem in which case the Laplacian expansion \( \Delta^2 \) will be different.

One way to solve the algorithm is to utilize the Jacobi method.  This most basic method simply evaluates each point, sweeping across the domain.  The initialization and BCs symmetry are preserved in this way.  However, in order to speed up this method, a simple modification can be implemented where values that are known from the current run compared to other nodes can be updated immediately.  Thus, reducing the amount of needed storage by half since two nodes will be know for one in this case and the previous sweep will not be necessary to store since information is updated instantaneously when available.  This technique is called the Gauss-Seidel method.  The GS method leads to quicker convergence, less round-off error, and less needed storage.  However, symmetry is not conserved which the user hopes does not affected the solution outcome.

If the sweep begins at the top left corner then the GS algorithm looks like

\begin{equation} U_{i, j} = \dfrac{1}{4} \left[ U^{(old)}_{i + 1, j} + U^{(new)}_{i - 1, j} + U^{(old)}_{i, j + 1} + U^{(new)}_{i, j - 1} \right] \end{equation}

Octave code:

%This code was written by Tim Barber for the numerical PDE class taught by Dr. Parigger in the Summer of 2011

%This file corresponds specifically to HW set #1

%Problem 1.3 Square Wire Problem: Chapter 17 of the Landau-course book
discusses the square-wire problem, viz. elliptic PDE. Section 17.4.2
elaborates on the solution using the finite difference method. Your task
here is to (i) derive the finite difference algorithm Eq. 17.27, (ii)
implement the code using source programing (see the listed source
code), and (iii) display the results using gnuplot (along the lines of
Section 17.4.2).


%input data manually

N_max = 100;
iter = 1000;

%initialize matrix

for i = 1:N_max
for j = 1:N_max
if j = 100
U(i, 100) = 99;
U(i, j) = 0;
j = j + 1;
i = i +1;

%iterate matrix using the Gauss-Seidel technique

for n = 1:iter + 1
for i = 2:N_max - 1
for j = 2:N_max - 1
U(i, j) = (1/4)*(U(i + 1, j) + U(i - 1, j)
+ U(i, j + 1) + U(i, j - 1));
j = j + 1;
i = i +1;
n = n + 1;

%plot of U(x, y)
mesh (U)

%label title and axes
title('HW 1.3', "fontsize", 20)
ylabel('y', "fontsize", 16)
xlabel('x', "fontsize", 16)
zlabel('U(x, y)', "fontsize", 16)

%commands to save plot as a .png file


[1] R. H. Landau, M. J. Páez, and C. C. Bordeianu. A Survey of Computational Physics -
a Introductory Computational Science, Princeton University Press, Princeton, New Jersey.

Numerical Math - Stiffness

In order to answer the question of stiff ODEs, let's look at an example in A First Course in the Numerical Analysis of Differential Equations by Iserles [1].

Hoffman [2] states that stiffness appears for single linear and nonlinear ODEs, higher-order linear and nonlinear ODEs, and systems of linear and nonlinear ODEs.  He lists several definitions for stiffness:

1. An ODE is stiff if the step size required for stability is much smaller than the step size required for accuracy.

2. An ODE is stiff if it contains some components of the solution that decay rapidly compared to other components of the solution.

3. A system of ODEs is stiff if at least one eigenvalue of the system is negative and large compared to the other eigen values of the system.

4. From a practical point of view, an ODE is stiff if the step sixe based on cost (i.e., computational time) is too large to obtain an accurate (i.e., stable) solution.

Hoffman [2] also gives a couple of examples.

In progress...to be continued.


[1] A. Iserles. A First Course in the Numerical Analysis of Differential Equations. 2nd ed. Cambridge University Press, Cambridge, UK. 2009

[2] J. D. Hoffman. Numerical Methods for Engineers and Scientists. 2nd ed. Marcel Dekker, Inc., New York, NY. 2001

Numerical Math - Adams methods

According to Iserles [1],

In progress...to be continued.

[1] A. Iserles. A First Course in the Numerical Analysis of Differential Equations. (2nd ed.).
Cambridge University Press, Cambridge, UK. 2009

Ubuntu 11.10 Beta 2 Released - and GNOME 3

Apparently GNOME 3 runs pretty well in the latest beta versions of 11.10 which GNOME 3 comes with by default, I believe.  Not sure how this is playing out as I thought Unity was the go to for Ubuntu.  The next release is pretty close which is Oct. 13th for 11.10.

I just hope the damn quad monitor is resolved soon for Unity!!  I like Unity better over the rest.  KDE Plasma Kubuntu 11.04 is ok, but it ran really slow for quads.  Xubuntu's XFCE was working pretty well until recently.  I can only get mirrored duals now.  Lubuntu works, but the frigging icons at the top look horrible and I don't have time to mess around.  So I am using GNOME Classic with no effects.  This is fine since it is the closet to Unity/GNOME as it gets, but it doesn't default with the window snapping which can be done, I believe, but I don't have time to mess with it either.

Ah, I found

Unity is based atop of the latest unstable release of GNOME 3.

Ubuntu 11.10 Beta 2 Released, Reviewed - September 22, 2011 - http://www.omgubuntu.co.uk/?p=20709

The synaptic package manager is now dead in 11.10.

Ubuntu 11.10 Beta 2 is Here : They Have Killed Synaptic Package Manager! by PUBUDU KODIKARA on SEPTEMBER 23, 2011 - http://techhamlet.com/2011/09/ubuntu-oneiric-ocelot-beta2/ 

A few more links:

Ubuntu 11.10 Beta 2 (Oneiric Ocelot) Released - September 23, 2011 - http://www.ubuntugeek.com/ubuntu-11-10-beta-2-oneiric-ocelot-released.html

Ubuntu 11.10 Oneiric Beta 1 Review And Screenshots Tour By Damien | September 5, 2011 - http://maketecheasier.com/ubuntu-11-10-oneiric-beta-1-review-and-screenshots-tour/2011/09/05

UBUNTU 11.10 ONEIRIC OCELOT BETA 1 HAS BEEN RELEASED [VIDEO, SCREENSHOTS] - 01 SEP 2011 WRITTEN BY ANDREW - http://www.webupd8.org/2011/09/ubuntu-1110-beta-1-has-been-released.html

  Ubuntu 11.10 Alpha 1 Has GNOME 3, Firefox 5, Linux Kernel 2.6.39 - June 2nd, 2011, 19:00 GMT · By Marius Nestor - http://news.softpedia.com/news/Ubuntu-11-10-Alpha-1-Has-GNOME-3-Firefox-5-Linux-Kernel-2-6-39-203976.shtml

Ubuntu 11.10 Beta 1 : An Early Tour of Oneiric Ocelot by PUBUDU KODIKARA on SEPTEMBER 2, 2011 - http://techhamlet.com/2011/09/ubuntu-11-10-beta-1/

Friday, September 23, 2011

Math - Vectors - Euclidean space

Aris [1] defines Euclidean 3-space as the general and typical three-dimensional space we see everyday.

In progress...to be continued.

[1] R. Aris. Vectors, Tensors and the Basic Equations of Fluid Mechanics. Dover Publications. New York, NY. 1990

Math - Vectors - Dot/scalar/inner product

The dot product, scalar, or inner product is the vector multiplication which executes for two vectors \( \mathbf{A} \) and \( \mathbf{B} \) in three dimensions is [1, 2]

\[ \begin{align} \mathbf{A} \cdot \mathbf{B} &= \left(A_1 \mathbf{e}_1 +  A_2 \mathbf{e}_2 + A_3 \mathbf{e}_3 \right) \cdot \left(B_1 \mathbf{e}_1 +  B_2 \mathbf{e}_2 + B_3 \mathbf{e}_3 \right) \\ &= A_1 B_1 + A_2 B_2 + A_3 B_3 \end{align} \]

That is, the dot product multiplies each corresponding component of the vectors and adds them together to  obtain a scalar.  So you could also call this a vector component product.

In progress...to be continued.


[1] K. Karamcheti. Principles of Ideal-Fluid Aerodynamics. John Wiley & Sons, Inc., New York, NY. 1966

[2] W. Kaplan. Advanced Calculus (5th ed.). Addison-Wesley. 2002

Math - Vectors - Unit vector and vector magnitude/length/norm

The unit vector of a vector is in the direction of the vector with a magnitude of one.  For example, in the three-dimensional Cartesian coordinate system the vectors \( \left( \hat{i}, \hat{j}, \hat{k} \right) \) or \( \left( \mathbf{i}, \mathbf{j}, \mathbf{k} \right) \) represent the unit vectors along the three axes \( \left(x, y, z \right) \).

In general, the unit vector of a vector can be written as

\[ \mathbf{e}_A = \dfrac{ \mathbf{A}}{| \mathbf{A}|} \]

which is the vector of \( A \) divided by the magnitude of \( A \).  The magnitude (also called the length or norm) in the three-dimensional case \( \vec{A} = A_1 \mathbf{i} + A_2 \mathbf{j} + A_3 \mathbf{k} \) is expressed as

\[ | \mathbf{A}| = \sqrt{\mathbf{A} \cdot \mathbf{A}} = \sqrt{A_1^2 + A_2^2 + A_3^2} \]

In an orthogonal right-handed system, the unit vectors in three dimensions can be expressed as \( \mathbf{e}_1 \), \( \mathbf{e}_2 \), and \( \mathbf{e}_3 \) where the components of a vector \( \mathbf{A} \) are \( A_1 \), \( A_2 \), and \( A_3 \) and correspond to the unit vectors respectively.  That is the vector \( \mathbf{A} \) can be broken down into individual components which relate to whatever coordinate system and unit vectors are chosen to be used [1, 2].

In progress...to be continued.


[1] K. Karamcheti. Principles of Ideal-Fluid Aerodynamics. John Wiley & Sons, Inc., New York, NY. 1966

[2] W. Kaplan. Advanced Calculus (5th ed.). Addison-Wesley. 2002

LaTeX Math - Horizontal spacing

Here are the spacing commands for LaTeX in math mode.

\quad - a space equal to the current font size (horizontally)

\qquad - is a double \quad

\, or \thinspace - small space, 3/18 of a quad

\: or \medspace - medium space, 4/18 of a quad

\; or \thickspace- large space, 5/18 of a quad

\! - negative small space, -3/18 of a quad

\negmedspace - negative medium space, -4/18 of a quad

\negthickspace - negative large space, -5/18 of a quad

The \medspace, \thickspace, \negmedspace, and \negthickspace commands require the amsmath package.

Found the full forms here: Special LaTeX Characters - 6. Math spacing commands - http://www.combinatorics.net/weblib/A.9-10/a9.html

LaTeX Math - Vector arrow

The code for creating a vector arrow over a symbol in LaTeX math mode is


so that

produces \( \vec{A} \).

Thursday, September 22, 2011

LaTeX Math - Degree symbol

The LaTeX symbol to produce "degrees" as in temperature or angle is


which produces \( ^{\circ} \) or


produces \( 30^{\circ} \).

wxMaxima - 2D plots with one or more functions

Alright so let's keep this ball rolling.  Next, I would like to enter an equation as a function and then plot that function on a 2D graph in Maxima.  I would also like to gauge this function versus a couple of more so I will have three functions plotted on the same graph.

As a continuation from the previous post, I am entering in and defining a function for tangential velocities.  It is as easy as before.  I set

u_theta2(u):= %pi*(lamb_da(al_pha) + csc(u)*cot(u) - (csc(u))^2 - log(tan(u/2)));


\[ u_{\theta} = \pi \left( \lambda + \csc \phi \cot \phi - \csc^2 \phi - \ln \Phi \right) \]

where \( \Phi = \tan \dfrac{\phi}{2} \).

Right now I am using the variable "u" in place of \( \phi \).  I will try to change that to "phee" later.I will aslo try to make a function for "big_phee" for \( \Phi \) too.

I also create the function one_over_R_sin(u) for comparison and choose a constant \( R \) while varying \( \phi \).

one_over_R_sin(u):= 1/(0.7*sin(u));

\[ u_{\theta} = \dfrac{1}{R \sin \phi} \]

Then we can plot by

plot2d([u_theta2(u), one_over_R_sin(u)], [u, 0.00001, %pi/6], [y, 0, 20]);

So the plot2d a 2-d graph or plot.  The first argument allow you to plot more than one function as the notation of [f(x), g(x)],.  If we were to just plot one function there would be no need for the square brace [ ] but instead just the function f(x),.  The next argument allows the range for the "x" variable which in this case is u.  So I let u range from 0 to my angle \(\alpha \) of \( 30^{\circ} \) or \( \dfrac{\pi}{6} \) radians.  This must be encased in a square brace [ ].  Then, if we like, we can give a range for the "y-axis" which I ranged from 0 to 20.

wxMaxima - defining a parameter/variable and a function

Ok, so here is one of my shots at Maxima/wxMaxima.  My goal is to define a parameter/variable then use it in a function I have defined myself.

My variable is alpha, \( \alpha \), but I defined it as al_pha since Maxima doesn't like variables that are already defined and many of those are Greek variables.  I just broke it up phonetically.  I set alpha to be a constant by

al_pha: 30*%pi/180

(I think using just "pi" works too.  It does, it just leaves it in symbolic form.  See screen shots.)

The colon (:) provides the capability to define the variable  al_pha in Maxima.  I also multiplied by Pi and divided by 180 in order to get al_pha from degrees (30) into radians since I am going to be dealing with trigonometric functions.

Next, I define my function as lamb_da as

lamb_da(x):= (csc(x))^2

Note, that I used "x" even though I want the angle alpha.  We will call lamb_da for al_pha later.  So the colon (:) plus the equal sign (=) attains a function definition in Maxima.  Also note that in order to square cosecant in Maxima I had to wrap in parentheses and then square.  I also could have done


but who wants to do that for 2 or higher?!

Screen shots:

Notice the difference between using %pi and pi gives 4 and \( \csc ^2 \left( \dfrac{\pi}{6}\right) \), respectively.

I then add more to lamb_da once I know it is working properly.

I can check it with KAlgebra.

I found this very good pdf where I discovered how to define a function and parameter:


Also this can be found in the Maxima documentation here:

7.6 Assignment operators - http://maxima.sourceforge.net/docs/manual/en/maxima_7.html#SEC41

Wednesday, September 21, 2011

Partial Differential Equations - Types

One very important step for solving, working with, and understanding partial differential equations (PDEs) is knowing the classifications of types.

A general second order PDE can be written as (Özişik 1993Tannehill et al 1997, Hoffman 2001, Chung 2002, Arfken & Weber 2005, Chung 2010):

\[ A \dfrac{\partial^2 \phi}{\partial x^2} + B \dfrac{\partial^2 \phi}{\partial x \partial y} + C \dfrac{\partial^2 \phi}{\partial y^2} + D \dfrac{\partial \phi}{\partial x}+ E \dfrac{\partial \phi}{\partial y} + F \phi + G \left( x, y \right) = 0 \]

The types of PDEs is based on the coefficients \( A \),  \( B \), and  \( C \) which produces the characteristic equations also known as discriminants:

\[ \begin{array}{lll} B^2 - 4AC < 0 & \text{Elliptic} & \text{Complex characteristic curves} \\ B^2 - 4AC = 0 & \text{Parabolic} & \text{Real and repeated characteristic curves}\\ B^2 - 4AC > 0 & \text{Hyperbolic}  & \text{Real and distinct characteristic curves} \end{array} \]

Some examples of each type of equation are:


Laplace's Differential Equation:

\[ \nabla^2 \phi = 0 \]

in 2-d Cartesian:

\[ \dfrac{\partial^2 \phi}{\partial x^2} + \dfrac{\partial^2 \phi}{\partial y^2} = 0 \]

Steady Heat Diffusion Equation:

\[ \dfrac{\partial^2 T}{\partial x^2} + \dfrac{\partial^2 T}{\partial y^2} = 0 \]

Poisson's Differential Equation (non-homogeneous Laplace Equation):

\[ \nabla^2 \phi = f \]

in 2-d Cartesian:

\[ \dfrac{\partial^2 \phi}{\partial x^2} + \dfrac{\partial^2 \phi}{\partial y^2} = f \left( x, y \right) \]


Heat or Unsteady Diffusion Equation:

\[ \dfrac{\partial \phi}{\partial t} = \alpha \nabla^2 \phi = 0 \]

in 1-d Cartesian:

\[ \dfrac{\partial \phi}{\partial t} = \alpha \dfrac{\partial^2 \phi}{\partial x^2} = 0 \]


Wave Equation:

\[ \dfrac{\partial^2 \phi}{\partial t^2} = c \nabla^2 \phi = 0 \]

in 1-d Cartesian:

\[ \dfrac{\partial^2 \phi}{\partial t^2} = c \dfrac{\partial^2 \phi}{\partial x^2} = 0 \]

Physical classification breaks up PDE's for further understanding (Tannehill et al 1997, Hoffman 2001).

Equilibrium Problems:

The first is called an equilibrium problem.  The solution of the PDE must be satisfied in a closed domain where conditions are set on the boundary.  Equilibrium problems are also known as boundary value problems and include examples such as steady-state temperature distributions, incompressible inviscid flows, and equilibrium stress distributions in solids.  Dominated by elliptical equations, equilibrium problems are also called jury problems as the boundary conditions determine the solution of every point in the domain.

Marching Problems:

Other equations of note:

First-Order Linear Wave Equation or the Advection Equation:

\[  \dfrac{\partial u}{\partial t} + c \dfrac{\partial u}{\partial x} = 0 \]

Inviscid Burgers Equation or Nonlinear First-Order Wave Equation:

\[  \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} = 0 \]

Burgers' Equation or Nonlinear Wave Equation with Diffusion:

\[  \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} = v \dfrac{\partial^2 u}{\partial x^2} \]

Tricomi Equation with Diffusion:

\[  y \dfrac{\partial^2 u}{\partial x^2} + \dfrac{\partial^2 u}{\partial y^2} = 0 \]


Arfken, G. B. & Weber, H.-J. Mathematical Methods for Physicists (6th ed.). Elsevier Academic Press. Burlington, MA. 2005

Chung, T. J. Computational Fluid Dynamics, Cambridge University Press, Cambridge, UK. 2002

Chung, T. J. Computational Fluid Dynamics, 2nd ed. Cambridge University Press, Cambridge, UK. 2010

Hoffman, J. D. Numerical Methods for Engineers and Scientists. CRC Press, Boca Raton, FL, 2nd edition, 2001.

Özişik, M. N. Heat Conduction. John Wiley & Sons, Inc., New York, NY, 2nd edition, 1993.

Smith, G. D. Numerical Solution of Partial Differential Equations: Finite Difference Methods. Oxford Applied Mathematics & Computing Science Series. Oxford University Press, New York, NY, 3rd edition, 1985.

Tannehill, J. C., Anderson, D. A., and Pletcher, R. H. Computational Fluid Mechanics and Heat Transfer, 2nd ed. Taylor & Francis  Hemisphere, New York, NY. 1997

Matrices - General math

As I've stated before I am logging topics/subjects I come across in classes and research. I am taking a vector calculus mainly for review, but I am also understanding the fundamentals much better and learning new stuff.  On top of that, I am taking a mathematical methods for physicists and inviscid flow and both are giving added and large doses of vector analysis.  I always have the point of view that the more you hear and see something the more you remember and take away from it. Thus, it becomes "easier" or almost second nature.  I also encourage getting a wide range of views from various people as they have very different teaching techniques, experiences, and their own learning background.  So, while I may have tortured myself by taking a couple of extra classes which are not necessarily "needed" for my degrees, I am gaining much valuable insight to the fundamentals and basics.

So, one of the first things (or eventual topics) in vector courses that comes about appears as matrices.  Matrices are very important in physics and math and thus most sciences.  Matrices appear in many math courses such as linear/matrix algebra and numerical linear/matrix algebra.  Matrices are associated with linear algebra due to collecting systems of linear ordinary differential equations ODEs into sets which are easily converted into matrices.  In fact, in Shores [1] book, Applied Linear Algebra and Matrix Analysis, he opens by remarking that

"The two central problems about which much of the theory of linear algebra revolves are the problem of finding all solutions to a linear system and that of finding an eigensystem for a square matrix."

In progress...

[1] T. S. Shores. Applied Linear Algebra and Matrix Analysis. Springer Science+Business Media, LLC., New York, NY. 2007

Tuesday, September 20, 2011

Vector Analysis and Calculus - General math

This post highlights vector calculus and vector analysis. Such topics and discussions will cover ideas and concepts encountered when dealing with vector analysis. Vectors are a very important concept in science and math and appear very early in calculus and physics classes in college or in advanced high school classes. Vectors are used to describe a direction and magnitude of important concepts in our world such as gravity and other forces. Vectors can also group together many sets of equations into a compact form such as the three-dimensional equations of motion expressed as a single line of a vector equation instead of expanding for each of the three components. Vectors appear very often in fluid dynamics and are a fundamental basis for the subject. Many fluid dynamic books introduce the reader into and with vector analysis [1-5] or contain an appendix at the end of the book [5] while the manuscript by Aris [6] is based upon vectors and fluid dynamics altogether.

As mentioned previously, vectors make up the fundamental basis of mathematics and physics in the world. Many mathematical books which generalize math topics which scientist, engineers, physicists, etc, should be familiar with often place vectorial analysis in the beginning or at least include it in the book type encyclopedia (a collection of topics and methods) of math for applied uses [7].

Vectors not only make up fundamental basis for fluid dynamics, but also for math and physics.  In fact it is an underlying foundation in math and physics sciences. Einstein used vector notation to develop and describe his relativity theories. Many in the early stages of the study of math and physics fields generally see vectors in essential courses such as calculus and general physics. In calculus, vector analysis might appear in a II or III semester of the course as the concepts of divergence, curl, gradient, etc. are brought up and discussed. Vectors appear very early at the very beginning in general college physics courses because almost everything is based upon the vector theory.  Forces, acceleration, velocity, position, momentum, electrostatics, fluid mechanics and dynamics, etc. all utilize vector analysis.

Specifically, since my background is in fluid dynamics from a graduate aerospace engineering education, I will use my experiences to discuss vectors and other topics.  Vectors in fluid dynamics/mechanics can be very useful to describe many fluid concepts and phenomena.  Additionally, vectors are very useful as they are coordinate independent or in other words the user does not have to worry about a coordinates system.

A general representation of a vector can be

\[ \vec{A} = A_1 \vec{e}_1 + A_2\vec{e}_2 + A_3 \vec{e}_3 + \ldots + A_n \vec{e}_n = \sum_{i = 1}^n \]

where the coordinate system can be anything and the number of dimensions \( n \).  This simple relation is why vectors are so useful, powerful, and why they make up the foundations of our math, physics, and related sciences.

The vector may also be written without the arrow above where boldface font is available.

\[ \mathbf{A} = A_1 \mathbf{e}_1 + A_2 \mathbf{e}_2 + A_3 \mathbf{e}_3 + \ldots + A_n \mathbf{e}_n \]

Scalars according to Serre [ ],

"...are elements of some field \( k \) (or \( K \)), or sometimes of a ring \( R \)."

In progress...


[1] K. Karamcheti. Principles of Ideal-Fluid Aerodynamics. John Wiley & Sons, Inc., New York, NY. 1966

[2] R. L. Panton. Incompressible Flow. (3rd ed.). John Wiley & Sons, Inc. Hoboken, NJ. 2005

[3] M. E. O’Neill & F. Chorlton. Viscous and Compressible Fluid Dynamics. Ellis Horwood Limited. Chichester, UK. 1989

[4] T. C. Papanastasiou, G. C. Georgiou, & A. N. Alexandrou. Viscous Fluid Flow. CRC Press. Boca Raton, FL. 2000

[5] M. T. Schobeiri. Fluid Mechanics for Engineers - A Graduate Textbook. Springer.
Berlin, Germany. 2010

[6] R. Aris. Vectors, Tensors and the Basic Equations of Fluid Mechanics. Dover Publications.
New York, NY. 1990

[7] G. B. Arfken & H.-J. Weber, Mathematical Methods for Physicists (6th ed.). Elsevier Academic Press. Burlington, MA. 2005

[ ] D. Serre. Matrices: Theory and Applications. Springer-Verlag New York, Inc., New York, NY. 2002

[ ] D. Serre. Matrices: Theory and Applications. 2nd ed. Springer Science+Business Media, LLC., New York, NY. 2010

Sunday, September 11, 2011

Libre Office - Word wrapping, turning off the automatic hyphenation

I don't use the open source/free office suites much since I use LaTeX for pretty much everything, even slide presentations. The two office suites that have been connected to Ubuntu are Open Office and Libre Office. They seem pretty similar to me, and I don't know what the differences are. Anyways, my wife was using my laptop and had to use Libre Office for the word document program to update a CV she had done in Word. For some reason the word wrapping is set to hyphenate automatically. To turn this off simply go to Format --> Paragraph then select the Text Flow tab and uncheck the Automatically box under the Hyphenation section. It's at the top and the first choice.

Friday, September 9, 2011

Hele-Shaw Flow

I am beginning to add some post which I encounter in class or research which will catalog some various topics and discussion. This particular post is concerned with Hele-Shaw Flow.

According to Cohen and Kundu [1, 2], Hele-Shaw flow is defined as the flow between objects which are short distances apart or between very small gaps such as tribology or the theory of flows in mechanical bearings. The Hele-Shaw flow occurs for low Reynolds numbers, also known as creeping flow, and remarkably, produces inviscid-like flow visualization. Since the Reynolds number is defines as a length scale times the fluid density times the speed of the fluid divided by the kinematic viscosity or
\( \mathrm{Re} = \dfrac{\rho U h}{ \mu} = \dfrac{U h}{ \nu} \)
the Reynolds number value becomes very small if the distance of the gap is small, \( h \), and even smaller if the fluid speed is slow, \( U \). Experimentalist can get the number even lower by using large dynamic viscosity property fluids, \( \nu \). When an object is place in the gap and fills that space then it has been observed to mimic potential flow theory values around an object [3].

In progress...


[1] I. M. Cohen & P. K. Kundu. Fluid Mechanics. (2nd ed.). Academic Press, San Diego, CA. 2002

[2] I. M. Cohen & P. K. Kundu. Fluid Mechanics. (4th ed.). Academic Press, Burlington, MA. 2008

[3] P. A. A. Narayana & K. N. Seetharamu. Engineering Fluid Mechanics. Alpha Science International, Ltd, Middlesex, UK. 2005

Best New Feature of Ubuntu Oneric - GNOME Shell | Tech Drive-in

Best New Feature of Ubuntu Oneric - GNOME Shell | Tech Drive-in

Sweet, some good news regarding GNOME 3, Unity, and Ubuntu!!

Thursday, September 8, 2011

Some references for vector calculus and analysis

Here are some good resources to look at for vector calculus and analysis including linear algebra and matrices.

[1] K. Karamcheti. Principles of Ideal-Fluid Aerodynamics. John Wiley & Sons, Inc., New York, NY. 1966

[2] W. Kaplan. Advanced Calculus (5th ed.). Addison-Wesley. 2002

[3] G. B. Arfken & H.-J. Weber, Mathematical Methods for Physicists (6th ed.). Elsevier Academic Press. Burlington, MA. 2005

[4] R. Aris. Vectors, Tensors and the Basic Equations of Fluid Mechanics. Dover Publications. New York, NY. 1990

[5] A. I. Borisenko and I. E. Tarapov. Vector and Tensor Analysis with Applications, (translated by R. A. Silverman). Dover Publications Inc., Mineola, NY. 1979 (originally published in 1968 by Prentice-Hall, Inc.

[6] H. M. Schey. Div, Grad, Curl, and All That: An Informal Text on Vector Calculus, 3rd ed. W. W. Norton \& Company, New York, NY. 1997

[7] H. M. Schey. Div, Grad, Curl, and All That: An Informal Text on Vector Calculus, 4th ed. W. W. Norton \& Company, New York, NY. 2005

[8] K. R. Reddy, S. Raghavan, and D.V.N. Sarma. Elements of Mechanics, Universities Press (India) Limited, Hyderabad, India. 1994.

[9] C.-T. Tai. General Vector and Dyadic Analysis: Applied Mathematics in Field Theory, 2nd ed. Wiley-IEEE Press, New York, NY. 1997.

[10] J. Betten. Creep Mechanics, 2nd ed. Springer, Berlin, Germany. 2005.

[11] J. Betten. Creep Mechanics, 3rd ed. Springer, Berlin, Germany. 2008.

[12] J. C. Slattery. Advanced Transport Phenomena, Cambridge University Press, Cambridge, UK. 1999.

[13] F. Irgens. Continuum Mechanics Springer, Berlin, Germany. 2008.

[14] P. J. Pahl and R. Damrath. Mathematical Foundations of Computational Engineering: A Handbook Springer, Berlin, Germany. 2001.

[15] M. T. Schobeiri. Fluid Mechanics for Engineers - A Graduate Textbook. Springer.
Berlin, Germany. 2010

In progress...to be continued.