Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

RE: Units

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23802] RE: [mg23718] Units
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 10 Jun 2000 03:00:01 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


> -----Original Message-----
> From: Enrique Cao [mailto:cao at mundo-r.com]
To: mathgroup at smc.vnet.net
>
> Hi:
>
> I need help in order  to solve this problem.
>
> I have the vector aceleration {3 t Meter/Second^2,t^2 Meter/Second^2}.
> This is a vector dependent of time (t).
>
> I want to get the  position vector with initial conditions {x[0]==2
> Meter,y[0]==5 Meter,x'[1]==2 Meter/Second,y'[1]==3
> Meter/Second}.
>
> I do this with the follow  expression:
>
> << Miscellaneous`Units`
>
> << Miscellaneous`SIUnits`
>
> DSolve[{x''[t]==3 t Meter/Second^2,y''[t]==t^2 Meter/Second^2,
> x[0]==2 Meter,y[0]==5 Meter,x'[1]==2 =
> Meter/Second,y'[1]==3 Meter/Second },{x[t],y[t]},t]
>
> The solution is
>
> {x[t]->(Meter(4 Second^2+ 8 Second t +t^3 ))/(2 Second^2),
>
> y[t]->Mter(3+(6 t)/Second+t^4/(12 Second^2))}
>
> The unit of position is Meter but the  solution is not correct.
>
> How can I get the correct solution ??
>
> Thank you very much
>
>     Henrique
>
> cao at mundo-r.com
>

Enrique,

The two differential equations are independent, so to keep things shorter
let's just deal with the first equation. You take t to be unitless, but you
want x to have units. Working backwards let's see what happens with that
kind of construction.

x[t_] := t^2*Meter

{x'[t], x''[t]}
{2 Meter t, 2 Meter}

The units are not correct because we have thrown away the units of t. We
really want something like x[t Second], so lets put s == t Second and, of
course, t == s/Second. Then...

x[s_] := (s/Second)^2*Meter

{x'[t Second], x''[t Second]}
{(2*Meter*t)/Second, (2*Meter)/Second^2}

The units are now correct, so let's do the differential equation the same
way, in terms of s instead of t.

Clear[x];
dsol = DSolve[{x''[s] == 3*s/Second*Meter/Second^2,
     x'[0] == Meter/Second, x[0] == 2*Meter}, x[s], s][[1,1]]

x[s] -> 2*Meter + (Meter*s^3)/(2*Second^3) + (Meter*s)/Second

We can now define x[s] by:

x[s_] = x[s] /. dsol
2*Meter + (Meter*s^3)/(2*Second^3) + (Meter*s)/Second

Then...

{x[t Second], x'[t Second], x''[t Second]}
% /. t -> 3

{2*Meter + Meter*t + (Meter*t^3)/2, Meter/Second + (3*Meter*t^2)/(2*Second),
  (3*Meter*t)/Second^2}

{(37*Meter)/2, (29*Meter)/(2*Second), (9*Meter)/Second^2}

and everything has the correct units.

However, I believe that a far better and more easily understood approach for
unit problems is to put all the units in the data, and not put any explicit
units in the equations. So, doing the same problem by this method, I would
define the data as:

data = {k -> 3*Meter/Second^3, v0 -> Meter/Second, x0 -> 2*Meter};

Clear[x];
dsol = DSolve[{x''[t] == k*t, x'[0] == v0,
     x[0] == x0}, x[t], t][[1,1]]

x[t] -> (k*t^3)/6 + t*v0 + x0

Define the function.

x[t_] = x[t] /. dsol
(k*t^3)/6 + t*v0 + x0

Then, just substitute the data into any expression that you want.

{x[3 Second], x'[3 Second], x''[3 Second]} /. data
{(37*Meter)/2, (29*Meter)/(2*Second), (9*Meter)/Second^2}

There is an ExtendUnits package at my web site below, which contains many
routines which facilitate the use of units.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: Finding Front-End Options
  • Next by Date: Re: Plot List 3D
  • Previous by thread: Re: Units
  • Next by thread: Round off or up