Re: managing order of magnitude instead of numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg56692] Re: managing order of magnitude instead of numbers
- From: pavlyk at gmail.com
- Date: Wed, 4 May 2005 00:32:58 -0400 (EDT)
- References: <d57gvv$p8a$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Format[OrdMagn[n_?NumberQ]]:=o[n] OrdMagn /: HoldPattern[Times[a___,c_OrdMagn,b___]]:= Module[{al}, al=DeleteCases[{a,c,b},x_/;FreeQ[x,OrdMagn]]; OrdMagn[Total[al/.{OrdMagn[n_] :> n}]] ] OrdMagn /: HoldPattern[Plus[a___,c_OrdMagn, b___]]:=Module[{al}, al=DeleteCases[{a,c,b},x_/;FreeQ[x,OrdMagn]]; OrdMagn[Max[al/.{OrdMagn[n_] :> n}]] ] OrdMagn /: HoldPattern[Power[OrdMagn[n_], p_?NumberQ]] := OrdMagn[p*n] Then, In[6]:= OrdMagn[1]-OrdMagn[1] Out[6]= o[1] Play around with it and modify accorng to your needs. Sasha