1 % TeX code generated by batTeX. Don't edit this file; edit the
2 % input file dimdem2.tex instead.
3 \documentclass[12pt
]{article
}
10 \title{A new Maxima package for dimensional analysis
}
11 \author{Barton Willis \\
12 University of Nebraska at Kearney \\
20 \subsubsection*
{Introduction
}
22 \noindent This
document demonstrates some of the abilities
23 of a new Maxima package for dimensional analysis. Maxima
24 comes with an older package dimensional analysis that is
25 similar to the one that was in the commercial Macsyma system.
26 The software described in this
document differs greatly from
29 The new dimensional analysis package was written by Barton Willis of
30 the University of Nebraska at Kearney. It is released under the terms of
31 the General Public License GPL. You may contact the author at
32 \begin{verb
} willisb@unk.edu
\end{verb
}.
35 \subsubsection*
{Installation
}
37 To use this package, you must first download the file
38 {\tt dimension.mac
}; it may be found at
39 \begin{verb
} www.unk.edu/acad/math/people/willisb
\end{verb
}.
40 After downloading, copy it into a directory that Maxima
44 \subsubsection*
{Usage
}
46 To use the package, you must first load it. From a Maxima prompt, this
47 is done using the command
52 load("dimension.mac");
61 \noindent To begin, we need to assign dimensions to the
62 variables we want to use. Use the
{\tt qput
} function to do this;
63 for example, to declare $x$ a length, $c$ a
64 speed, and $t$ a time, use the commands
69 qput(x, "length", dimension)$
73 qput(c, "length" / "time", dimension)$
77 qput(t, "time", dimension)$
83 \noindent We've defined the dimensions length and time to be
84 strings; doing so reduces the chance that they will conflict
85 with other user variables. To declare a dimensionless variable
86 $
\sigma$, use $
1$ for the dimension. Thus
91 qput(sigma,
1,dimension)$
96 \noindent To find the dimension of an expression, use the
97 {\tt dimension
} function. For example
102 dimension(
4 * sqrt(
3) /t);
110 dimension(x + c * t);
118 dimension(sin(c * t / x));
126 dimension(abs(x - c * t));
134 dimension(sigma * x / c);
142 dimension(x * sqrt(
1 - c * t / x));
151 \noindent {\tt dimension
} applies
{\tt logcontract
} to its
152 argument; thus expressions involving a difference of logarithms
153 with dimensionally equal arguments are dimensionless; thus
158 dimension(log(x) - log(c*t));
170 \noindent {\tt dimension
} is automatically maps over lists. Thus
177 dimension(
[42, min(x,c*t), max(x,c*t), x^^
4, x . c
]);
183 \left[ 1,length,length,length^
4,
{{length^
2}\over{time
}} \right]
188 \noindent When an expression is dimensionally inconsistent,
189 {\tt dimension
} should signal an error
197 {\em Expression is dimensionally inconsistent.
}
204 {\em Expression is dimensionally inconsistent.
}
208 \noindent An
{\em equation\/
} is dimensionally correct
209 when either the dimensions of both sides match or
210 when one side of the equation vanishes. For example
213 dimension(x = c * t);
221 dimension(x * t =
0);
231 \noindent When the two sides of an equation have
232 different dimensions and neither side vanishes,
233 {\tt dimension
} signals an error
243 {\em Expression is dimensionally inconsistent.
}
247 \noindent The function
{\tt dimension
} works with derivatives and
253 dimension('diff(x,t));
259 {{length
}\over{time
}}
263 dimension('diff(x,t,
2));
269 {{length
}\over{time^
2}}
273 dimension('diff(x,c,
2,t,
1));
279 {{time
}\over{length
}}
283 dimension('integrate (x,t));
292 Thus far, any string may be used as a dimension; the other
293 three functions in this package,
294 \begin{verb
} dimension_as_list
\end{verb
},
295 \begin{verb
} dimensionless
\end{verb
}, and
296 \begin{verb
} natural_unit
\end{verb
} all require that each
297 dimension is a member of the list
298 \begin{verb
} fundamental_dimensions
\end{verb
}. The default value is of
304 fundamental_dimensions;
310 \left[ mass,length,time
\right]
314 \noindent A user may insert or delete elements from this list.
315 The function
\begin{verb
} dimension_as_list
\end{verb
} returns the dimension
316 of an expression as a list of the exponents of the
317 fundamental dimensions. Thus
324 dimension_as_list(x);
334 dimension_as_list(t);
344 dimension_as_list(c);
350 \left[ 0,
1,-
1 \right]
354 dimension_as_list(x/t);
360 \left[ 0,
1,-
1 \right]
364 dimension_as_list("temp");
376 \noindent In the last example, "temp" isn't an element of
377 \begin{verb
} fundamental_dimensions
\end{verb
}; thus,
378 \begin{verb
} dimension_as_list
\end{verb
}
379 reports that "temp" is dimensionless. To correct this, append "temp" to the list
380 \begin{verb
} fundamental_dimensions
\end{verb
}
387 fundamental_dimensions : endcons("temp", fundamental_dimensions);
393 \left[ mass,length,time,temp
\right]
399 \noindent Now we have
406 dimension_as_list(x);
412 \left[ 0,
1,
0,
0 \right]
416 dimension_as_list(t);
422 \left[ 0,
0,
1,
0 \right]
426 dimension_as_list(c);
432 \left[ 0,
1,-
1,
0 \right]
436 dimension_as_list(x/t);
442 \left[ 0,
1,-
1,
0 \right]
446 dimension_as_list("temp");
452 \left[ 0,
0,
0,
1 \right]
458 \noindent To remove "temp" from
459 \begin{verb
} fundamental_dimensions
\end{verb
}, use the
{\tt delete
} command
466 fundamental_dimensions : delete("temp", fundamental_dimensions)$
473 The function
{\tt dimensionless
} finds a
{\em basis\/
} for the
474 dimensionless quantities that can be formed from a list of
475 dimensioned quantities. For example
483 dimensionless(
[c,x,t
]);
487 Dependent equations eliminated: (
1)
491 \left[ {{c\,t
}\over{x
}},
1 \right]
495 dimensionless(
[x,t
]);
499 Dependent equations eliminated: (
1)
509 \noindent In the first example, every dimensionless quantity
510 that can be formed as a product of powers of $c,x$, and $t$ is
511 a power of $c t/x$; in the second example, the only
512 dimensionless quantity that can be formed from
513 $x$ and $t$ are the constants.
515 The function
\begin{verb
} natural_unit(e,
[v1,v2,...,vn
])
\end{verb
}
516 finds powers $p_1,p_2,
\dots p_n$ such that
518 \mbox{dimension
}(e) =
\mbox{dimension
} (v_1^
{p_1
} v_2^
{p_2
} \dots v_n^
{p_n
}).
527 natural_unit(x,
[c,t
]);
531 Dependent equations eliminated: (
1)
539 natural_unit(x,
[x,c,t
]);
543 Dependent equations eliminated: (
1)
553 Here is a more complex example; we'll study the Bohr model of
554 the hydrogen atom using dimensional analysis. To make things
555 more interesting, we'll include the magnetic moments of the
556 proton and electron as well as the universal gravitational
557 constant in with our list of physical quantities.
558 Let $
\hbar$ be Planck's constant, $e$ the electron charge, $
\mu_e$ the
559 magnetic moment of the electron, $
\mu_p$ the magnetic
560 moment of the proton, $m_e$ the mass of the electron, $m_p$
561 the mass of the proton, $G$ the universal gravitational constant,
562 and $c$ the speed of light in a vacuum. For this problem, we might
563 like to display the square root as an exponent instead of as a radical;
564 to do this, set
{\tt sqrtdispflag
} to false
571 SQRTDISPFLAG : false$
577 \noindent Assuming a system of units where Coulomb's law is
579 \mbox{force
} =
\frac{\mbox{product of charges
}}{\mbox{distance
}^
2},
588 qput(
%hbar, "mass" * "length"^2 / "time",dimension)$
592 qput(
%%e, "mass"^(1/2) * "length"^(3/2) / "time",dimension)$
596 qput(
%mue, "mass"^(1/2) * "length"^(5/2) / "time",dimension)$
600 qput(
%mup, "mass"^(1/2) * "length"^(5/2) / "time",dimension)$
604 qput(
%me, "mass",dimension)$
608 qput(
%mp, "mass",dimension)$
612 qput(
%g, "length"^3 / ("time"^2 * "mass"), dimension)$
616 qput(
%c, "length" / "time", dimension)$
621 \noindent The numerical values of these quantities may
622 defined using
{\tt numerval
}. We have
627 numerval(
%%e, 1.5189073558044265d-14*sqrt(kg)*meter^(3/2)/sec)$
631 numerval(
%hbar, 1.0545726691251061d-34*kg*meter^2/sec)$
635 numerval(
%c, 2.99792458d8*meter/sec)$
639 numerval(
%me, 9.1093897d-31*kg)$
643 numerval(
%mp, 1.6726231d-27*kg)$
649 \noindent To begin, let's use only the variables $e, c,
\hbar, m_e$, and
650 $m_p$ to find the dimensionless quantities. We have
653 dimensionless(
[%hbar, %me, %mp, %%e, %c]);
657 \left[ {{m_e
}\over{m_p
}},
{{c\,
\hbar}\over{e^
2}},
1 \right]
663 \noindent The second element of this list is the reciprocal of the fine
664 structure constant. To find numerical values, use
{\tt float
}
673 \left[ 5.4461699709874866 \times 10^
{-
4},
137.035990744505,
1.0
680 The natural units of energy are given by
683 natural_unit("mass" * "length"^
2 / "time"^
2,
[%hbar, %me, %mp, %%e, %c]);
689 \left[ c^
2\,m_e,
{{c^
3\,
\hbar\,m_p
}\over{e^
2}} \right]
693 \noindent Let's see what happens when we include
694 will include $
\mu_e,
\mu_p$, and $G$. We have
701 dimensionless(
[%hbar, %%e, %mue, %mup, %me, %mp, %g, %c]);
707 \left[ {{\mu_p}\over{\mu_e}},
{{c^
2\,m_e\,
\mu_e}\over{e^
3}},
{{c^
2
708 \,m_p\,
\mu_e}\over{e^
3}},
{{e^
4\,G
}\over{c^
4\,
\mu_e^
2}},
{{c\,
709 \hbar}\over{e^
2}},
1 \right]
716 To find the natural units of mass, length, time,
717 speed, force, and energy, use the commands
724 natural_unit("mass",
[%hbar, %%e, %me, %mp, %mue, %mup, %g, %c]);
730 \left[ m_p,
{{c^
2\,m_e^
2\,
\mu_e}\over{e^
3}},
{{c^
2\,m_e^
2\,
\mu_p
731 }\over{e^
3}},
{{G\,m_e^
3}\over{e^
2}},
{{c\,
\hbar\,m_e
}\over{e^
736 natural_unit("length",
[%hbar, %%e, %me, %mp, %mue, %mup, %g, %c]);
742 \left[ {{e^
2\,m_p
}\over{c^
2\,m_e^
2}},
{{\mu_e}\over{e
}},
{{\mu_p
743 }\over{e
}},
{{G\,m_e
}\over{c^
2}},
{{\hbar}\over{c\,m_e
}} \right]
747 natural_unit("time",
[%hbar, %%e, %me, %mp, %mue, %mup, %g, %c]);
753 \left[ {{e^
2\,m_p
}\over{c^
3\,m_e^
2}},
{{\mu_e}\over{e\,c
}},
{{
754 \mu_p}\over{e\,c
}},
{{G\,m_e
}\over{c^
3}},
{{\hbar}\over{c^
2\,m_e
759 natural_unit("mass" * "length" / "time"^
2,
[%hbar, %%e, %me, %mp, %mue, %mup, %g, %c]);
765 \left[ {{c^
4\,m_e\,m_p
}\over{e^
2}},
{{c^
6\,m_e^
3\,
\mu_e}\over{
766 e^
5}},
{{c^
6\,m_e^
3\,
\mu_p}\over{e^
5}},
{{c^
4\,G\,m_e^
4}\over{
767 e^
4}},
{{c^
5\,
\hbar\,m_e^
2}\over{e^
4}} \right]
771 natural_unit("mass" * "length"^
2 / "time"^
2,
[%hbar, %%e, %me, %mp, %mue, %mup, %g, %c]);
777 \left[ c^
2\,m_p,
{{c^
4\,m_e^
2\,
\mu_e}\over{e^
3}},
{{c^
4\,m_e^
2\,
778 \mu_p}\over{e^
3}},
{{c^
2\,G\,m_e^
3}\over{e^
2}},
{{c^
3\,
\hbar\,
779 m_e
}\over{e^
2}} \right]
784 \noindent The first element of this list is the rest mass energy of the
788 The dimension package can handle vector operators such as
789 dot and cross products, and the vector operators div, grad, and curl.
790 To use the vector operators, we'll first declare them
806 \noindent Let's work with the electric and magnetic fields;
807 again assuming a system of units where Coulomb's law is
809 \mbox{force
} =
\frac{\mbox{product of charges
}}{\mbox{distance
}^
2}
811 the dimensions of the electric and magnetic field are
815 qput(e, sqrt("mass") / (sqrt("length") * "time"), dimension)$
819 qput(b, sqrt("mass") / (sqrt("length") * "time"),dimension)$
822 and the units of charge density $
\rho$ and current density $j$ are
826 qput(rho, sqrt("mass")/("time" * "length"^(
3/
2)), dimension)$
830 qput(j, sqrt("mass") / ("time"^
2 * sqrt("length")), dimension)$
833 Finally, declare the speed of light $c$ as
837 qput(c, "length" / "time", dimension);
843 {{length
}\over{time
}}
846 \noindent Let's find the dimensions of
847 $\|
\mathbf{E
} \|^
2,
\mathbf{E
} \cdot \mathbf{B
},
848 \|
\mathbf{B
} \|^
2$, and $
\mathbf{E
} \times \mathbf{B
} / c$. We have
857 {{mass
}\over{length\,time^
2}}
867 {{mass
}\over{length\,time^
2}}
877 {{mass
}\over{length\,time^
2}}
881 dimension((e ~ b) / c);
887 {{mass
}\over{length^
2\,time
}}
893 \noindent The physical significance of these quantities becomes more apparent
894 if they are integrated over $
\mathbf{R^
3}$. Defining
899 qput(v, "length"^
3, dimension);
910 \noindent We now have
914 dimension('integrate(e.e, v));
920 {{length^
2\,mass
}\over{time^
2}}
924 dimension('integrate(e.b, v));
928 {{length^
2\,mass
}\over{time^
2}}
932 dimension('integrate(b.b, v));
936 {{length^
2\,mass
}\over{time^
2}}
940 dimension('integrate((e ~ b) / c,v));
945 {{length\,mass
}\over{time
}}
948 \noindent It's clear that $\|
\mathbf{E
} \|^
2,
\mathbf{E
} \cdot \mathbf{B
}$
949 and $\|
\mathbf{B
} \|^
2$ are energy densities while
950 $
\mathbf{E
} \times \mathbf{B
} / c$ is a momentum density.
952 Let's also check that the Maxwell equations are
953 dimensionally consistent.
956 dimension(DIV(e)=
4*
%pi*rho);
960 {{mass^
{{{1}\over{2}}}}\over{length^
{{{3}\over{2}}}\,time
}}
964 dimension(CURL(b) - 'diff(e,t) / c =
4 *
%pi * j / c);
968 {{mass^
{{{1}\over{2}}}}\over{length^
{{{3}\over{2}}}\,time
}}
972 dimension(CURL(e) + 'diff(b,t) / c =
0);
976 {{mass^
{{{1}\over{2}}}}\over{length^
{{{3}\over{2}}}\,time
}}
980 dimension(DIV(b) =
0);
984 {{mass^
{{{1}\over{2}}}}\over{length^
{{{3}\over{2}}}\,time
}}
988 \subsubsection*
{Conclusion and Future directions
}
990 Algorithmically, the dimensional analysis package is straightforward;
991 nevertheless, there are many details, such as correctly setting
992 option variables for linsolve, that need to be tended to. Let me know
993 when you find a bug; I'll try to fix it. There may be some operators that
994 aren't handled; again, let me know what is missing and I'll try
997 Eventually, I hope that this package will work smoothly with the new physical
1000 I could add predefined dimensions for derived units such as momentum, charge,
1001 density, etc.; however, given the plethora of schemes for
1002 electromagnetic units, I'm hesitant to do this.
1004 This documentation was processed by bat
\TeX, a Maxima preprocessor
1005 for
\TeX. The bat
\TeX software is also available from the author's