Search code examples
maple

is it possible to add an integration rule to Maple int?


I'd like Maple to return ln(abs(x)) for int(1/x,x) instead of ln(x).

Is there a way to give a rule using a pattern, for int to use in this case as it is possible to do in Mathematica? i.e. somehow to override int result for a specific result like the above? Or may be there is some global option one can set?

Maple 2018.1


Solution

  • A procedure way:

     REALINT2 := proc (f, x) local func, a; 
     func := int(f, x); 
     a := selectfun(func, ln); 
     `assuming`([simplify(eval(func, [seq(a[k] = map(proc (x) options operator, arrow; 
     abs(x) end proc, a[k]), k = 1 .. nops(a))]))], [x in real]) end proc:
    
     REALINT2(1+1/x, x); 
     REALINT2(1/sin(x), x); 
     REALINT2(x/(x^2+1), x); 
     REALINT2(tan(x), x); 
     REALINT2((diff(f(x), x))/f(x), x); 
     REALINT2(1+1/abs(x), x); 
     `assuming`([REALINT2(1/x, x)], [x < 0])
    
     #                          x + ln(|x|)
     #                 ln(1 - cos(x)) - ln(|sin(x)|)
     #                          1   / 2    \
     #                          - ln\x  + 1/
     #                          2           
     #                         -ln(|cos(x)|)
     #                           ln(|f(x)|)
     #                     / x - ln(-x)      x < 0
     #                    |                      
     #                    <  undefined       x = 0
     #                    |                      
     #                     \ x + ln(x)       0 < x
     #                             ln(-x)