Different integration results from int method in symbolic math toolbox
Show older comments
Hi, everyone, I am current using integration method of int in symbolic math toolbox, the code is shown as follows:
%%%%%%%%%%%%%%%
clear;
clc;
syms x w;
assume(x,"real");
assumeAlso(w,"real");
% integration
y1=exp(-1i*w*x-x)*sin(x);
y2=exp(-(1i*w+1)*x)*sin(x);
F1=int(y1,x,0,Inf)
F2=int(y2,x,0,Inf)
%%%%%%%%%%%%%%%
% parameter i is imaginary unit %
When running the above code in matlab:
The answer for F1 is : (right answer)
1/((1 + w*1i)^2 + 1)
The answer for F2 is :
-(w - 1)/((w - 1)^2 + 1)
In the above code, function y1 and y2 are identical function in different forms. Why different integration results are achieved?
Function F2 does not even have imaginary unit i.
Does anyone have explanation for this?
Thank you very much
Accepted Answer
More Answers (1)
Looks like a bug in the computation of F2?
syms x w;
assume(x,"real");
assumeAlso(w,"real");
% integration
y1=exp(-1i*w*x-x)*sin(x);
y2=exp(-(1i*w+1)*x)*sin(x);
simplify(y1 - y2) % verify
F1=int(y1,x,0,Inf)
F2=int(y2,x,0,Inf)
The anti-derivatives are the same for both
F1 = int(y1,x)
F2 = int(y2,x)
As are the integrals computed from the anti-derivatives, which match the original F1
limit([F1 F2],x,Inf) - subs([F1 F2],x,0)
3 Comments
Yifan
on 19 Nov 2023
It looks like a bug. Maybe someone else will have a different opinion. You can always file a bug report with TMW, including a link to this thread to illustrate the issue, and see what they say. If you do file a bug report, it would be nice if you post back here with the final TMW assessment.
Also, int works fine if the upper limit of integration is not Inf. I've had trouble in the past with int not working correctly when one of the limits of integration was Inf and in that case TMW agreed it was a bug.
syms x w;
assume(x,"real");
assumeAlso(w,"real");
% integration
y1=exp(-1i*w*x-x)*sin(x);
y2=exp(-(1i*w+1)*x)*sin(x);
syms t real
F1=int(y1,x,0,t)
F2=int(y2,x,0,t)
Gotta be a bug.
syms x w
assume(x,"real");
assumeAlso(w,"real");
y1=exp(-1i*w*x-x)*sin(x);
y2=exp(-(1i*w+1)*x)*sin(x);
isAlways(y1 == y2)
F1=int(y1,x,0,Inf)
F2=int(y2,x,0,Inf)
isAlways(F1 == F2)
temp = F1 - F2
fplot([real(temp), imag(temp)], [-5 5])
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








