Sunday, January 22, 2012

MathJax

Let's follow up on a few previous posts (a calculation of d/dt of the total energy in a gravitational field, a post about typesetting math, and an introductory exploration of LaTeX). I'm grateful for a comment from a reader, with a link to this page, which makes it pretty clear that, yes, you can use their server to get the script in your pages.

So that's what we'll do. I had to modify the LaTeX commands a bit for this but it's mostly the same as before.


[ UPDATE: I do see a problem, now. The script applies to all LaTeX on the page, which if you go to the main page for the blog, includes the previous post... Just click on the post title, to see the original formatting code. ]



$\mathbf{F} = m\mathbf{a}= m\ddot{\mathbf{r}}
= m\frac{d^2}{dt^2}\mathbf{r}$

$\mathbf{F} = -$$\nabla$$V(\mathbf{r})$

$E = \frac{1}{2}m|\dot{\mathbf{r}}|^2+ V$

$\frac{d}{dt} E = \frac{d}{dt} ( \frac{1}{2}m
|\dot{\mathbf{r}}|^2 + V )$ $= ?$


$|\dot{\mathbf{r}}|^2 = |\dot{\mathbf{r}}|
|\dot{\mathbf{r}}| = \dot{\mathbf{r}}
\cdot\dot{\mathbf{r}}$

$\frac{d}{dt}\frac{1}{2}m|\dot{\mathbf{r}}|^2
= \frac{1}{2}m\frac{d}{dt}(\dot{\mathbf{r}}
\cdot\dot{\mathbf{r}})$$ = m\dot{\mathbf{r}}\cdot\ddot{\mathbf{r}}$$ = \dot{\mathbf{r}}\cdot-($$\nabla$$V$$)$


$\nabla$$V$ $= < \frac{\partial{V}} {\partial{x}}, \frac{\partial{V}} {\partial{y}},\frac{\partial{V}} {\partial{z}} >$

$\dot{\mathbf{r}}$ = $<$ $\frac{dx}{dt}$, $\frac{dy}{dt}$,$\frac{dz}{dt}$$ >$

$\nabla$$V$ $\cdot$$\dot{\mathbf{r}}$ $= < \frac{\partial{V}} {\partial{x}} \frac{dx}{dt}, \frac{\partial{V}} {\partial{y}} \frac{dy}{dt}, \frac{\partial{V}} {\partial{z}}\frac{dz}{dt}>$$=\frac{d}{dt}V$


$\frac{d}{dt} E = \frac{d}{dt} ( \frac{1}{2}m
|\dot{\mathbf{r}}|^2 + V )$ $= ?$

$\frac{d}{dt}$E $= \dot{\mathbf{r}}$$\cdot$(-$\nabla$V) + $\nabla$V $\cdot$ $\dot{\mathbf{r}}$ = 0

Saturday, January 21, 2012

Typesetting, again

Here are the equations from the last post, in LaTeX. It took about two hours, fairly painstaking work, but I think it looks pretty good..

UPDATE:

Here is a nice simple reference for LaTeX. I started with "LaTeX Bootcamp" (pdf).



$\mathbf{F} = m\mathbf{a}= m\ddot{\mathbf{r}}
= m\frac{d^2}{dt^2}\mathbf{r}$

$\mathbf{F} = -$$\nabla$$V(\mathbf{r})$

$E = \frac{1}{2}m\norm{\dot{\mathbf{r}}}^2+ V$

$\frac{d}{dt} E = \frac{d}{dt} (\frac{1}{2}m
\norm{\dot{\mathbf{r}}}^2 + V)$

\hspace*{2em}$ = ?$\\

$\norm{\dot{\mathbf{r}}}^2 = \norm{\dot{\mathbf{r}}}
\norm{\dot{\mathbf{r}}} = \dot{\mathbf{r}}
\cdot\dot{\mathbf{r}}$

$\frac{d}{dt}\frac{1}{2}m\norm{\dot{\mathbf{r}}}^2
= \frac{1}{2}m\frac{d}{dt}(\dot{\mathbf{r}}
\cdot\dot{\mathbf{r}})$

\hspace*{2em}$ = m\dot{\mathbf{r}}\cdot
\ddot{\mathbf{r}}$

\hspace*{2em}$ = \dot{\mathbf{r}}\cdot-($
$\nabla$$V$$)$\\

$\nabla$$V$$ = <\frac{\partial{V}} {\partial{x}}, \frac{\partial{V}} {\partial{y}},\frac{\partial{V}} {\partial{z}}>$

