Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

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


  • Prev by Date: Re: GUIkit problem
  • Next by Date: Re: Creating forms for user input in Mathematica
  • Previous by thread: Re: managing order of magnitude instead of numbers
  • Next by thread: Re: managing order of magnitude instead of numbers