MathGroup Archive 1999

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

Search the Archive

Re: weird behavior of simplify

  • To: mathgroup at
  • Subject: [mg21240] Re: [mg21186] weird behavior of simplify
  • From: Andrzej Kozlowski <andrzej at>
  • Date: Mon, 20 Dec 1999 02:28:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at

I am not sure if one should call it a bug (I feel I have used this word too
often on this list anyway). As is often the case  it depends on one's
perspective. If Simplify did not give the answer you expect in any of these
cases you wouldn't probably call it a bug! In fact I was surprised to see
that Simplify works in some of them. The reason is that the mechanism of
Assumptions in Simplify is based on a very general ability to solve
algebraic equations and inequalities (Groebner basis and
CylindricalAlgebraicDecomposition)  and is then extended to other types of
functions in a rather ad hoc way (I think that is true, anyway, although I
may be oversimplifying things a bit).  As far as I know there is no more
general approach. So, however much one improves Simplify it will be probably
always possible to manufacture  examples where it will fail.
Of course, given any such example one can then modify Simplify to deal with
it, so perhaps in the future it will not be so easy to come up with one as
simple as these.

For example, to deal with the ones you give one could do something like

Simplify[b_. + a_.*E^(x_ + y_), Element[n_, Integers]] :=
    Simplify[b, Element[n, Integers]] +
      Simplify[a, Element[n, Integers]]*Simplify[E^x, Element[n, Integers]]*
        Simplify[E^y, Element[n, Integers]];

By using Simplify and ExpandAll one can than get the answer you want in all
your cases:

Simplify[ExpandAll[E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n)], Element[n , Integers]]
 (4 I Pi)/n
Simplify[ExpandAll[E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n) + x],
  Element[n , Integers]]
 (4 I Pi)/n
E           + x

    E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n) + 3/E^((4*I*(3 + n^2)*2*Pi)/n)],
  Element[n , Integers]]
 (4 I Pi)/n        3
E           + ------------
               (24 I Pi)/n

One could actually incorporate ExpandAll into Simplify for such cases. But
as I wrote above, one can always easily manufacture a somewhat different
simple example for which this won't work, e.g.

Simplify[2^(E^((24*I*Pi)/n + 8*I*n*Pi)),Element[n,Integers]]
  (8 I (3 + n ) Pi)/n

This is a limitation of trying to extend Simplify by using pattern matching
rather than general mathematical algorithms; there will always be fairly
simple patterns that do not match any rules.

Having said all this, I still would like to to know why exactly the example
below which has x as a summand works but one without it does not. It looks
to me that some pattern is not being matched. Perhaps Adam Strzebonski will
enlighten us?

> From: b320 <b320 at>
To: mathgroup at
> Organization: FYMA
> Date: Fri, 17 Dec 1999 01:23:44 -0500 (EST)
> To: mathgroup at
> Subject: [mg21240] [mg21186] weird behavior of simplify
> I tried the following simplification:
> Simplify[E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n), {n OE Integers}]
> and nothing happened
> E^(-((4*I*(-1 - 4*n + n^2)*Pi)/n))
> But this time it worked out the way it should
> Simplify[E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n) + x, {n OE Integers}]
> E^((4*I*Pi)/n) + x
> But again
> Simplify[E^((2*I*(1 - n^2 + 4*n)*2*Pi)/n) + 3/E^((4*I*(3 +
> n^2)*2*Pi)/n), {n OE Integers}]
> Does not simplify the way I would expect:
> E^((4*I*Pi)/n) + 3/E^((8*I*(3 + n^2)*Pi)/n)
> So is this a bug or is there a more subtel explanation ?
> Thank you for comments

  • Prev by Date: Re: newtons method, notation
  • Next by Date: Re: Help tracking down a Bug
  • Previous by thread: weird behavior of simplify
  • Next by thread: serie of random number