Make Mupad use trig identities to simplify integrations
Show older comments
Hello, here is my problem:
Integrals such as:
int(sinh(A*x)*sin(B*x),x)
or
int(sinh(A*x)*sin(B*x),x)
give very clear, easily coded solutions in MuPad. However
int(sinh(A*x)*sin(B*x)*cos(C*x),x)
generates a horrid solution involving terms such as sin(A x i), when it is clear as an integral of real functions on real variables the result should be real. (yes I have used assume(x, Type::Real)..)
By hand, there is a simple way to break down the third integral to a sum of the form of the first integral using sin(A)cos(B)=(sin(A+B)+sin(A-B))/2 i.e:
int(sinh(A*x)*(sin((B+C)*x)+sin((B-C)*x))/2,x)
but that still gives me a similarly horrible answer. In fact I have to seperate the integral entirely and by hand to
int(sinh(A*x)*sin((B+C)*x)/2,x)+int(sinh(A*x)*sin((B-C)*x)/2,x)
So my questions are:
1: Is it possible to get MuPad to do the trig conversion above automatically? I've only found functions to do the opposite so far.
2: Can integration be persuaded to keep the expanded/simplified form of these integrals so that it gives more elegant results?
Obviously the examples above are quite simple, but my problem involves many such terms in a bit of a 'worms nest', which all need expanding to fourier series coefficients, hence the form of the above equations and me wanting Mupad to save me a lot of time and possible error!
Accepted Answer
More Answers (1)
Andrei Bobrov
on 15 Apr 2011
variant
syms x A B C
int(subs(sinh(A*x)*sin(B*x)*cos(C*x),sinh(A*x),1/2*(exp(A*x)-exp(-A*x))),x)
or so
eval(['f1 = @(x,A,B,C)' vectorize(char(int(subs(sinh(A*x)*sin(B*x)*cos(C*x),sinh(A*x),1/2*(exp(A*x)-exp(-A*x))),x)))]);
>> f1(3,2,5,1)
ans =
-36.21
or so 2: idea of Walter Roberson, use Maple Toolbox for MATLAB:
Ex = int(sinh(A*x)*sin(B*x)*cos(C*x),x);
count = maple(['simplify(combine(convert(' char(Ex) ',trig),trig),size)'])
count =
2 2
1/2 (-(A + (C + B) ) (-C + B) sinh(x A) cos(x (-C + B))
2 2 2 2
+ A cosh(x A) (A + (C + B) ) sin(x (-C + B)) + (A + (-C + B) )
/
(-sinh(x A) (C + B) cos(x (C + B)) + cosh(x A) sin(x (C + B)) A)) /
/
2 2 2 2
((A + (-C + B) ) (A + (C + B) ))
1 Comment
Alexander
on 20 Apr 2011
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!