Inconsistent results for symbolic integration of >2 cosine factors
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
When I integrate the product of two cosine functions with integer arguments, I get an answer that appears correct. When I add a third, the solution simplifies to zero, which is not consistent with at least one case of numerical integration. This occurs with Ver 23.2 of SMT (2023b).
clear
syms m n p x
assume(in(m, 'integer') & in(n, 'integer') & in(p, 'integer'));
assumeAlso(m>=0 & n>=0 & p>=0);
assumptions
%% Symbolic Solutions
% Expected
y_2cos_sym = simplify(int(cos(x*m)*cos(x*n), x, -pi, pi))
% Unexpected
y_3cos_sym = simplify(int(cos(x*m)*cos(x*n)*cos(x*p), x, -pi, pi))
%% Numerical Solutions
m = 0; n = 0; p = 0;
% Expected
y_2cos_num = int(cos(x*m)*cos(x*n), x, -pi, pi)
% Expected
y_3cos_num = int(cos(x*m)*cos(x*n)*cos(x*p), x, -pi, pi)
3 comentarios
Paul
el 18 de Feb. de 2024
clear all
syms m n p x
assume(in(m, 'integer') & in(n, 'integer') & in(p, 'integer'));
assumeAlso(m>=0 & n>=0 & p>=0);
assumptions
%% Symbolic Solutions
% Expected
y_2cos_sym = (int(cos(x*m)*cos(x*n), x, -pi, pi))
y_2cos_sym is returned as piecewise w/o using simplify.
I'm curious about this. I'm surprised that y_2cos_sym is returned as a piecewise function. In other cases I've run into with just a single variable int doesn't recognize special cases for integer parameters in the integrand, so I'm curious why it does so for y_2cos_sym
clear all
syms n integer
syms t w real
f(t) = sin(2*sym(pi)*2*t);
T = 1.4;
C(n) = int(f(t)*exp(-1j*2*sym(pi)*n*t),t,0,T)
C(n) is not returned as piecewise, and n = -2 and n = 2 cause problems
try
C(2)
catch ME
ME.message
end
even though C(n) is well defined for n = 2 (and n = -2)
C2 = int(subs(f(t)*exp(-1j*2*sym(pi)*n*t),n,2),t,0,T)
So why doesn't int return C(n) as a piecewise?
I'm going to guess that y_2cos_sym is a known special case by int but y_3cos_sym (and my C(n)) is not.
Respuestas (0)
Ver también
Categorías
Más información sobre Special Values en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!