how to use units along function parameter values in Mathematica

Posted by niko on Stack Overflow See other posts from Stack Overflow or by niko
Published on 2009-09-13T19:49:37Z Indexed on 2010/03/28 22:13 UTC
Read the original article Hit count: 544

I would like to pass the parameter values in meters or kilometers (both possible) and get the result in meters/second.

I've tried to do this in the following example:

u = 3.986*10^14 Meter^3/Second^2;
v[r_, a_] := Sqrt[u (2/r - 1/a)];

Convert[r, Meter];

Convert[a, Meter];

If I try to use the defined function and conversion:

a = 24503 Kilo Meter;
s = 10198.5 Meter/Second;
r = 6620 Kilo  Meter;
Solve[v[r, x] == s, x]

The function returns the following:

{x -> (3310. Kilo Meter^3)/(Meter^2 - 0.000863701 Kilo Meter^2)}

which is not the user-friendly format.

Anyway I would like to define a and r in meters or kilometers and get the result s in meters/second (Meter/Second).

I would be very thankful if anyone of you could correct the given function definition and other statements in order to get the wanted result.

© Stack Overflow or respective owner

Related posts about mathematica

Related posts about units-of-measurement