MathGroup Archive 2005

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

Search the Archive

Re: Units, simplification

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59575] Re: Units, simplification
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 12 Aug 2005 00:09:56 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/11/05 at 4:54 AM, not_valid at w.pl (KaeL) wrote:

>I admit I am not too experienced mit M. (v. 5.1). My problems
>regards simplification of unit equations. Consider such a simple
>entry:

>Simplify[Ampere Meter Meter/Joule Tesla]

>Explanation for non-physicist: this is equal to 1 Usage of
>"<<Miscellaneous`Units`" does not help here, as this package is
>rather _conversion_ (SI into cgs, .i.e Tesla into Gauss) oriented.
>Running "<<Miscellaneous`PhysicalConstants`" does not help either,
>as this package rather _introduces/defines_ the units. And you
>would need here sort of relation between units-am I right?

>Any idea how to solve my problem?

Yes. The way I have solved this issue for myself is to edit the Units.m package by adding the following two lines:

FundamentalSI::usage = "FundamentalSI[expr] converts expr to fundamental SI units (International System)."

and

FundamentalSI[expr_]:=SI[expr]//.$ToFundamental

These two lines define a new function that does what you want. The first line should be added to the section of the file that defines usage messages. I've put it just ahead of the usage message for SI.

The second line defines the function and needs to go somewhere in the Private context. Like the other line, I added it just ahead of the definintion for SI[expr_]

Once these two lines are added the following works

In[1]:=
<< "Miscellaneous`Units`"; 
FundamentalSI[Ampere Meter Meter/Joule Tesla]

Out[2]=
1

Note if you always want these set of fundamental units simply adding //.$Fundamental on the end of the definition for SI[expr_] will make SI behave in this manner.

There are a couple of consequences of solving the issue in this manner.

I have modified one of the standard distribution packages. So, every upgrade to Mathematica will overwrite these changes and you will lose this behaviour until you edit the new Units.m file.

Since I have not modified the stub that gets called when doing <<Miscellaneous` this new function will not be loaded. That is, to get this new functionality as I have modified things you must explictly load the Miscellaneous`Units` package using Needs, Get or <<.

Of course this last issue would disapper if you also edit the stub or modify the definition for SI[expr_]

There is undoubtedly a way to do this without modifying the Units.m package. But since this functionality already exists in the package this seemed the most elegant solution to me.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Re: Re: Mathematica 5.2 and mathssh
  • Next by Date: Re: Options in my own packages?
  • Previous by thread: Re: Units, simplification
  • Next by thread: Re: Units, simplification