How to calculate the symbolic integration of rational functions?

8 ビュー (過去 30 日間)
JINGYI 2023 年 1 月 25 日
編集済み: Walter Roberson 2023 年 1 月 28 日
I have no trouble integrating functions whose denominator is a polynomial of degree < 4. But when I try to integrate:
syms x real
int(1/(x^4 + x^3 + x^2 + x + 1), x, 0, 1)
ans = 
It just output what I have input. Is it even possible to integrate such functions.
Moreover, I also need to integrate symbolic rational functions. In that case, how can I tell Matlab about some assumptions such that ?(I thought it may need that to do the job)

回答 (3 件)

Torsten 2023 年 1 月 25 日
編集済み: Torsten 2023 年 1 月 25 日
syms x
f = x^4+x^3+x^2+x+1;
fp = partfrac(1/f,x,'FactorMode','real')
fp = 
ans = 
ans = 
f = matlabFunction(f);
ans = 0.5455
  4 件のコメント
Torsten 2023 年 1 月 25 日
It might be possible for polynomials of degree <= 4 to deduce conditions on the parameters what kind of zeros you will get (real, complex) and if there is a zero in the interval of integration. But you will have to derive these conditions on your own.
For symbolic polynomials of degree > 4, this will lead to nowhere (see John D'Errico's example).


John D'Errico
John D'Errico 2023 年 1 月 25 日
編集済み: John D'Errico 2023 年 1 月 25 日
If the polynomial has a sufficiently low degree, it can always be factored, in which case as has been pointed out, you just turn it into a sum of separate terms using partial fractions. If it has degree higher than 4, and has no simple splitting into factors, then you can still use partfrac to perform the work.
syms x
K = 1/(x^5 + 2*x^4 + 3*x^3 + 4*x^2 + 5*x + 6)
K = 
Kfac = partfrac(K,x,'factormode','real')
Kfac = 
ans = 
A problem of course, is that if your kernel can not be solved, even using a numerical solver.
syms a
K2 = 1/(x^5 + 2*x^4 + 3*x^3 + 4*x^2 + 5*x + a)
K2 = 
Sadly, there is nothing to be done here, even for as simple a modification as this, if the denominator polynomial has no factorization.
ans = 
At best, you could write it s a function of a. As soon as you define a there in terms of a numeric value, the problem can be solved.
As far as telling MATLAB about the sign of a a discriminant, that does not really help things. All that does is restrict the branches of the solution. It tells MATLAB that some roots would be real valued, but it does not give sufficient information that the polynomial has a factorization. Effectively, that is one of those good news, bad news things.
The good news is, your roots are real.
The bad news is, it does not help you by the slightest amount to solve your problem.
  3 件のコメント
Walter Roberson
Walter Roberson 2023 年 1 月 28 日
編集済み: Walter Roberson 2023 年 1 月 28 日
It does, however, transform the problem from one of being "I have no idea how to integrate this" into "I know how to integrate this if I can find the roots of the polynomial somehow". In some cases there is additional information available that can help determine roots, even if the polynomial has symbolic coefficients.
Wolfram Alpha tends to time out of you ask it to work on polynomials with even one symbolic coefficient, as it is trying to determine whether there are any roots of the polynomial within the bounds of integration, which can be tricky to determine.


Walter Roberson
Walter Roberson 2023 年 1 月 25 日
summed over
In this particular case of a quartic it is possible to list the analytic solutions to the root and so create an analytic result for the integral; it would be pretty long though.
If you extend to as well then
syms x
ans = 
This happens because x^5+x^4+x^3+x^2+x+1 can be factored and so the roots can be calculated readily.
If you extend to x^6 then Wolfram Alpha gives a form similar to the form for ^4
The pattern appears to be int(1/POLY(x), x, 0, 1) = summed over




Community Treasure Hunt

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

Start Hunting!

Translated by