       Re: managing order of magnitude instead of numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg56685] Re: managing order of magnitude instead of numbers
• From: dh <dh at metrohm.ch>
• Date: Wed, 4 May 2005 00:32:50 -0400 (EDT)
• References: <d57gvv\$p8a\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

Hi Roberto,
you could define a new data type that encapsulates the order of
magnitude. From your example I take it, that by order of magnitude you
do not mean powers of a variable, but powers of 10.
Therefore we may define a new type called e.g. ord and inside ord we
specify the power of 10:
ord[n] where n must ne an integer.
We must now give the rules for ord, e.g.:

ord /: ord[x_Integer] + ord[y_Integer] := ord[Round[Log[10, 10^x + 10^y]]];
ord /: ord[x_Integer] - ord[y_Integer] :=
ord[Round[Log[10, Abs[10^x - 10^y]]]];
ord /: ord[x_Integer]*ord[y_Integer] := ord[x + y];
ord /: ord[x_Integer]/ord[y_Integer] := ord[x - y];

we are now ready to calculate. E.g.
a=ord;  (*this specifies an number of the order 1*)
b=ord;  (*this specifies an number of the order 10*)
and we get:

a+b  --> ord
a-b  --> ord
a*b  --> ord
a/b  --> ord[-1]

Sincerely, Daniel

foice wrote:
> i need to make calculation without specifing the exact values of my
> parameters, i want only to specify their order of magnitude.
> obviously i need only order of magnitudes as result.
>
> now the problem is that
>
> O(1) - O(1) = O(1)
>
> while
>
> 1-1 = 0
>
> so it's clear i cannot use numbers to make this "order of magintude
> calculation"
>
> at the present stage i let mathematica do the calculation in a fully
> simbolic way and then, by hand calculation, i get my result by
> susbstitution of the order of magnitudes in place of the symobls used.
>
> making a very simple example:
>
> i ask to mathematica to do
>
> a - b
>
> and then i substitute
>
> a=O(1)
>
> b=O(0.002)
>
> and calculate
>
> a - b = O(1)
>
> in this way i'm  making operation between magnitues not values, but i
> have to do it on my own, while doing calculation with mathematica will
> be much better.
>
> is there any way to make calculation betwwen order of magnitues
> instead of between numbers?
>
> thanks.
> roberto.
>

• Prev by Date: Re: Re: books on writing packages
• Next by Date: Re: Problems with eps format
• Previous by thread: Re: managing order of magnitude instead of numbers
• Next by thread: Re: managing order of magnitude instead of numbers