Re: Treating units as positive constants?

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Re: Treating units as positive constants?*From*: mek at guinan.psu.edu (Mark E. Kotanchek)*Date*: Mon, 2 Nov 92 09:13:51 EST

For this particular problem, I am doing some example calculations involving kinetic molecular theory for a freshman class. I want to carry units throughout, but I am stumped on how to have Mathematica simplify Sqrt[meter^2] to meter, etc. Is there a way to do this without appearing overly complicated to the students (for example without having to introduce FullForm, Power, /., and such like)? probably the approach you want is to redefine some Mma functions before you get into the problem, i.e., Unprotect[Sqrt]; Sqrt[x_^y_] := x^(y/2)/;EvenQ[y]; Protect[Sqrt]; Unprotect[Power]; Power[x_^y_,z_] := x^(y/2) /; EvenQ[y] && z==1/2; Protect[Power]; I just include these re-definitions (which are a composite of previous discussions in the mmaGroup) at the start of every file in an initialization cell. If I really knew what I was doing, I suppose I could put them in a package and call them via something like, Needs["myUtilities`mmaIsStupidFix`"]; but I haven't gotten around to that yet. ;) For what it's worth, Mark. --- Mark Kotanchek Guidance & Control Dept - 363 ASB Applied Research Lab/Penn State P.O. Box 30 State College, PA 16804 e-mail: mek at guinan.psu.edu (NeXTmail) TEL: (814)863-0682 FAX: (814)863-7843