Why Can't int Find a Simple Integral?

syms x real
E(x) = 99/50*dirac(x) + rectangularPulse(0, 300, x)/30000
E(x) = 
int on first term yields expected result
int(99/50*dirac(x),x,-inf,inf)
ans = 
int on second term yields expected result
int(rectangularPulse(0, 300, x)/30000,x,-inf,inf)
ans = 
int on sum fails
int(E(x),x,-inf,inf)
ans = 
Shouldn't that work?

 Accepted Answer

I am very glad to let you know that this bug has been fixed in MATLAB R2023b.
Now, this code produces
syms x real
E(x) = 99/50*dirac(x) + rectangularPulse(0, 300, x)/30000
int(99/50*dirac(x),x,-inf,inf)
int(rectangularPulse(0, 300, x)/30000,x,-inf,inf)
int(E(x),x,-inf,inf)
this output
E(x) =
(99*dirac(x))/50 + rectangularPulse(0, 300, x)/30000
ans =
99/50
ans =
1/100
ans =
int((99*dirac(x))/50 + rectangularPulse(0, 300, x)/30000, x, -Inf, Inf)
Cheers

5 Comments

Why do you think the bug has been fixed ?
Although the summands of E(x) can be integrated separately, it seems this is still not possible for E(x).
Yes, it still seems to be the same problem. However, I don't have 2023b installed and it's not yet in use here on Answers or Online. Perhaps @Pranav inadvertently posted results from a previous version. I guess I'll wait and see until I can actually run 2023b.
Thanks Paul. I believe 2023b Prerelease is up for download. May be you don't have access to 2023b Prerelease. Once the perfect version of R2023b is shipped, you should be able to verify this answer.
Torsten
Torsten on 28 Jun 2023
Edited: Torsten on 28 Jun 2023
Once the perfect version of R2023b is shipped, you should be able to verify this answer.
I hope not :-)
Now that 2023b is here, let's check for its perfection :)
syms x real
E(x) = 99/50*dirac(x) + rectangularPulse(0, 300, x)/30000
E(x) = 
int on first term yields expected result
int(99/50*dirac(x),x,-inf,inf)
ans = 
int on second term yields expected result
int(rectangularPulse(0, 300, x)/30000,x,-inf,inf)
ans = 
int on sum succeeds
int(E(x),x,-inf,inf)
ans = 

Sign in to comment.

More Answers (1)

Tips
  • In contrast to differentiation, symbolic integration is a more complicated task. If int cannot compute an integral of an expression, check for these reasons:
  • The antiderivative does not exist in a closed form.
  • The antiderivative exists, but int cannot find it.
If int cannot compute a closed form of an integral, it returns an unresolved integral.
Try approximating such integrals by using one of these methods:
  • For indefinite integrals, use series expansions. Use this method to approximate an integral around a particular value of the variable.
  • For definite integrals, use numeric approximations.
Look into Tips section of page for that reason, Going by tips section, if you consider the numeric approximations
syms x real
E(x) = 99/50*dirac(x) + rectangularPulse(0, 300, x)/30000
E(x) = 
int(E(x),x,-4,4) % with a numeric approximation it works
ans = 

1 Comment

I don't think that's what the Tips section means for "numeric approximation," which, for example, would be using vpaintegral.
In this case, the exact answer is, I think:
sym(99)/sym(50) + 1/sym(100)
ans = 
And that answer can be obtained with finite limits of integration that cover the full range of E(x) where it's non-zero
syms x real
E(x) = 99/50*dirac(x) + rectangularPulse(0, 300, x)/30000;
int(E(x),x,-1e6,1e6)
ans = 
Seems like this problem with +- inf as the limits of integration is easy enough that int should return a result. Unless there's some sublety that I'm missing.
This works
int(E(x),x,-inf,1e6)
ans = 
But this doesn't?
int(E(x),x,-1e6,inf)
ans = 
I wonder if this is related to the issues raised in this Question, which I thought were fixed in R2022a.
But this does?
expand(int(E(x),x,-inf,inf))
ans = 
This sure looks like a bug to me.

Sign in to comment.

Products

Release

R2022b

Tags

Asked:

on 26 Feb 2023

Commented:

on 17 Sep 2023

Community Treasure Hunt

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

Start Hunting!