Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Re: 2*m^z - m^z = ?


It is, in fact, possible to write a function "mySimplify" which avoids  
this particular problem and (I think) gives the same results as  
Simplify, although it is inevitably a lot slower. Here is the function:

SetAttributes[mySimplify, HoldAll]
mySimplify[expr_] :=
  Simplify[ReleaseHold[Simplify[Unevaluated[expr] /. x_?NumericQ :>  
Hold[x]]]]

You can check that

Table[{2*m^z - m^z, mySimplify[2*m^z - m^z]}, {m, 1, 21}]

gives correct answers. It also simplifies other expressions in the  
expected way:

mySimplify[Cos[x]^2 + Sin[x]^2]
1

I am sure mySimplify will not perform well in all sitiations but it  
maybe a useful alternative to Simplify and perhaps a sophisticated  
version of it could even be usefully implemented in Mathematica?

Andrzej Kozlowski



On 26 Apr 2008, at 16:41, Andrzej Kozlowski wrote:

>
>
>
> On 25 Apr 2008, at 18:26, Alexey Popkov wrote:
>
>> Hello,
>> What do you think about this:
>>
>> Table[
>> {2*m^z - m^z,
>>  FullSimplify[2*m^z - m^z]},
>> {m, 1, 21}] // TableForm
>>
>> The answer is very interesting (only odd numbers are treated well):
>>
>> 1					1
>> -2^z + 2^(1 + z)			2^z
>> 3^z					3^z
>> 2^(1 + 2*z) - 4^z			4^z
>> 5^z					5^z
>> 2^(1 + z)*3^z - 6^z		2^(1 + z)*3^z - 6^z
>> 7^z					7^z
>> 2^(1 + 3*z) - 8^z			8^z
>> 9^z					9^z
>> 2^(1 + z)*5^z - 10^z		2^(1 + z)*5^z - 10^z
>> 11^z					11^z
>> 2^(1 + 2*z)*3^z - 12^z		2^(1 + 2*z)*3^z - 12^z
>> 13^z					13^z
>> 2^(1 + z)*7^z - 14^z		2^(1 + z)*7^z - 14^z
>> 15^z					15^z
>> 2^(1 + 4*z) - 16^z		16^z
>> 17^z					17^z
>> 2^(1 + z)*9^z - 18^z		2^(1 + z)*9^z - 18^z
>> 19^z					19^z
>> 2^(1 + 2*z)*5^z - 20^z		2^(1 + 2*z)*5^z - 20^z
>> 21^z					21^z
>>
>> Can anyone explain the reason for this behavior?
>>
>
>
> Thera are many such pheonomna in computer algebra. This particular one
> I have already once explained on this forum, but as I can't find my
> post I will repeat it.
>
> The reason why this happens is that Mathematica (and all other
> Computer ALgebra Systems) performs certain "simplifications", or more
> precisely "reductions to canonical form" automatically, even before
> applying Simplify or FullSimplify, simply as part of the evaluation
> process. One such "simplification" that is done automatically is this:
>
> 2*6^z
> 2^(z + 1)*3^z
>
> In other words, Mathematica sees that 6 has 2 as a factor, it factors
> it out and combines all factor of 2 into a single power. This is a
> typical example of "reduction to canonical form". Such reductions make
> certian operations much simpler and faster but unfortunately this
> particular one does not fit in very well with another reduction that
> Mathematica also performs automatically:
>
>  2^z*3^z
>  6^z
>
> Such "reductions" cannot be undone by Simplify or FullSimplify because
> they are performed on evaluation, so even if Simplify "undid" one of
> them, the reduction would be immediately performed again.
> Unfortunately these two reductions  prevent Simplify and FullSimplify
> form seeing that
>
> 2^(z + 1)*3^z-6^z
>
> can be simplified to 6^z, because Simplify cannot re-write 2^(z +
> 1)*3^z as 2*6^z and it also cannot re-write 6^z as 2^z*3^z for reasons
> described above.
>
> In the example you gave the problem can be easily dealt with by
> wrapping Evaluate round the first argument of Table.
>
> Table[Evaluate[{2*m^z - m^z, FullSimplify[2*m^z - m^z]}], {m, 1, 21}]
>
> However the problem of simplifying
>
> p=2*6^z-6^z
>
> and similar expressions is harder to deal with. Note that Mathematica
> has no difficulty verifying that
>
> p == 6^z // Simplify
> True
>
> so it is only transforming p into 6^z by means of FullSimplify that is
> difficult. In fact, I don't think it can be done, without using some
> tricks. Here is one such trick. We divide p  by 3^z, then FullSimplify
> and finally again multiply by 3^z:
>
> FullSimplify[[p/3^z]*3^z
> 6^z
>
>
> Andrzej Kozlowski
>



  • Prev by Date: Re: Enable multicore calculation ?
  • Next by Date: Re: Re: Print[Plot] vs Print[text,Plot]?
  • Previous by thread: Re: 2*m^z - m^z = ?
  • Next by thread: Re: 2*m^z - m^z = ?