Integrating from polyint(p)

조회 수: 5 (최근 30일)
Tatte Berklee
Tatte Berklee 2020년 8월 3일
댓글: Tatte Berklee 2020년 8월 4일
Hi folks!
I have a question regarding univariate integration from the coefficients produced (e.g. 1x8 double) from polynomial integration.
An example code I have is:
[p,S] = polyfit(x,y,N);
q=polyint(p);
At this point, the code produces something like 1x8 double with polynomial coefficients.
But the ultimate integral I would like to compute is an indefinite integral with lower and upper limit being 1 and inf respectively in the form of a fraction:
x/(the polynomial I got for q with x being the variable).
How would I do this?

채택된 답변

John D'Errico
John D'Errico 2020년 8월 4일
편집: John D'Errico 2020년 8월 4일
Sorry, but polyint cannot integrate a rational polynomial, and certainly not over an infinite region. Depending on the roots of the polynomial, it may or may not have an integral.
The simplest way to do your integration is to use the symbolic toolbox.
syms x
P = x^4 + 8*x^3 + 23*x^2 + 28*x + 12;
int(x/P,x,[1,inf])
ans =
log((3*2^(1/2))/8) + 2/3
If you have only the coefficients of the polynomial, you can still do it.
pcoeff = [1 8 23 28 12];
roots(pcoeff)
ans =
-3
-2
-2
-1
So a happy list of roots.
int(x/poly2sym(pcoeff,x),[1,inf])
ans =
log((3*2^(1/2))/8) + 2/3
  댓글 수: 1
Tatte Berklee
Tatte Berklee 2020년 8월 4일
John, thank you. Since I know exactly to which order my polynomial goes, I did something like: (e.g. n=6)
fun = @(x) x/(p(1,1)*x.^6+p(1,2)*x.^5+p(1,3)*x.^4+p(1,4)*x.^3+p(1,5)*x.^2+p(1,6)*x+p(1,7)).^2;
exp = integral(fun,0,Inf,'ArrayValued',true);
Does my code look valid?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by