CSS

Thursday, December 15, 2011

Basic Physics Macros

Continuing from my post LaTeX Macros for Personal Notes, I'd like to discuss some macros for physics.

I am using the "ISEE" approach to tackling examples, where we have four major steps:

  1. "Identify" what do we have and what are we looking for?
  2. "Set Up" what are the relevant concepts and equations? Set up the equations.
  3. "Execute" Carry out the scratch work
  4. "Evaluate" Look back, reflect, what were the key points and key ideas?

We are working with a lot of examples, and the examples are long (compared to math!). So we need to indicate when the examples are done.

Following Euclid, we introduce a \qefsymbol which is used at the end of examples and constructions. This is done just as QED is used at the end of proofs.

I will use the amsthm package.

\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[chapter]
\newtheorem{prop}[thm]{Proposition}

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{ex}[thm]{Example}
\newtheorem{fact}{Experimental Fact}
\newtheorem{prob}[thm]{Problem}
\newtheorem{construction}[thm]{Construction}
\newtheorem{con}[thm]{Conjecture}
\newtheorem*{notation}{Notation}
\newtheorem*{assume}{Assumption}
\newtheorem*{quest}{Question}

\theoremstyle{remark}
\newtheorem{rmk}[thm]{Remark}
\newtheorem{sch}[thm]{Scholium}

\newcommand\qefsymbol{\ensuremath\blacksquare}
%{\ensuremath\triangle} % perhaps \ensuremath\triangle if one prefers...

\makeatletter
\newenvironment{example}{\begin{ex} %
  \let\qedsymbol\qefsymbol % this is a temporary "let"
  \pushQED{\qed}}%
  {\popQED\@endpefalse\end{ex}}

\newenvironment{construct}%
  {\begin{construction}\pushQED{\qed}}%
  {\popQED\end{construction}}
\makeatother

Now, to keep track of which step of ISEE we are at, I'd like to introduce the following code:

\font\manual=manfnt

