## Conversion & Dimensional Analysis

Conversion & Dimensional Analysis Tool
This tool allows your to input an expression in one system of dimensions (often called units) and translate it into another system. For example you might wish to convert twenty thousand miles per hour to mks metric units. Write 20000 mi/hr in the expression box and set the desired units to meters, kilograms, seconds and kelvins (the defaults) respectively. Press Convert and the tool will display 8940.8 m/s. The term mi/hr could also be written as either miles/hour or mph.
Numbers

This tool supports both numbers and SI (Systeme International - often called the metric system) powers of ten prefixes. A number is in a standard fixed or floating point format beginning with a optional negative sign, one or more digits, an optional fractional part (consisting of a period and one or more digits) and an optional mantissa [power of 10] (composed of the letter "e" followed by an optional sign and one or more digits). Two special numbers exist, e and pi (p). The single letter e is the base of the natural logarithms (2.71828...) and pi is the ratio of the circumference of a circle to its diameter (3.14159...).

```
Valid            Invalid    Reason
------------     ---------- ------------------------------------------
2                -.2        Digit must precede decimal point. Use -0.2.
25e-8            25 e -8    Spaces are not allowed
-2               -0         Zero cannot be negative
```

Any dimension, even a user defined dimension, may be prefixed with an SI power of ten prefix. So gigasecond, femtometer, kilocentury, and microampere are also valid. Many of the dimensions supported by this tool have abbreviations with built in SI power of ten. Thus a gigasecond is also a gs, a femtometer is a fm, but there is no built prefix for either century or ampere. Since it is a common practice to use plural forms for nouns in many expressions, you may add a plural "s" suffix to composite dimensions: So 10 gigameters is the same as 10 gigameter. Abbreviations cannot have plural endings. The built in abbreviated dimensions are all listed in the selection boxes. Answers will be displayed using these abbreviation dimensions. There should be no break between the prefix and its dimension. The SI powers of ten prefixes are:

```
Fractional Powers    Integral Powers
- deci    10-1        - deka    101
- centi   10-2        - hecto   102

m milli   10-3        k kilo    103
u micro   10-6        M mega    106
n nano    10-9        g giga    109

p pico    10-12       t tera    1012
f femto   10-15       P peta    1015
- atto    10-18       - exa     1018

- zepto   10-21       - zetta   1021
- yocto   10-24       - yotto   1024
```

The abbreviations m, M, p and P are case sensitive for the first letter of the abbreviation. Mg is a metric ton, a megagram, while mg is a milligram. The second letter of the abbreviation is case insensitive. The symbol � cannot be readily entered at the keyboard. The look alike letter "u" is substituted. Except for the specific combinations Pm:pm, Ps:ps, Pg:pg; Mm:mm; Ms:ms; Mg;mg; C:c; e, and pi any other alphabetic prefix, unit name or abbreviation is case insensitive. "C" is the abbreviation for Celsius and "c" is the abbreviation for the speed of light.

Physical Units

Physicists use just seven types of (dimensions) in combination with each other to describe everything. Four of the types of dimensions are instantly familiar to everyone. They are length, time, mass, and temperature. The first of the less familiar types of dimensions, electrical current describes the instantaneous flow of electrons in a circuit. Chemists use the concept of molarity to describe a certain number of molecules of a substance. The final type of unit luminous intensity measures the apparent brightness of an object. Each of these dimensions can be measured using various scales. Lengths, as an example, may be measured in meters, feet, miles, light-years or a host of other scales. This tool recognizes many scales for lengths, masses, times and temperatures. You will need to set the selection boxes to the desired dimensions on output. Two combinations are very commonly used in science - the so called MKS [also MKSA] and CGS [also CGSA] systems. The tool is set to MKSA if meters, kilograms, second and Kelvins are selected. MKS is the most popular system used by science. CGS was originally the standard, but its values are generally too small for ease of use. CGS is set when the selection boxes are set to centimeters, grams, seconds and Kelvins. The so called English system (really an American holdover) occurs whenever the lengths are dimensions like (inches, feet, yards or miles) and the masses are (grains, ounces, pounds and tons).

The three less familiar kinds of dimensions are supported with a single dimension in each case. Current is expressed in amperes (abbreviated as amp). Molarity is expressed in moles (mol). Luminous intensity is expressed in candela (cd). Since each of these kinds of dimensions has only a single choice, no selection box is provided for them.

