Next: Question 10: I Up: Some Maple Questions and Previous: Question 8: How

Question 9: How can I make Maple pull constants outside the integration?

Answer: Currently there is no predefined function that will do this but it can be easily accomplished given Maple's design. Greg Fee of the Maple Symbolic Computation Lab suggests you define a function `expand/Int` as follows:


> `expand/Int` := proc(a,r)
>  local x,f,y,c;
>      if type(r,name) then x := r
>      elif type(r,`=`) then x := op(1,r)
>      else ERROR(`bad 2nd arg`)
>      fi;
>      if type(a,`*`) then
>          c := 1;
>          y := 1;
>          for f in a do  if has(f,x) then y := y*f else c := c*f fi od;
>          c*Int(y,r)
>      elif type(a,`+`) then map(procname,a,r)
>      else Int(a,r)
>      fi
>  end;
Maple is designed so that users may add their own special routines for dealing with special functions. Functions such as expand, simplify, combine, int and others have a specially designed interface to make this easy. For example, when expand is passed an argument such as Int(something), Maple will invoke the routine `expand/Int`, if it exists, on something.
Here's an example of how the above `expand/Int` works:

> Int(a*x^n+a*f(x)*sin(1)*Pi,x);
                           /
                          |     n
                          |  a x  + a f(x) sin(1) Pi dx
                          |
                         /

> expand(");
                         /                       /
                        |   n                   |
                     a  |  x  dx + a sin(1) Pi  |  f(x) dx
                        |                       |
                       /                       /

Related help files include: expand, combine, Int, simplify


gagin@thsun1.jinr.ru