\newcommand\identify{\noindent\llap{\manual\char'170\rm\kern.5em}\textbf{Identify:}}
\newcommand\setup{\noindent\llap{\manual\char'170\rm\kern.5em}\textbf{Set up:}}
\newcommand\execute{\noindent\llap{\manual\char'170\rm\kern.5em}\textbf{Execute:}}
\newcommand\evaluate{\noindent\llap{\manual\char'170\rm\kern.5em}\textbf{Evaluate:}}

There are other matters to discuss, like units and so forth, which I'll tackle next time...

MetaPost, Plotting, and numerical precision

So, to write up diagrams in LaTeX, you need to use Metapost. But Metapost doesn't use floating point arithmetic.

As Claudio Beccari's "Floating point numbers and METAFONT, METAPOST, TEX, and PostScript Type 1 fonts" (TUGboat [pdf]) notes, 32 bit integers are used to represent real numbers. The first 16 bits form the fractional part, 14 bits the integer part, 1 bit for the sign, and 1 bit for special purposes.

So, that means we have 16 log(2)/log(10) digits of precision, or about 4 digits. Now lets remember:

1 PS point = 1.00375 points
1 pica = 12 PS points
1 inch = 72 PS points = 72.27 points = 6 pica
1 cm = 28.3464567 PS points = 2.36220472 pica

We have precision of 2-16 points, or about 0.000868055556 inches, or 0.00220486111 centimeters.

That's decent for output but not for intermediate computations. For example, if we were to plot xx, we may lose a lot of precision.

Plots in Metapost

Lets consider a simple plot of $f(x)=x^{2}$.

numeric u;
u := 1pc; % units

vardef f(expr x) = x*x enddef;

beginfig(0)
  % draw the axes
  drawdblarrow (-3u-ahlength,0)--(3u+ahlength,0);
  drawdblarrow (0,0-2ahlength)--(0,9u+ahlength);

  % plot the function
  draw (-3u,f(-3)*u)
    for i=-3+0.05 step 0.05 until 3:
    ..(i*u,f(i)*u)
  endfor;
endfig;
end;

Remember that ahlength is the length of the arrow head.

This basic scheme can be generalized if we add numerics x0 and x1 which control where the plot begins and ends (respectively), as well as the step size dx which is taken to be "small enough".

Revising our code:

numeric u;
numeric dx;
u := 1pc; % units
dx := 0.05; 

vardef f(expr x) = x*x enddef;

beginfig(0)
  numeric x[];

  x0 := -3; % start plotting at x=-3
  x1 := 3; % stop plotting at x=+3

  % draw the axes
  drawdblarrow (x0*u-ahlength,0)--(x1*u+ahlength,0); % x-axis
  drawdblarrow (0,0-2ahlength)--(0,f(x1)*u+ahlength); % y-axis

  % plot the function
  draw (x0*u,f(x0)*u)
    for i=x0+dx step dx until 3:
    ..(i*u,f(i)*u)
  endfor;
endfig;
end;

This makes things a little complicated. What we are doing is computing the pairs (x,y) and then scaling them, then plotting.

The dx is the change in x before scaling. The points plotted have a change in x that amounts to dx*u=0.6pt approximately.

But we can do more! If we specify how big we want this plot to be, i.e. it has to fit within X inches, then we can determine the scale u by this.

Specifically, u := X/(x[1]-x[0]) is the scale factor definition.

If we demand that dx*u=0.6pt hold, which is "sufficiently good" for practical purposes, then we also define dx := (3pt)/(5*u).

The interested reader may want to read Learning Metapost by Doing.

LaTeX Macros for Personal Notes

So last time, I discussed the notion of personal mathematical notes (as opposed to expository mathematical notes) and would like to discuss some LaTeX macros which enable writing personal notes.

The basic scheme is to write in "chunks" (to borrow a term from literate programming). We've all seen examples of this, Bagchi and Wells refer to it as "labeled style" in their paper Varieties of Mathematical Prose

But each "chunk" is a self-contained concept, example, discussion, etc.

For a good example of this writing style, see On Euler's Footsteps.

LaTeX Code

I am taking CWEB's style. So, the code listing I have is as follows:

% chunk.sty
\ProvidesPackage{chunk}[2011/12/15 Cunking commands for personal notes]
\makeatletter

\@ifundefined{@addpunct}{
  \def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi}
  }{}

\newcounter{chunk@ctr}

\newcommand\M{\medbreak\noindent%
  \refstepcounter{chunk@ctr}%
  \textbf{\thechunk@ctr\@addpunct{.}}\quad\ignorespaces}

% deprecated macro:
% \newcommand\N[1]{\M\textbf{#1\@addpunct{.}}\quad\ignorespaces}

% superior implementation:

\def\N{\@ifstar
        \NStar%
        \NNoStar%
}
\def\NStar#1{\medbreak\noindent\textbf{#1\@addpunct{.}\quad}\ignorespaces}
\def\NNoStar#1{\M\textbf{#1\@addpunct{.}\quad}\ignorespaces}

% permits writing \N*{Un-numbered chunk} for a chunk
% without a numeric label!

\makeatother
% end of cunk.sty

Note that it is completely self-contained code, and you do not need amsgen package. If you already loaded it, then no worries!

Each chunk is numbered. We use \M for unlabeled chunks, and \N{My favorite chunk!} for labeled chunks (which is labeled "My favorite chunk!").

So lets write up some example usage:

\documentclass{article}
\usepackage{chunk} % make it in the same directory
% or put it in ~/texmf/tex/latex/ and run "sudo texhash"
\title{Example Notes}
\author{Alex Nelson}
\date{\today}
\begin{document}
\maketitle

\N{Introduction}
Today we will solve all the problems in the universe. 

\M Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis 
aute irure dolor in reprehenderit in voluptate velit esse 
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 
cupidatat non proident, sunt in culpa qui officia deserunt 
mollit anim id est laborum.

\N{Conclusion?} Nobel Prize please!

\end{document}

As far as bugs, I don't think there are any...it's too minimalistic!

To Do

The chunk counter is rather minimalistic, and doesn't count within any section. This has to be changed by hand if the user wants to use these macros and number chunks within each chapter...

In the time honored tradition of mathematicians, this exercise is left for the reader!

Tuesday, December 13, 2011

Personal v. Expository notes

Personal Notes Are For One's Self

I recently stumbled across Thinking Mathematically by J. Mason, L. Burton, K. Stacey (Amazon) which has an interesting approach to writing personal mathematical notes.

I say "personal" as opposed to "expository" because they are really personal scratchwork rather than explanations.

What's really cute is Mason, et al., espouse a sort of "markup language" approach (they call it a "rubric"). Let me review this a little.

When "entering" a mathematics problem, there are three things to ask ourselves, which constitute the entry phase:

  1. What am I know? (What is given?)
  2. What do I want?
  3. What can I introduce?
Know, want, introduce. These three things we should always, always, always ask ourselves! Even in long proofs, we should ask ourselves these questions! We should ask ourselves when we get stuck!

With introducing stuff. . . we can do several types of introduction.

Notation:
Assigning values and meanings to variables.
Organization:
Recording and arranging what you know.
Representation:
Choose particular representatives which are easier to manipulate.
Bear in mind that rephrasing the question is particularly useful.

Now, reviewing your work is also critical. There are several different ways of doing this:

Check:
the resolution;
Reflect:
on the key ideas and key moments;
Extend:
to a wider context.
The best way to get the most out of reviewing is to write up your resolution for someone else, in such a way that one can follow what you have done and why.

We can check several things:

  1. Check calculations;
  2. Check arguments to ensure computations are appropriate;
  3. Consequences of conclusions to see if they are reasonable;
  4. Check that the resolution fits the question.
This is sort of subconsciously done.

We also reflect in finitely many ways:

  1. What are the key ideas and key moments?
  2. What are the implications of conjectures and arguments?
  3. Can the resolution be made clearer?
It helps one see things that otherwise would have been missed.

As far as extending, one should really be generalizing the problem. For example: how many squares are on a 3 × 3 chess board? There are 9 instances of 1 × 1 squares, 4 instances of 2 × 2 squares, and a single 3 × 3 square. Thus there are 14 squares altogether. Now, to extend:

  1. How many squares are on an n × n board?
  2. How many rectangles are on a 3 × 3 board? Extend this to n × n boards.
  3. What if we start with an m × n board? How many squares are there in it?
  4. Why work only in two dimensions?
  5. Why count squares with edges parallel to the original?

When stuck, try re-entering the entry phase. This can be done through:

  1. Summarize everything known and wanted;
  2. Rephrase the question in a more appealing way;
  3. Re-read or re-digest the problem.
This is useful sometimes.

Conjecturing is a cyclic four-step procedure:

  1. Articulate a conjecture (and while making it, believe it);
  2. Check the conjecture covers all known cases and examples;
  3. Distrust the conjecture. Try to refute it by finding a nasty case or example; use it to make predictions which can be checked;
  4. Get a sense of why the conjecture is right, or how to modify it, on new examples (go back to step 1).
Note you can start anywhere in this procedure.

It's not too long until one gets to a state where one says "I don't believe it's possible" which leads to the questions

  1. Why can it not be done?
  2. All right, what can be done?
Asking "What can be done" is a critical step in conjecturing.

Now, critical mathematical thinking should be nurtured by thinking three things while doing or reading a proof:

  1. Every statement made should be treated as a conjecture.
  2. Try to defeat and prove conjectures simultaneously.
  3. Look critically at other people's proofs.
There are some mathematical registers that some authors suggest using while writing notes. The collection is sometimes called a rubric:
I Know:
What is given? What is known?
I Want:
What do we want to prove?
Introduce:
Try contributing some:
Notation:
Assigning values and meanings to variables.
Organization:
Recording and arranging what you know.
Representation:
Choose particular representatives which are easier to manipulate.
Stuck!:
"I do not understand...", "I do not know what to do about...", "I cannot see how to...", "I cannot see why..." — try going back to the entry portion "want/know/introduce", or make a conjecture.
AHA!:
Whenever you have a good idea, write it down. Usually, they are of the form: "AHA! Try...", "AHA! Maybe...", or "AHA! But why...".
Check:
the mathematics. This means:
  1. Check calculations;
  2. Check arguments to ensure computations are appropriate;
  3. Consequences of conclusions to see if they are reasonable;
  4. Check that the resolution fits the question, i.e., our answer is the answer to the question asked.
Reflect:
meditate on:
  1. What are the key ideas and key moments?
  2. What are the implications of conjectures and arguments?
  3. Can the resolution be made clearer?
Extend:
generalize to other settings.
The real trick is to change "I'm stuck, panic!" to "I'm stuck, okay, so what can be done about it?"

Monday, December 12, 2011

MathJax, Updates

Updates

I've just updated the design of the blog. I think it looks negligibly better.

I'll also try to write more here rather than on my notebk's wiki.

I posted some exercises for Sean [pdf] which are fun calculus problems.

I suspect what I'll do next is write up my notes on differential geometry from Osserman's course I audited a couple years ago, as well as my notes on algebraic topology (from Dr Schwarz's courses). Then I'll work on spin geometry, "commutative geometry", analysis, and so on.

By "commutative geometry", I really mean spectral triples using commutative rings (Here I am sloppy, but meh I am a sloppy person!). It is also called Differential Calculus over Commutative Algebras, although there are no real texts on the subject...

I'll have to review the prime spectrum of the commutative ring $C(M)$ of continuous functions on a topological space $M$ and how it relates to the topology of $M$.

If we let $M$ be a smooth manifold, then we work with $C^{\infty}(M)$ — I am told there is a theorem due to Shields which says if $M$ and $N$ are smooth manifolds and $C^{\infty}(M)$ is isomorphic to $C^{\infty}(N)$ then $M$ and $N$ are diffeomorphic. How interesting! But I cannot find this theorem...

At any rate, vector bundles over $M$ may be considered by looking at the projective modules over $C^{\infty}(M)$.

We consider algebraic analogs for sections, vector fields, covector fields, and so on. It is really quite cute.

Noncommutative geometry is similar in setting up a dictionary between "algebraic stuff" and "geometric stuff", at least how Connes approaches it. It's just that the "geometric stuff" we work with is a smooth Riemannian manifold $M$ equipped with a spin structure, we consider spin bundles over it, and so on.

MathJax

I am experimenting with MathJax on blogger, so bear with me people.

My reference for this subject is the thread at stackexchange on it.

Consider the "Harmonic Series" \[ \sum^{\infty}_{n=1}\frac{1}{n}=1+\frac{1}{2}+\frac{1}{3}+\cdots \] which diverges famously.

MathJax uses the \(...\) or $...$ for "inline mathematics" and \[...\] or $$...$$ for "display math", e.g., the mathematics produced above.

I don't know whether to keep it or not, because MathJax is sluggish on some computers. But it is the "way of the future", like blimps and autogyros.