I've had considerable difficulty in integrating products of trig functions with Maple. It usually expands the trig functions into forms that just are a mess to deal with. So, I usually handle this by splitting an expression into two parts: a constant term that doesn't depend upon the integration variable and a dependent term. In the past, I've usually done this by hand but have now created a procedure to do this automatically.
> breakApart := proc(expr,dep_var,const_name)
local dep_term, indep_term, dep_term2, indep_term2, cons_eq;
dep_term, indep_term := selectremove(depends, [op(1..nops(expr),expr)],dep_var);
dep_term2 := mul(dep_term[i],i=1..nops(dep_term));
indep_term2 := mul(indep_term[i],i=1..nops(indep_term));
cons_eq := const_name = indep_term2;
return cons_eq, const_name*dep_term2;
Below is a term to integrate, note that it is actually part of a sum with n being the index variable for the series so it can only be an integer.
> term :=-(16*y*z*(-1)^n*a^2*sin(((2*n+1)*Pi*y)/a))*sinh(((2*n+1)*Pi*z)/a)/((2*n+1)^3*Pi^3*cosh(1/2*((2*n+1)*Pi*b)/a));
Now we break it apart into a constant (with respect to y) and a new term that includes the constant in preparation for integration with respect to y.
> k1_eq, term2 := breakApart(term,y,k1(z));
Integrating with respect to y,
> inty_result := int(term2,y=-a/2..a/2) assuming n::integer;
An obvious factorization can be made so we will do that before substitution,
> inty_simplify := factor(inty_result);
Resubstituting the other terms back in,
> inty_subs := subs(k1_eq,inty_simplify);
Note that since we have -1 raised to the n squared, it will always be 1.
> inty_final := subs(((-1)^n)^2=1, inty_subs);
Now breaking it apart in preparation for integrating with respect to z,
> k2_eq, term3 := breakApart(inty_final,z,k2);
> int_z := int(term3,z=-b/2..b/2) assuming n::integer;
Since we know that we have a hyperbolic cosine in the denominator of our constant, let's split up the expression based upon cosh to simplify the remaining work,
> intz_collect := collect(int_z,cosh);
Note that we can factor the cosh term to eliminate one of the (2n+1) terms in the denominator so performing that,
> intz_factor := factor(op(1, intz_collect)) + op(2,intz_collect);
Now resubstituting the constant back in,
> intz_subs1 := subs(k2_eq, intz_factor);
Note that the second term really contains an expression for tanh. Since I haven't found a reliable way for Maple to automatically simplify this we can do it ourselves,
> intz_subs2 := algsubs(sinh(1/2*(2*n+1)*Pi*b/a)/cosh(1/2*(2*n+1)*Pi*b/a)=tanh(1/2*(2*n+1)*Pi*b/a), intz_subs1);
Re-splitting the terms,
> intz_collect := collect(intz_subs2,tanh);
and then factoring to simplify, we get the final result. While this takes many more steps and manual work than letting Maple integrate, we get nice compact results.
> int_final := op(1,intz_collect) + factor(op(2, intz_collect));
This post generated using the online HTML conversion tool
I'd appreciate any feedback on better ways to do this or automate the process further.
Download the original worksheet