Working with units

The AutomaticUnits package provides capabilities for working with phyisical quantities associated with various units.

Its aim is to automate both the conversions between different unit values and also to ensure dimensional compatibilitity.

Over 1000 different units are supported.

Load the units package first.

<<AutomaticUnits`

Calculations involving units will automatically convert arguments into a suitable common default unit. In most cases the default is SI units.

10.5Meter+14 Inch

No conversion will be performed if quantities are already in a common unit system

37 Yard+12 Yard

Where input units are not dimensionally compatible, no computation will be performed.

Day + Inch

Composite units can be used by multiplying powers of units, and will also be handled automatically.

2.5 Atmosphere Acre+4*(10^7) KilogramMeter(Second^(-2))

SimplifyUnits will try to find simpler equivelents to composite units.

SimplifyUnits[0.1 Atmosphere Acre]

Most operators, for which unit based quanties make sense, will automatically handle units.

2000 Meter>1.2 Mile

Sort[{Foot, Inch, Mile, 200 Yard}]

Max[{Foot, Inch, Mile, 200 Yard}]

Solve[30 x+200 Meter==100.Foot,x]

Reduce[30 x+200 Meter==100.Foot,x]

Some data constructors can support ranges or intervals using unit based quanties. For example, here we generate 10 random quantities between 1 Yard and 1 Meter...

RandomReal[{Yard,Meter},{10}]

Range[10 Meter]

Or generate values beween 10 Meters and 13 Yards in 1 Foot steps.

Range[10. Meter, 13 Yard, Foot]

Many plotting routines will handle units, and will usually display the resulting units as AxesLabels.

ListLinePlot[{300 Inch,10 Meter,10 Yard}]

Plot[x^2,{x,3 Foot, 3 Meter}]

data=Transpose[{
RandomReal[{3. Foot,500 Yard},{40}],
RandomReal[3 Week,{40}],
RandomReal[3 Farad,{40}]}];
ListContourPlot[data]

Angles are considered to have an angle dimension and so, for example Steredian is not dimensionally equivelent to Radian. Angle units are handled automatically by trigonometric functions

Sin[RightAngle/3.]

Cos[Sqrt[2. Steradian]]

Unit based quantities have a head Unit which is not shown in StandardForm.

FullForm[10 Meter]

In TraditionalForm, traditional short labels, with tooltips, are used for the units.

TraditionalForm[10 Meter]

You can convert quantities to specific units

Convert[Meter,Furlong]

Or to appropriate the most appropriate unit from a list

Convert[1.Meter,{Yard,Mile,Day}]

Convert[2000.Meter,{Yard,Mile,Day}]

A large collection of predefined sets of units is available

Convert[100.Kilogram,"Imperial"]

Convert[100.Kilogram,"Atomic"]

The available named unit sets is given by...

UnitSet[]

You can see or change the members of a particular set or create new sets.

UnitSet["Troy"]

Convert[0.1 Gram,"Troy"]

UnitSet["HeavyTroy"] = {Unit[1, "TroyOunce"], Unit[1, "TroyPound"], Unit[1, "Pennyweight"]};
Convert[0.1 Gram, "HeavyTroy"]

You can declare new units

DeclareUnit["word"];
DeclareUnit["page",2000 word];
DeclareUnit["book",200 page];
book +200 word

Convert[book +2000 word, page]

Temperatures are assumed to represent temperature differences for standard unit conversion

Celsius/Meter+Fahrenheit/Meter

But their different origins are respected using ConvertTemperature

ConvertTemperature[122.01 Celsius,Fahrenheit]