How to integral 2 time
4 次查看(过去 30 天)
显示 更早的评论
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)
1 个评论
Walter Roberson
2017-6-14
This question is closely related to https://www.mathworks.com/matlabcentral/answers/344635-i-don-t-know-why-matlab-don-t-give-me-the-answer-for-this-integral
回答(1 个)
Walter Roberson
2017-6-14
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 个评论
Walter Roberson
2017-6-14
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
2017-6-14
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!