Problems evaluating symbolic integral

3 次查看(过去 30 天)
I'm having issues evaluating the definite integral of a symbolic expression using MATLAB's Symbolic Toolbox:
syms t n
assume(n, 'integer')
expression = sin(3*t)^2 * cos(n*t);
value = int(expression, t, -pi, pi);
This returns that the integral is 0 everywhere, despite the fact that there should be a special case where the integral is non-zero at n = 6. When I don't make the assumption that 'n' is an integer, I get an expression that is singular at n = 6. Is there some way that I can adapt my code so that it returns the expected answer? For reference, I go on to take the sum of the integral expressions for increasing values of n using symsum(), and would like to avoid the case where I need to explicitly define these singular values of 'n'. I am trying to avoid evaluating this integral numerically, if at all possible.
  2 个评论
David Goodmanson
David Goodmanson 2020-8-2
Hi Joshua,
Certainly value = 0 for integer n is a bad result.
But for unrestricted n, the result at n = 6 is not singular. The result is
value = -(36*sin(pi*n))/(n*(n^2 - 36)) = -(36*sin(pi*n))/(n^3 - 36n))
Both the numerator and denominator are zero at n = 6, and by l'hopital's rule the result is
-36*pi*cos(pi*6) / (3n^2 - 36) | n= 6 = -pi/2
which is correct.
Joshua Wilson
Joshua Wilson 2020-8-2
Hi David,
Thanks for your response. This makes sense, I missed the fact that both the numerator and denominator being 0 would allow this to be handled. I suppose I can use the limit() function to evaluate the expressions properly.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by