≡ ▼
=L_POLYINT(coeffs, [k])

ArgumentDescriptionExample
coeffsCoefficients of the original polynomial in decreasing order of power
k(default=0) The constant of integration0

## Description

L_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},
L_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 L_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},
L_POLYINT(px,,-1,5)
)

Result: 408


## Lambda Formula

This code for using L_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
*/
L_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,L_POLYVAL(row,b)-L_POLYVAL(row,a))),
qx
)
));


### Named Function for Google Sheets

Name: L_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,L_POLYVAL(row,b)-L_POLYVAL(row,a))),
qx
)
)


## L_POLYINT Examples

Example
Find the area under $$(x^2+3x-1)(4x+1)$$ between a=0 and b=10. Use L_POLYMULT to multiply the two polynomials, then find q(x) and evaluate the integral using L_POLYVAL(qx,b)-L_POLYVAL(qx,a).
Test: Copy and Paste this LET function into a cell
=LET(
px_1, {1,3,-1},
px_2, {4,1},
px, L_POLYMULT(px_1,px_2),
qx, L_POLYINT(qx),
L_POLYVAL(qx,10)-L_POLYVAL(qx,0)
)

Result: 14273.333

References & Resources