Simplifying with units

UnitSimplify is intended to simplify expressions of the sort encountered in a physics class where units are included.

UnitSimplify[expression_, units_List] := 
      Simplify[expression, # > 0 & /@ units] /. 
        Abs[aa_] ->  aa

An example

The units

To make things simpler we define our units.

M  =  "meter";
Kg  =  "kilogram";
S  =  "second";

Some expressions

Here are some expressions of the sort found in physics.

area  =   .000478 M^2

     Δp  =  20000.  Kg/(M S^2) 

    ρ  =  1.44 Kg/M^3

    mdot  =   .069 Kg/S

Putting them in a formula

We can apply a formula to our expressions.

ourexpression  =   mdot/(area (Sqrt[ 2 Δp ρ]))

And now we simplify. Note the second argument of UnitSimplify is a list of the units to be considered in simplifying.

UnitSimplify[ 
      mdot/(area (Sqrt[ 2 Δp ρ])), {M, Kg, 
        S}]