Inconsistent results for symbolic integration of >2 cosine factors

6 visualizzazioni (ultimi 30 giorni)
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
ans = 
%% Symbolic Solutions
% Expected
y_2cos_sym = simplify(int(cos(x*m)*cos(x*n), x, -pi, pi))
y_2cos_sym = 
% Unexpected
y_3cos_sym = simplify(int(cos(x*m)*cos(x*n)*cos(x*p), x, -pi, pi))
y_3cos_sym = 
0
%% Numerical Solutions
m = 0; n = 0; p = 0;
% Expected
y_2cos_num = int(cos(x*m)*cos(x*n), x, -pi, pi)
y_2cos_num = 
% Expected
y_3cos_num = int(cos(x*m)*cos(x*n)*cos(x*p), x, -pi, pi)
y_3cos_num = 
  3 Commenti
Joel Lynch
Joel Lynch il 18 Feb 2024
Thanks, will do. For what it's worth, Maple 2023 seems to miss this too. Not sure about Mathematica.
Paul
Paul il 18 Feb 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
ans = 
%% Symbolic Solutions
% Expected
y_2cos_sym = (int(cos(x*m)*cos(x*n), x, -pi, pi))
y_2cos_sym = 
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) = 
C(n) is not returned as piecewise, and n = -2 and n = 2 cause problems
try
C(2)
catch ME
ME.message
end
ans = 'Division by zero.'
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)
C2 = 
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.

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by