POLYINT
=POLYINT(coeffs, [k])
Argument | Description | Example |
---|---|---|
coeffs | Coefficients of the original polynomial in decreasing order of power | |
k | (default=0) The constant of integration | 0 |
In the template file, navigate to the Polynomials worksheet to see the POLYINT function in action.
Description
POLYINT returns the integral of polynomial p(x). The integral of a polynomial p(x) of degree n is a new polynomial q(x) of degree n+1. If you know what the constant of integration should be, you can include that constant as a scalar k. Otherwise, it is assumed to be zero.
$$p(x) = β_nx^n + β_{n-1}x^{n-1} + … + β_1x + β_0$$
$$q(x) = \int β_3x^3+β_2x^2+β_1x+β_0 dx=\frac{β_3x^4}{4}+\frac{β_2x^3}{3}+\frac{β_1x^2}{2}+β_0x+k$$
As an example, what is the integral of p(x)=2x^3+5x+6? Remember to include 0 as the coefficient of the x^2 term.
=LET( k, 42, px, {2,0,5,6}, POLYINT(px,k) ) Result: {0.5, 0, 2.5, 6, 42} q(x) = 0.5x^4 + 0x^3 + 2.5x^2 + 6x + 42
You can specify values for a and b using POLYINT(px,,a,b) to evaluate \(\int_a^b p(x) dx = q(b)-q(a)\). The constant k is not needed in this case and can be left blank. See the following example:
=LET( px, {2,0,5,6}, POLYINT(px,,-1,5) ) Result: 408
Lambda Formula
This code for using POLYINT in Excel is provided under the License as part of the LAMBDA Library, but to use just this function, you may copy the following code directly into your spreadsheet.
Code for AFE Workbook Module (Excel Labs Add-in)
/** * Returns the integral of the polynomial with integration constant k, * optionally evaluated from a to b */ POLYINT = LAMBDA(coeffs,[k],[a],[b], LET(doc,"https://www.vertex42.com/lambda/polyint.html", k,IF(ISBLANK(k),SEQUENCE(ROWS(coeffs),1,0,0),IF(ROWS(k)=1,SEQUENCE(ROWS(coeffs),1,k,0),k)), n,COLUMNS(coeffs), powers,SEQUENCE(1,n,n,-1), qx,HSTACK(coeffs/powers,k), IF(AND(NOT(ISBLANK(a)),NOT(ISBLANK(b))), BYROW(qx,LAMBDA(row,POLYVAL(row,b)-POLYVAL(row,a))), qx ) ));
Named Function for Google Sheets
Name: POLYINT Description: Returns the integral of a polynomial as another polynomial Arguments: coeffs, k, a, b Function: LET(doc,"https://www.vertex42.com/lambda/polyint.html", k,IF(ISBLANK(k),SEQUENCE(ROWS(coeffs),1,0,0),IF(ROWS(k)=1,SEQUENCE(ROWS(coeffs),1,k,0),k)), n,COLUMNS(coeffs), powers,SEQUENCE(1,n,n,-1), qx,HSTACK(ARRAYFORMULA(coeffs/powers),k), IF(AND(NOT(ISBLANK(a)),NOT(ISBLANK(b))), BYROW(qx,LAMBDA(row,POLYVAL(row,b)-POLYVAL(row,a))), qx ) )
POLYINT Examples
Test: Copy and Paste this LET function into a cell =LET( px_1, {1,3,-1}, px_2, {4,1}, px, POLYMULT(px_1,px_2), qx, POLYINT(qx), POLYVAL(qx,10)-POLYVAL(qx,0) ) Result: 14273.333
See Also
POLYVAL, POLYFIT, POLYDER, PINTERP