필터 지우기
필터 지우기

Inconsistent results for symbolic integration of >2 cosine factors

조회 수: 2 (최근 30일)
Joel Lynch
Joel Lynch 2024년 2월 18일
댓글: Paul 2024년 2월 18일
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
Joel Lynch
Joel Lynch 2024년 2월 18일
Thanks, will do. For what it's worth, Maple 2023 seems to miss this too. Not sure about Mathematica.
Paul
Paul 2024년 2월 18일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by