Integrating from polyint(p)

5 visualizzazioni (ultimi 30 giorni)
Tatte Berklee
Tatte Berklee il 3 Ago 2020
Commentato: Tatte Berklee il 4 Ago 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?

Risposta accettata

John D'Errico
John D'Errico il 4 Ago 2020
Modificato: John D'Errico il 4 Ago 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 Commento
Tatte Berklee
Tatte Berklee il 4 Ago 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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Polynomials in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by