Composite Units

The seven types of dimensions would be of little use except that they may be combined almost endlessly forming more complex concepts. Lengths expand to become areas and area expand to become volumes. Combining lengths with time yield velocities and accelerations. For these reason, this tool supports dimensions which are expressions composed of composites of other dimensions. I have supplied a sizable list of composite dimensions. Composites will be converted to abbreviations or expressions composed of abbreviations. Conversions to other systems of dimensions will occur and the results will be show as abbreviations. No attempt will be made to reform composite name in the answers. The current list of composites are:

 Name Equivalent expression Purpose abampere 10∙amp Electrical current abcoulomb 10∙coulomb Charge acre 160∙rod2 Area ampere amp Electrical current amps amp Electrical current amu 1.660540210×10-24 g Mass of atomic unit angstrom an Length atm 1.013246∙bar Pressure bar megadyne/cm2 Pressure boltz 1.38065812×10-16 erg/k Boltzmann constant btu 1054.8∙joule Energy c 299792458∙m/s Speed of light c_e 4.803206814×10-10 esu Charge (on electron) cal 4.1840∙joule Energy calorie 4.1840∙joule Energy candela cd Luminous intensity cc cm3 Volume celsius c Temperature centuries Cy Time century Cy Time coulomb a∙s Charge cup 0.0625∙gal Volume cycle 1/s2 Frequency day dy Time deg k Temperature degree k Temperature dyne g∙cm/s2 Force e_V 1.602177250×10-12 erg Electron volt emu erg/abcoulomb Electromotive force erg dyne∙cm Energy esu abampere∙s Charge (electrostatic unit) fahrenheit f Temperature farad coulomb/volt Capacitance feet ft Length fine 7.2973530833×10-3 Fine structure constant foot ft Length fortnight 14∙dy Time furlong 220∙yd Time gal 231∙in3 Volume gallon 231∙in3 Volume gauss 1×10-4 tesla Magnetic inductance gilbert oersted∙cm Magnetomotive force gmole mol Molarity grain grn Mass gram g Mass grav 6.6725985×10-11 newton∙m2/kg2 Gravitational constant gravity grav*m*M/distance2 Force Newton's Law of Gravity h 6.626075540×10-27 erg∙s Plancks constant hectare 10000*m2 Area henry weber/amp Electrical inductance hertz 1/s Frequency horsepower 550∙ft∙lb/s Power hour hr Time hp 550∙ft∙lb/s Power inch in Length inches in Length joule newton∙m Energy kcal kilocalories Energy kelvin k Temperature lightyear ly Length liter 1000∙cm3 Volume m_e 9.109389754×10-28 g Mass of electron m_h 1.6733×10-24 g Mass of hydrogen m_n 1.674928610×10-24 g Mass of neutron m_p 1.672623110×10-24 g Mass of proton maxwell gauss∙cm2 Magnetic flux meter m Length mile mi Length minute mn Time mole mol Molarity mph mi/hr Velocity n_a 6.022136736×1023 Avagadros number newton kg∙m/s2 Force oersted kiloamp/(4p∙m) Magnetic field ohm volt/amp Resistance orb_vel (grav*(m+M)*(2/R-1/A))^0.5 Velocity (orbits) ounce oz Mass parsec pc Length pascal kg/(m∙s2) Pressure pint 0.125∙gal Volume pound lb Mass psi 68.947 kilodyne/cm2 Pressure pt 0.125∙gal Volume qt 0.25∙gal Volume quart 0.25∙gal Volume rdc 7.5646×10-15 erg/(cm3∙k4) Radiation density constant rod 5.5∙yd Length ryd 2.179874113×10-11 erg Rydberg constant second s Time slug lb∙ft/s2 Force stef_boltz 5.6705119×10-5 erg/(cm2∙k4∙s) Stefan-Boltzmann constant tablespoon 0.90234375∙gal Volume teaspoon 0.30078125∙gal Volume tesla volt/(s∙m2) Magnetic inductance therm 10000 btu Energy ton 2000∙lb Mass volt joule/coulomb Electromotive force watt joule/s Power weber tesla∙m2 Magnetic flux week wk Time yard yd Length year yr Time
