MathGroup Archive 2002

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

Search the Archive

Re: Mathematica have an 'Assume' type syntax/command?

  • To: mathgroup at
  • Subject: [mg33082] Re: Mathematica have an 'Assume' type syntax/command?
  • From: adam.smith at (Adam Smith)
  • Date: Fri, 1 Mar 2002 06:51:43 -0500 (EST)
  • References: <a5htib$hsu$>
  • Sender: owner-wri-mathgroup at

Mathematica has the capability of adding assumptions to the integral
via Assumptions->{}.  However, it is not perfect as shown below in the
Mathematica equivalent of what you did in Maple:

Integrate[x^2*Sin[n*Pi*(x/a)]^2, {x, 0, a}, 
Assumptions -> {Element[n,Integers], n > 0,a>0}]

If[Im[n/a] == 0, (a^3*(4*n^3*Pi^3 - 6*n*Pi*Cos[2*n*Pi] + 
     (3 - 6*n^2*Pi^2)*Sin[2*n*Pi]))/(24*n^3*Pi^3), 
Integrate[x^2*Sin[(n*Pi*x)/a]^2,{x, 0, a}]]

The output is if the condition Im[n/a]==0 is true, then whatever
appears in the 2nd position.  If false, the answer is the third

I say it the use of assumptions in not perfect, because doing the
integral without assumptions gives

Integrate[x^2*Sin[n*Pi*(x/a)]^2, {x, 0, a}]

a^3/6 - (a^3*Cos[2*n*Pi])/(4*n^2*Pi^2) - (a*(-a^2 +

Which then simplifies using the Simplify[] with conditions

Simplify[Integrate[x^2*Sin[n*Pi*(x/a)]^2, {x, 0, a}],

(1/12)*a^3*(2 - 3/(n^2*Pi^2))

The final form is fine as long as n is not zero.  It would imply that
as n=0 the thing "blows up".  However, the Simplify fails for the case
of n=0 as can be seen by looking at the limit of the integral as n
approaches zero.

Limit[a^3/6 - (a^3*Cos[2*n*Pi])/(4*n^2*Pi^2) - (a*(-a^2 +


This can be traced to the similar problem in Simplify for Sin[n Pi]/n

Simplify[Sin[n Pi]/n,Element[n,Integers]]


This is true except for n=0, in which case the answer = Pi. 
Obviously, somewhere in the Simplify code Mathematica recognizes that
Sin[n Pi] = 0 for integers, but it does not check that the denominator
is not 0.  I wrote to Mathematica about this and got back a long
answer saying it was not a bug but a limitation having to do with
"problems with generalicity" (my paraphrase from memory).  My
interpretation of "generalicity" was that it would be impossible to
anticipate all the various limiting conditions that could come up for
Simplify to handle and that trying to build a huge number of special
cases would make the Simplify with conditions routine much too slow.

Having said that, I still think that this is a deficiency in Simplify.
 Maybe others feel the same way, let Mathematica know about it.  Until
it changes, I strongly recommend that people check any special cases
with the Limit[] method.

Adam Smith

This is fine in your case since 
"Flip Flippy" <flip at> wrote in message news:<a5htib$hsu$1 at>...
> Hi All,
> I saw this on sci.math and was wondering how an 'assume' type function
> can be done in Mathematica.
> Does one exist, or is there a way to emulate one?
> Here was the problem.
> After running the following code in maple:
> assume(n>0,n,integer);
> int(x^2*(sin(n*Pi*x/a))^2,x=0..a);
> Any thoughts?  Thank you, Flip

  • Prev by Date: Re: Solve (on Mathematica 4.1 Windows XP)?
  • Next by Date: perhaps? RE: Finding pattern Matched series
  • Previous by thread: Re: Mathematica have an 'Assume' type syntax/command?
  • Next by thread: request help