$\dot{\mathbf{r}}$ = $<$$\frac{dx}{dt}$, $\frac{dy}{dt}$,$\frac{dz}{dt}$$>$

$\nabla$$V$$\cdot$$\dot{\mathbf{r}}$$=< \frac{\partial{V}} {\partial{x}} \frac{dx}{dt}, \frac{\partial{V}} {\partial{y}} \frac{dy}{dt}, \frac{\partial{V}} {\partial{z}}\frac{dz}{dt}>$

\hspace*{2em}$=\frac{d}{dt}V$\\

$\frac{d}{dt}$E = $\dot{\mathbf{r}}$$\cdot$(-
$\nabla$V ) + $\nabla$V $\cdot$ $\dot{\mathbf{r}}$ = 0

Vector fun

In Marsden & Tromba's Vector Calculus, I found the following problem. It involves time-derivatives of the position vector r(t), for which we're using the dot notation of the physicists (and Newton).

In the first panel, we have Newton's second law, then the statement that the force is minus the gradient of the gravitational potential V, followed by a calculation of the total energy in the system. The problem is to compute d/dt of the energy. (hint)


The answer is given in the last panel, below. According to the book, it's a "simple calculation."

The first step is to compute d/dt of the kinetic energy. We use the formula from above, plus a trick to convert the squared term back to the dot product of dr/dt with itself. Then we use the chain rule, and finally, the definition of the force in terms of the gradient of the potential.


Calculation of d/dt of the potential energy puzzled me for quite a while, though it really shouldn't have. My solution was to work backward from the answer, as shown.


We put the two results together, and notice that they cancel. Surprise!

Typesetting math

This post is really just a note to myself about something I need to investigate more. The problem I'd like to solve is how to format mathematical equations for the web. You can see the caveman approach on most of my posts here, like this one.

I just make a table in html

<div style="overflow-x: scroll;">
<table bgcolor="#ffffb0" border="0" padding="4">
<tbody>
<tr><td><pre style="font-family: monaco;">

I like the background color, and vary it depending on whether the content is code or output from a program.

It might be nice to have something prettier. So, looking around, I happened across MathJax, and also this post which explains how to use it on Blogger.

Here's a screenshot of the example:

The method used in the post is to load the script from the mathjax server, but I think what I'm probably supposed to do is direct people to resource on my (nonexistent) server. OTOH, they link to the post on the mathjax site.

What I'll probably do is just look into how to use LateX and then post screenshots.

Any thoughts?

Cycloid


While working through the MIT ocw lectures on multi-variable calculus (Prof. Denis Auroux, here), I particularly enjoyed his discussion about the cycloid. Above is a graphic from the wikipedia article (actually the graphic is an animated gif, but I grabbed one of the frames). The red curve is generated by the motion of a point on the edge of a rolling circle.

In addition to the beauty of the curve, it turns out that the length and area under the curve have simple values that are relatively easy to calculate. See wikipedia for the details.

One thing the article doesn't explain is how to get the "parametrization" for the curve. This looks hard, but is made easy by using vectors. It's explained in the second half of Auroux's fifth lecture.

Another thing the article doesn't explain is how to integrate

√(2 - 2 cos t)

Start from the double angle formula:

cos 2s = cos2s - sin2s
cos 2s = 1 - 2 sin2s
2 sin2s = (1 - cos 2s)
2 sin2(t/2) = (1 - cos t)

It's straightforward from there.

The Mathworld article is also quite nice, and references a famous challenge in history, the one which led to this quote (in reference to Newton):


"Ah, I know the lion by his paw!"

Tuesday, January 10, 2012

Pilgrim's progress

Lately I've been working (again) on understanding multi-variable calculus. I always wished I had time to cover this material in college, but I took lots of courses in biochemistry and molecular biology instead. I wanted to put up the best resources I've found for this so far.

First, and no surprise, the ocw videos at MIT by Denis Auroux (here). I am currently at #25, about to jump off into integrals in 3D space. (It's my second time to get this far). This time I think I really have everything under control. The proof of Green's theorem was perfect, a kind of mathematical satori.

I also work through everything in Gilbert Strang's book as well. I need to read carefully there, because he's so concise, but his insight is just incredible. Check out the proof of the flux version of Green's theorem.

Two more are recently discovered resources that are especially helpful because they develop everything slowly but completely:

Paul's lecture notes
A beautiful set of pages from someone at U Minnesota

All highly recommended.