User Units

Any sequence of alphabetic letters which is not an SI prefix, a basic or a composite unit may be a user defined unit. They may be prefixed with the standard SI prefixes as desired. Therefore something like 20 megaFrogs/kiloPond is valid and actually result in 20000 Frogs/Pond. With user defined dimensions, you stand the risk of them becoming built-in composites. However I suspect Frogs and Ponds are immune from this possibility. User dimensions are case insensitive. The result attempts to preserve the cases as you gave them but if you use both forms (say Frogs/Pond+frogs/pond), you take potluck" with which spelling appears in the answer.

What problems do small flutes and members of University of Maryland teams share if they entered as user unit names? How many of what objects do you have when you have 3.14596 exactly? Clue: Les Coleman is an unrepentant punster. Answers available upon request.

Prompts and Temporary Composites

When a symbol is enclosed in single quotes, the user is prompted for the correct value. Certain expressions have multiple occurances of the same unit (perhaps the masses of two planets). Entering a single value would be pointless. For example Newton s Law of Gravity is written as grav*'m'*'M'/'distance'^2. You will be prompted for the two masses (m and M) and the distance. You may enter prompt in expressions you create although there is little point since you could just as easily enter the value where it occurs. In this list of composite units, prompted variables are shown in boldface for legibility.

You may create temporary composite dimensions which persist for the current invocation of this tool. If a user defined composite is given the same name as an existing composite dimension, the user defined name will be used. A temporary composite is defined by name = expression. The '=' sign indicates that this input defines an expression by the given name. For example, if you wished to create a temporary composite dimension for Newton's F=ma you might choose to write it as Force = 'mass' * 'accelleration'. When you subsequently used Force in an expression you will be prompted for mass and accelleration before the computation continues.

Operators, Expressions and Implicit Multiplication

Five operators +, -, *, / and ^ are supported. Composite dimensions in science are almost exclusively formed of multiplication, divisions and exponentiation by integers. Addition, subtraction and exponentiation with exponents other than integers are included none the less. As is commonly accept, exponentiation occurs before multiplication and division, which in turn occur before addition or subtraction. Thus 1+3*4^2 is 49 (1+3*(4^2)) rather than 256 which would be the result taking the operators as they appear. To change the order of evaluation, you may group the results in parenthesis. The expression ((1+3)*4)^2 or 256 shows the operations evaluated left to right in spite of normal precedence rules.

Common practice in the sciences allows the multiplication operator to be assumed in most expressions. This is called implicit multiplication. An expression such as X Y is equivalent to X*Y where X and Y are units of any type. A space is required between units; XY would be yet another unit, not the product of X and Y. When a unit is preceeded by a number, the number is normally incorporated into the unit. Spaces are not required between the number and the unit although they may occur. So 2X is equivalent to 2 X. However 2X is not equivalent to 2*X. 2X behaves as it if it were written (2*X) while 2*X behaves as if it were written 2*(X). Frequently these forms produce identical results, but an exception is exponentiation. 2X^2 is processed as if it were written (2*X)^2 yielding 4X2, where 2*X^2 is processed as if it were written 2*(X)^2 yielding 2X2.

The distinction between 2X and 2*X is crucial when X is F (Fahrenheit) or C (Celsius). Unlike all the others dimensions (units) two of the scale (Celsius and Fahrenheit) are displaced from absolute zero by 273.15 and 459.67 degrees respectively. This means that 10*C (ten times a Celsius degree) is not the same thing as 10C, the point on the Celsius scale ten degrees above the point marked 0 (but which in reality is 283.15 degrees above absolute zero). Sound confusing? Well it is, which is why the Kelvin scale is used in ALL scientific work. Zero on the Kelvin scale is indeed absolute zero. We would thing it odd if 4 pounds of flour really meant 463.67 pounds of flour, but we blithly ignore this oddity with temperatures - at least until we try to convert them.

Tips

There are a number of tricks that allow you to use the tool more procuctively. Suppose for example you would like to know how many calories of heat are produced when a ounce of matter is converted to energy by nuclear reactions. An expression like oz*c^2 will tell you how much energy is produced but it will leave the answer as 2.547954e15kg*m/s which is correct but not in the desired units. Even if you recognize kg*m/s as a joule, it still leaves you in the wrong units. If you alter oz*c^2 to become oz*c^2/calories it will answer 608.975673e12 which is the number of calories in an ounce of matter.

