Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Simplify 0/0 to 1?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77511] Re: Simplify 0/0 to 1?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 11 Jun 2007 04:23:20 -0400 (EDT)
  • References: <934147.40360.qm@web43135.mail.sp1.yahoo.com>

I would not call this bad performance. In fact this is inevitable,  
not only in Mathematica but in every CAS that exists today (although  
not necssarily in the same example). All you need to do is to choose  
numerator and denominator  equal to zero but sufficiently complicated  
and such that the CAS will see that they are equal before it can  
check that they are both 0. I believe (though obviously I have not  
checked this) that every CAS will then simplify the expression to 1,  
because for reason of performance it will cancel common factors as  
soon as it can see them. It might perhaps perform a check on them  
first to see if they are zero (so this would prevent this sort of  
situation happening) but doing such tests every time cancellations  
are performed could produce a huge performance hit, and anyway may  
not be successful.

  Here is a very trivial example:

  (1 - Cos[Pi/23]^2 - Sin[Pi/23]^2)/(1 - Cos[Pi/23]^2 - Sin[Pi/23]^2)
  1

This was turned into 1 by the evaluator withot any Simplify even  
though both, the numerator and the denominator are clearly zero. You  
can avoid this by mapping Sinmplify on the numerator and the  
denominator but you have to use Unevaluated first:

Simplify /@
  Unevaluated[(1 - Cos[Pi/23]^2 - Sin[Pi/23]^2)/(1 - Cos[Pi/23]^2 -
      Sin[Pi/23]^2)]
The same approach will work in your example:

Simplify/@o

Here is essentially the same example (which is   based on the Sin^2[a] 
+Cos^2[a]==1 identity) but just made a bit more complicated, so that  
this time, like in your original example, the evaluator does not  
reduce the expression to 1 immediately, but only after Simplify is  
applied.


Simplify[(1 - Cos[Pi/23]^2 - Sin[Pi/23]^2)^2/(1 - 2*Cos[Pi/23]^2 + Cos 
[Pi/23]^4 -
     2*Sin[Pi/23]^2 + 2*Cos[Pi/23]^2*Sin[Pi/23]^2 + Sin[Pi/23]^4)]

1

As you can see again, the numerator and the denominator are both zero  
but Simplify sees that they are equal before it can see that they are  
both zero and at that point the Evaluator performs the cancelation.

Andrzej Kozlowski





On 10 Jun 2007, at 20:57, dimitris anagnostou wrote:

>
> Hi.
> This appeared in another forum as part of a question
> what another CAS does.
> Just of curiosity I check Mathematica's performance (5.2).
> The result was poor!
>
> Here is the expression
>
>
> In[16]:=
> o = (Log[2]*Cos[Pi/12] - Log[2]*Sin[Pi/12] - 2*Cos[Pi/12] + 2*Sin[Pi/
> 12] + Sqrt[2] +
>     2*Log[Cos[Pi/12] - Sin[Pi/12]]*Cos[Pi/12] - 2*Log[Cos[Pi/12] -
> Sin[Pi/12]]*Sin[Pi/12])/
>    (Log[2]*Cos[Pi/12] - Log[2]*Sin[Pi/12] + 2*Log[Cos[Pi/12] -
> Sin[Pi/
> 12]]*Cos[Pi/12] -
>     2*Log[Cos[Pi/12] - Sin[Pi/12]]*Sin[Pi/12])
>
>
> Out[16]=
> (Sqrt[2] + (-1 + Sqrt[3])/Sqrt[2] - (1 + Sqrt[3])/Sqrt[2] - ((-1 +
> Sqrt[3])*Log[2])/(2*Sqrt[2]) +
>    ((1 + Sqrt[3])*Log[2])/(2*Sqrt[2]) - ((-1 + Sqrt[3])*Log[-((-1 +
> Sqrt[3])/(2*Sqrt[2])) + (1 + Sqrt[3])/(2*Sqrt[2])])/
>     Sqrt[2] + ((1 + Sqrt[3])*Log[-((-1 + Sqrt[3])/(2*Sqrt[2])) + (1 +
> Sqrt[3])/(2*Sqrt[2])])/Sqrt[2])/
>   (-(((-1 + Sqrt[3])*Log[2])/(2*Sqrt[2])) + ((1 + Sqrt[3])*Log[2])/
> (2*Sqrt[2]) -
>    ((-1 + Sqrt[3])*Log[-((-1 + Sqrt[3])/(2*Sqrt[2])) + (1 + Sqrt[3])/
> (2*Sqrt[2])])/Sqrt[2] +
>    ((1 + Sqrt[3])*Log[-((-1 + Sqrt[3])/(2*Sqrt[2])) + (1 + Sqrt[3])/
> (2*Sqrt[2])])/Sqrt[2])
>
> Watch now a really bad performance!
>
> In[17]:=
> (Simplify[#1[o]] & ) /@ {Numerator, Denominator}
>
> Out[17]=
> {0, 0}
>
> That is Mathematica simplifies succesfully both the numerator
> and denominator to zero. So, you wonder what goes wrong?
>
> Try now to simplify the whole expression!
>
> In[19]:=
> Simplify[o]
>
> Out[19]=
> 1
>
> A very weird result to my opinion!
> Simplification of 0/0 to 1?
> I think no simplification or some
> warning messages would be much better
> than 1!
>
> Note also that
>
> In[20]:=
> RootReduce[o]
>
> Out[20]=
> 1
>
> Dimitris
>
> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket:  
> mail, news, photos & more.



  • Prev by Date: Re: Trouble with a system of equations
  • Next by Date: Re: Fast interactive graphics
  • Previous by thread: Re: simplification of 0/0 to 1?
  • Next by thread: Re: Simplify 0/0 to 1?