Raymond Toy wrote:
> Robert Dodier wrote:
>> Gary wrote:
>>
>>> I've been trying to evaluate a symbolic double integral but am
>>> perplexed by the unevaluated tan(pi/2) expressions in the result since
>>> tan(pi/2) is undefined. What am I missing here and what do I need to
>>> do to get this to evaluate to the correct value of
>>> (4*pi - 3*sqrt(3))*a^2/6?
>>> sage input:
>>> ***************************************************************
>>> var('a r theta')
>>> assume(a > 0)
>>> integral(integral(r, r, a*csc(theta), 2*a), theta, pi/6, pi/2)
>>> ***************************************************************
>>>
>>> sage output:
>>> *********************************************************************
>>> (2*pi*tan(pi/2) + 1)*a^2/(2*tan(pi/2)) - (2*pi + 3*sqrt(3))*a^2/6
>>> *********************************************************************
>> Sage punts to Maxima to do symbolic integrals.
>> In this case, Maxima computed an antiderivative and plugged
>> in the limits of integration. You can coax Maxima into doing
>> the right thing by computing a limit:
>>
>> assume (a > 0, bb > 0, bb > %pi/6);
>> integrate (integrate (r, r, a*csc(theta), 2*a), theta, %pi/6, bb);
>> => (4*a^2*bb*tan(bb)+a^2)/(2*tan(bb))-(2*%pi+3*sqrt(3))*a^2/6
>> limit (%, bb, %pi/2, minus);
>> => (4*%pi-3*sqrt(3))*a^2/6
>>
>> I guess Maxima could apply the limit automatically -- that
>> shouldn't change the result for most integrals, but gets the
>> correct result in cases like this. Opinions from the Maxima
>> crowd are welcome.
>
>
> Maxima normally does apply limits (or something). There's something
> special about the integrand 2*a^2-a^2/2*csc(theta)^2. If you look at
> just the integrand csc(theta)^2, maxima returns something nice.
> a^2/2*csc(theta)^2 is also ok. Even 2*a^2-a^2*csc(theta)^2 is ok, but
> divide csc(theta) term by 2, and maxima is confused.
>
> Don't know why.
The issue is that maxima calls easy-subs to see if we can just
substitute the limits in. easy-subs returns T, so maxima just
substitutes the limits.
If I change easy-subs so that it returns NIL when the expression
contains tan, maxima now carefully substitutes the limits and returns
the correct answer.
However, maxima also asks questions about the sign of tan(theta) and
tan(theta+%pi/6). But these questions are also asked for the simple
integrand csc(theta)^2, so we are causing any additional issues. And
the testsuite finishes successfully.
Ray