How to calculate the symbolic integration of rational functions?

10 ビュー (過去 30 日間)
JINGYI
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
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 = 
int(fp,x,0,1)
ans = 
0.54553107040141442996330649608048
vpaintegral(1/f,x,0,1)
ans = 
0.545531
f = matlabFunction(f);
integral(@(x)1./f(x),0,1)
ans = 0.5455
  4 件のコメント
JINGYI
JINGYI 2023 年 1 月 25 日
That's why I suppose matlab needs some assumptions. The problem is it would be a huge labour if I try to figure out those assumptions by myself. I was expecting some interactive way of integration, where matlab keeps asking me questions like 'if '. Is it possible?
Torsten
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 = 
int(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.
partfrac(K2,x,'factormode','real')
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 件のコメント
John D'Errico
John D'Errico 2023 年 1 月 27 日
But that merely says, that IF you knew the roots of the polynomial P(x), you can solve the problem. Since you cannot perform that task if the coefficient of P are not numeric, AND the degree is higher than 4, the solution returned by Wolfram Alpha is a bit of a mirage.
As I said, mathematical impossiblility is still impossible, no matter how you cloak it.
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
int(1/(x^5+x^4+x^3+x^2+x+1),x,0,1)
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

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by