Integrating from polyint(p)

5 vues (au cours des 30 derniers jours)
Tatte Berklee
Tatte Berklee le 3 Août 2020
Commenté : Tatte Berklee le 4 Août 2020
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?

Réponse acceptée

John D'Errico
John D'Errico le 4 Août 2020
Modifié(e) : John D'Errico le 4 Août 2020
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 commentaire
Tatte Berklee
Tatte Berklee le 4 Août 2020
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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by