Symbolic Integration Problem Using Symbolic Math Toolbox
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear Matlab users,
I would like to get the integral of a function symbolically in MATLAB. However, MATLAB doesn't give me the integral of this function. Do you have any advice?
Thanks in advance.
MATLAB Codes to run:
clear all; clc;
syms a q mL y nL p s b yA yU mR nR r
KK5=sin(q*pi*(mR*y+nR)/a)*cos((r*pi*(mR*y+nR))/a)*cos((2*p*pi*y)/b);
K5=simplify((-1/2)*((a*r)/(q^2-r^2)*pi)*int(KK5,y,[yA yU]))
It gives me this result:
K5 =
-(a*r*pi*int(cos((pi*r*(nR + mR*y))/a)*sin((pi*q*(nR + mR*y))/a)*cos((2*pi*p*y)/b), y, yA, yU))/(2*(q^2 - r^2))
댓글 수: 2
Walter Roberson
2022년 8월 31일
Integral with respect to which variable? You did not specify a variable of integration, so int() is going to pick one.
Note: when you syms i and syms j then the i and j that result will just be normal variables, with no connection to sqrt(-1) and no connection to coordinate axes. int() will not recognize hyperbolic functions, or possibilities of rewriting in terms of exp()
채택된 답변
Torsten
2022년 8월 31일
편집: Torsten
2022년 8월 31일
syms par1 par2 par3 par4 par5
syms a q p s b mR nR r
syms y yA yU
K5 = cos(par1*y+par2)*sin(par3*y+par4)*cos(par5*y);
K55 = int(K5,y,yA,yU);
K55 = subs(K55,[par1 par2 par3 par4 par5],[q*pi*mR/a q*pi*nR/a r*pi*mR/a r*pi*nR/a 2*pi*p/b]);
K55 = (-1/2)*((a*r)/(q^2-r^2)*pi)*K55;
K55 = simplify(K55)
댓글 수: 9
Paul
2022년 8월 31일
It looks like a "divide by a" is missing in your expression for the argument of the sin(). For some reason, including that makes a big difference in the result. Still a mystery
syms a q mL y nL p s b yA yU mR nR r
% KK5=sin(q*pi*(mR*y+nR)) *cos(r*pi*(mR*y+nR)/a)*cos(2*p*pi*y/b);
KK5=sin(q*pi*(mR*y+nR)/a)*cos(r*pi*(mR*y+nR)/a)*cos(2*p*pi*y/b);
K5=(-1/2)*((a*r)/(q^2-r^2)*pi)*int(KK5,y,yA,yU);
simplify(K5)
I wonder if there are some allowable values of the parameters (r,q, etc.) that make it not possible to evaluate the integral uniquely
Torsten
2022년 8월 31일
It looks like a "divide by a" is missing in your expression for the argument of the sin().
Yes, that's why I wrote: Up to here, it works.
추가 답변 (1개)
ercan duzgun
2022년 8월 31일
편집: ercan duzgun
2022년 8월 31일
댓글 수: 2
Torsten
2022년 8월 31일
After correcting some errors in your code, I get the same result for both approaches.
format long
syms a r iv mR nR y yA yU mL nL b jv iv
KK5=sin(iv*pi*(mR*y+nR)/a)*cos(r*pi*(mR*y+nR)/a)*cos(2*jv*pi*y/b);
KKK5=int(KK5,y,yA,yU);
KKKK5=simplify(((-1/2)*((a*r)/((iv^2-r^2)*pi)))*KKK5);
num_KKK5=double(subs(KKKK5,[a r iv mR nR y yA yU mL nL b jv],[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.25 0.35 0.45 0.55]))
%method2
syms y5 p5 y55 p55 y555
Y5=sin(y5*y+p5)*cos(y55*y+p55)*cos(y555*y);
YY5=int(Y5,y,yA,yU);
YYY5=simplify(((-1/2)*((a*r)/((iv^2-r^2)*pi)))*YY5);
YYYY5=subs(YYY5,[y5 p5 y55 p55 y555],[(iv*pi*mR/a) (iv*pi*nR/a) (r*pi*mR/a) (r*pi*nR/a) (2*jv*pi/b)]);
num_YYYY5=double(subs(YYYY5,[a r iv mR nR y yA yU mL nL b jv],[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.25 0.35 0.45 0.55]))
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!