Sometimes you vaguely remember a formula but you aren't sure you remembered it correctly. For example "Is volts times amperes a watt?" Two easy ways to check are volts*amperes/watts and volts/amperes-watts. The answers are 1 for the ratio and 0 for the difference. Both indicate the answer to the question is yes. Both the ratio and the difference techniques can be used to determine how two units differ. For example joule/newton produces m indicating that a joule is a newton through a meter. We could also use the difference method joule-newton*meter obtaining the answer 0. The tool can even help clarify the differences between dimensions. For example, a watt is a unit of power and a joule is a unit of energy. What is the difference between power and energy when a physicist talks about them. joule/watt allows you to see that their ratio is a second. So energy is the amount of power used in a given time period.

Here are some valid expressions

```
2 GigaFurlongs/kiloFortnight
17 gigapascals/dyne
6*(2/3)+(25^0.5)
6(2/3)+(25^0.5)
15 Men on a dead man^s chest / Yo ho ho + a bottle of Rum
```

The last line is indeed valid! All of the words except "a" (i.e. an ampere) and "s" (a second) are user defined dimensions. Most of these terms are connected by implicit multiplications. The following are all invalid for the reason that follow:

```
20 Mega(furlongs/fortnight)       SI prefixes MUST precede dimensions
15 giga pascals/dyne              SI prefixes cannot be detached from their dimensions
15 Men on a dead man's chest ; Yo ho ho & a bottle of Rum.
```

The last expression contains meaningless chracters (', ;, & and a period outside a number). They are brought to the users attention but are treated as spaces. At some point in the future they may be used for enhancements.

Formal Syntactical Definition

The following is a formal specification of a valid expression. Any expression which conforms to these rules should work successfully. The intent of this specification has been described above and you don't need to understand it to use the tool. The following symbols have a meaning within the specification. If the defined object appears in the definition, the defined object may appear recursively. For example, an expression appears in its definition. A more complex expression may be built recursively from simpler expressions.

```
expression   = {operand                       }
{'('expression')'              }
{expression operator expression}
operator     = {'^' | '*' | '/' | '+' | '-'}
operand      = {number                 }
{unit                   }
{Prefix"unit            } <1>
{Number[' ']unit        }
{Number[' ']Prefix''unit}
Number       = number [' 'number...] <2>
number       = {[-]d[d...]['.'d[d...]][e[-]d[d...]] | 'e' | 'pi' }
d            = {'0' | '1' ... | '9'}
Prefix       = prefix["prefix...] <3>

prefix       = { 'deci' | 'deka' | ...  'micro' | 'mega' | ... 'yocto' | 'yotto'} <4>
unit         = {abbreviation }
{composite    }
{UserDefined  }
UserDefined  = a[a...] <5>
a            = { '_' | 'a' | ... | 'z' | 'A' | ... | 'Z'}
abbreviation = {'s' | 'm' | 'kg' ...} <6>
composite    = {'joule' | 'mph' | 'century' ...} <7>
```
• <1> Note that '' is a null string indicating prefix"unit are not blank separated.
• <2> A sequence of numbers is valid. Intended for things like '10 pi meters' or '3.2 kilogram'.
• <3> A sequence of prefixes is valid, but usually undesirable.
• <4> The list of SI Powers of Ten prefixes listed above
• <5> Any list of letters which do not conflict with prefixes, composites, abbreviations, pi or e.
• <6> The abbreviations which appear in the select lists.
• <7> The list of composite dimensions listed above. Only 'c' {speed of light} is case sensitive.

The meta syntactical notations are as follows:

```...            Sequence may be repeated. Also used informally for obvious list items.
[ ]            What appears between brackets may optionally appear.
[x|y...]       Optional term, select from x, y etc. May be stacked vertically.
{x|y...}       Required term, select from x, y etc. May be stacked vertically.
' '            What appears between quotes must appear as given
=              Left hand is defined by right hand
<#>             Supplemental explanatory note
```
This utility was authored by Les Coleman and is subject to Copyrights belonging to Les Coleman. This material may be referenced and reproduced as long as proper attribution is given as specified in Proper Usage Guidelines for Frosty Drew and Related Materials.