Re: Simplifying=> Sqrt[Meter^2/Second^2]
- To: mathgroup at smc.vnet.net
- Subject: [mg3005] Re: Simplifying=> Sqrt[Meter^2/Second^2]
- From: BobHanlon at aol.com
- Date: Mon, 22 Jan 1996 03:05:41 -0500
In[1]:= y = Sqrt[x^2 Meter^2/Second^2] Out[1]= 2 2 Meter x Sqrt[---------] 2 Second PowerExpand will handle this: In[2]:= y // PowerExpand Out[2]= Meter x ------- Second However, there are situations where you may not want PowerExpand to apply to other elements of the expression. Consequently, you may want to teach Mathematica how to handle the square root of the square of a positive number: In[3]:= Unprotect[Sqrt]; Sqrt/: Sqrt[x_^2 /; Positive[x] == True] := x; Sqrt/: Sqrt[z_/x_^2 /; Positive[x] == True] := Sqrt[z]/x; (* must precede next definition *) Sqrt/: Sqrt[z_ x_^2 /; Positive[x] == True] := x Sqrt[z]; Protect[Sqrt]; In[8]:= Unprotect[Second]; Meter/: Positive[Meter] = True; Second/: Positive[Second] = True; Protect[Second]; In[12]:= Sqrt[Meter^2/Second^2] Out[12]= Meter ------ Second In[13]:= Sqrt[x Meter^2/Second^2] Out[13]= Meter Sqrt[x] ------------- Second Note that the definitions are not applied retroactively: In[14]:= y Out[14]= 2 2 Meter x Sqrt[---------] 2 Second Mathematica does not try to recompute the Sqrt so it does not apply the new definitions. > From: justin at fns.net To: mathgroup at smc.vnet.net > Newsgroups: comp.soft-sys.math.mathematica > Subject: Simplifying=> Sqrt[Meter^2/Second^2] > Date: 18 Jan 1996 07:31:07 GMT > > Does anyone know if mathematica can be "taught" that an > expression of the Sqrt[Meter^2/Second^2] is equivalent to and should > be simplified to Meter/Second? > > Thanks in Advance > Justin at fns.net > UF Mechanical Engineering ==== [MESSAGE SEPARATOR] ====