From: colin@tri.org.au (Colin Rose) Subject: Re: conditions in integration results, Mathematica, Macsyma Date: Sun, 20 Jun 1999 02:58:17 +1000 Newsgroups: sci.math.symbolic Richard J. Fateman wrote: If [ Im[a]==0 && Im[2a-2b]==0 && Im[b]==0 && Im[2a+2b]==0 ... > Have others found the conditionalized results of the > Mathematica integration program useful in further computation?? No. I personally find it incredibly irritating. Five issues come to mind: 1. Superfluous: The conditional statements are often superfluous, and sometimes wrong. Under v3, for instance, integrating a Normal(mu, sigma^2) distribution yields the conditional: Re[Mu/Sigma^2 > 0 && Re[Sigma^2] > 0 && X <= 0 which is clearly nonsense. Fortunately, this example has been fixed in the new v4 release. 2. Syntax: Under the new v4, the Assumption syntax used by Integrate is different to the excellent NEW Assumptions technology used by Simplify, FullSimplify and Expand. This means that one has to work with two assumptions technologies that have completely different syntaxes and do not know how to talk to each other. 3. Peculiar: For example... Under v2: Integrate did NOT give conditional results. Mma knew how to integrate x^-c: In[]:= Integrate[x^(-c), {x, a, Infinity}] Out[]= a^(1-c)/(-1 + c) Under v4: With Conditions turned off, Mathematica no longer knows the answer: In[]:= Integrate[x^(-c), {x, a, Infinity}, GenerateConditions -> False] Out[]= Zilch even though it does know the answer if you allow it to present the conditions. This is very strange indeed. In other situations, supplying some of the required assumptions, but not all of them, is actually worse than providing none at all with GenerateConditions set to False. 4. Funtionally poor: Normally, If[] structures are used in situations such as: If[x < 0, x^2, x^3] Here, different things happen depending on whether x is smaller or greater than 0. By contrast, Integrate always returns answers of form: If[ cond, answer, ELSE I don't know] and NEVER EVER the more interesting case: If[ cond, answer1, answer2 ] (two different answers, depending on whether the condition is satisfied or not.) By using a conditional If[] statement to always display a single answer has no functional purpose. Worse, it has many disadvantages, including making it more difficult to see the answer, and ... 5. Post-processing results: So, Mma returns: If[ cond, ANSWER, ELSE I don't know] Richard asked whether this output is useful in further computation ... now suppose you find that the conditions specified are suitable, and you now want to do further work with ANSWER, such as Simplify it or Expand it etc. To do this, you have to grab the ANSWER out of the If statement, create a new expression with it, and then Simplify it. Eg: sol = If[a, b, c]; sol[[2]] // Simplify But things get messy when the solution is say: sol = 2 If[a, b, c]; because now: sol[[2]] == If[a, b, c], NOT b. -- Under the circumstances, I find the best situation is to simply avoid conditional results altogether by setting: SetOptions[Integrate, GenerateConditions -> False] which causes the conditional statements to disappear all together. This is quite delicious. On the downside, one doesn't get to see the assumptions Mathematica is making in generating the answer, which can be useful. This information [ the condition ] could easily be displayed in the Message box, or pop up in a special info text cell or similar ... this would be an easy way to convey the necessary information to the user without using the irksome If approach. Cheers Colin -- Colin Rose tr(I) - Theoretical Research Institute __________________________________________ colin@tri.org.au http://www.tri.org.au/