Different integration results from int method in symbolic math toolbox

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

Hi, everyone,
I have received the reply to this question from USA development team of Mathworks.
The original reply is shown as follows:
%%%%%%%%%%%%%%%%%%%%%
I have received word from Mathworks and they have confirmed it is a bug. Unfortunately, this seems to be a niche case and does not have a workaround. The development team has been informed of this and a potential fix will be released in a future update.
The issue has been investigated and the root cause has been identified as an incorrect pattern being applied to the inputs. The incorrect pattern locally affects the integrals of the form:
1. int(t^w*ln(b*t^d)^m*exp(-u*t^s)*cos(c*t^s),t,0,Inf)
2. int(t^w*ln(b*t^d)^m*exp(-u*t^s)*sin(c*t^s),t,0,Inf)
Mathworks and I would like to thank you for bringing this bug to our attention and express our apologies for the inconvenience this may have caused. I will mark this ticket closed but please email support@techsource-asia.com again should you have other queries.
%%%%%%%%%%%%%%%%%%%%%
So, I think, just wait for the update of Matlab.
Thank you all for viewing this question.

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
ans = 
0
F1=int(y1,x,0,Inf)
F1 = 
F2=int(y2,x,0,Inf)
F2 = 
The anti-derivatives are the same for both
F1 = int(y1,x)
F1 = 
F2 = int(y2,x)
F2 = 
As are the integrals computed from the anti-derivatives, which match the original F1
limit([F1 F2],x,Inf) - subs([F1 F2],x,0)
ans = 

3 Comments

Is it a bug for built-in symbolic integration of matlab? I also use Maple to evaluate same problem. Maple gives the same results (also right result) for both F1 and F2. No bug appears for Maple.
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)
F1 = 
F2=int(y2,x,0,t)
F2 = 
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)
ans = logical
1
F1=int(y1,x,0,Inf)
F1 = 
F2=int(y2,x,0,Inf)
F2 = 
isAlways(F1 == F2)
Warning: Unable to prove '1/((1 + w*1i)^2 + 1) == -(w - 1)/((w - 1)^2 + 1)'.
ans = logical
0
temp = F1 - F2
temp = 
fplot([real(temp), imag(temp)], [-5 5])

Sign in to comment.

Products

Release

R2022a

Asked:

on 19 Nov 2023

Answered:

on 29 Nov 2023

Community Treasure Hunt

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

Start Hunting!