Search code examples
maple

Maple incorrect calculation with ShowSolution function


Maple solves the following problem incorrectly when using ShowSolution function which is in student.calculus1 package. It's works fine when the power of x variable is odd or when I write sin(n*x) but when I wrote x^(even number)cos(nx) it's calculated incorrectly. Or when I put a number instead of n it's calculated correctly. Do I miss something? :| Here is a screenshot:

When assume(n::integer). Maple says the answer is 0 which is also incorrect


Solution

  • It looks like a bug (and I have submitted a bug report), going wrong at the first step.

    As workaround, you could do this as a first step,

    restart;
    with(Student:-Calculus1):
    
    ee := Int( x^2*cos(n*x), x=-Pi..Pi ):
    
    new := rhs( Rule[parts, x^2, sin(n*x)/n]( ee ) ) assuming n::integer;
    
                 -(Int(2*sin(n*x)*x/n, x = -Pi .. Pi))
    
    ShowSolution( new ) assuming n::integer; 
    

    which produces 4*(-1)^n*Pi/n^2 at the final step.

    Or do those steps without the assumptions on n, and then simplify the final result under assuming n::integer.