MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: beginner question regarding units in equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123913] Re: beginner question regarding units in equations
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 30 Dec 2011 07:04:15 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <12274722.43163.1325142914577.JavaMail.root@m06>

First some general comments on using units in Mathematica. These are not
absolutely obligatory but I think they considerable ease the path. Then a
small pitch for the ExtendUnits package.

1) Units are part of the data and not part of the equations. Solve equations
in pure symbolic form first and then, when you have a symbolic expression
for the answer, substitute the data with the units.

Suppose you have some variables, say h, w, m for height, width, mass in your
problem. Don't write expressions such as:

h = 1.5 Centimeter
w = 5 Centimeter
m = 5 Gram

The reason is that this assigns values to these symbols, inserts the numbers
and units directly into equations, and no longer allows the equations to be
solved with these symbols. (You might have a variation of the problem where
you wanted to solve for h with some other variable now given a data value.)
Mathematica generally has an easier time solving equations without units and
approximate numbers.

Rather, write a rule for the data, say:

data1 = {h -> 1.5 Centimeter, w -> 5 Centimeter, m -> 5 Gram}

Then after you have solved your symbolic equations to obtain a symbolic
expression for the answer you can substitute the data. (/. Is the shortcut
for ReplaceAll.)

symbolicAnswerExpression /. data1

Then you can use the Units package to Convert to whatever consistent unit
you want.

2) The ExtendUnits package ($30) from my web site has many features that
make it easier to use units.

Books or papers may use unit names other than those allowed by Mathematica
Units. For example, Kilometer is not a Mathematica unit and can't directly
be used. Nor could you use something like gm, say, for Gram, or mph for
Mile/Hour. ExtendUnits allows you to install new names as unit symbols (for
the duration of the Mathematica session.)

You can't use Mathematica numerical routines with expressions that contain
units, for example plotting or using NDSolve or NSolve. In engineering work
symbolic expressions are often written that use implied input and output
units. In other words, the input would now consist of pure numbers with
implied units. ExtendUnits contains two routines that allow you to derive
such expressions: Deunitize and ImpliedUnits.  Deunitize will deunitize to
one of the standard systems: SI, MKS, CGS. ImpliedUnits allows you to use
any consistent units as implied units. For example, one length in a problem
may be conveniently expressed in Kilo Meter and another length in
Centimeter, and a calculated result might be in Meter. People do things like
that if it is convenient to the collection of the data and relates to
practical use.

There are other features such as the ability to use Decibel units or to
introduce reduced units such as geometric units in general relativity or
atomic units. There is also a very handy palette that allows you to quickly
find, paste commands, or get Help on all of the routines in ExtendUnits,
Units and PhysicalConstants. Also units for Length, Mass, Volume, Area, ,
Time and Pressure can be pasted from popup lists that are either
alphabetical or by magnitude.


David Park
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html 




From: RDog [mailto:roger.leventhal at gmail.com] 

I am a very new user so I apologize in advance if this question is too basic
for the group.

Many civil engineering equations are empirically derived and therefore the
units dont work out exactly. How does Mathematica handle units in equations
and especially in empirical equations where there may be parameters set to
weird exponetial powers. Does the program use units at all in equations or
does the user need to keep track?





  • Prev by Date: Re: Why does Manipulate leak global symbols? (Potential bug here?)
  • Next by Date: Nested factor in LinearModelFit
  • Previous by thread: Re: beginner question regarding units in equations
  • Next by thread: Re: beginner question regarding units in equations