How to integral 2 time

3 views (last 30 days)
PP STML
PP STML on 14 Jun 2017
Commented: Walter Roberson on 14 Jun 2017
I am a vey new Matlab user. Could anyone please help me with this integral? How can I get the result of g?
f(x) = int((6719222573537927*exp((5*x)/2 - (15*u)/2)*(u + x)^(3/2)*(u - x)^19)/576460752303423488, u, abs(x), Inf)
h(x) = exp(-(x-3)^2)
gexpr = abs(f(x)-h(x))*f(x)
gfun = matlabFunction(gexpr)
g = integral(gfun, -inf, inf)

Answers (1)

Walter Roberson
Walter Roberson on 14 Jun 2017
The expression is simply too complicated for MATLAB to integrate symbolically. There are other software vendors and tools that are more complete. Two of the leading commercial alternatives are Maple (Maplesoft) and Mathematica (Wolfram Research)
  3 Comments
Walter Roberson
Walter Roberson on 14 Jun 2017
The numbers involved in the computation get so large that you are getting catastrophic cancellation that is leaving MATLAB with the impression of very large oscillations fairly close together. Numeric integration cannot cope with oscillations that large and that rapid.
If you were to plot gexpr (the symbolic expression that is to be integrated) then the output you would get would vary greatly depending how many digits you were calculating to. 75 digits of precision is not enough to get anything reasonable for plotting between 34.82 to 34.87 for example, but 200 digits is enough so that the wild swings in the resulting plot over that range are only magnitude +/- 10^(-33) . Unfortunately switching to 200 digits is not enough to save the numeric integral: you are integrating to infinity and the intermediate values just get larger and larger, so you would need infinitely high precision to handle the values as you got towards infinity.
Walter Roberson
Walter Roberson on 14 Jun 2017
I had some success in plotting when I broke f(x) into a piecewise based upon x < 0 or not, with one integrating from x to infinity and the other integrating from -x to infinity, to get the effect of the x as the bound. The two parts separately integrate more simply than the combination -- though one of the two is notably more messy. You can then extend the piecewise to the calculation of gexpr . The resulting expression has a peak at about -3/4, and a much smaller peak around 1, and graphs considerably more readily.
However, the overall result still involves expressions that have terms that vary too quickly for Maple to be willing to try to integrate, even though in practice the values get very small.

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox 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!