# Integrating a B-Spline basis function with respect to the standard normal PDF

I am looking for ways to evaluate exactly (i.e. analytically or semi-analytically) integrals of the type: $$\int_{-\infty}^{+\infty}B_{i}^k(u)e^{-\frac{(u-\mu)^2}{2\sigma^2}}du,$$ where $$B_i^k$$ is a spline of order $$k$$, an element of the B-Spline basis for the linear space of splines of order $$k$$ on knots $$\{t_i\}$$, defined as usual recursively by: $$B_i^k(x)=\frac{x-t_i}{t_{i+k}-t_i}B_i^{k-1}(x)+\frac{t_{i+k+1}-x}{t_{i+k+1}-t_{i+1}}B_{i+1}^{k-1}(x),$$ with $$B_i^0(x)=\begin{cases} 1 & x\in [t_i;t_{i+1}) \\ 0 & \text{otherwise } \end{cases}$$ Of particular interest would be the case of $$\mu=0, \sigma=1$$.

I am aware of the Gauss-Hermite quadrature : $$\int_{-\infty}^{+\infty}f(x)e^{-\frac{x^2}{2}}\approx \sum_{i=1}^n w_i f(x_i),$$ where $$x_i$$ are the roots of a Hermite polynomial of order $$n$$ and $$w_i$$ are the associated weights. Importantly, the approximation sign can be replaced by an exact equality when $$f$$ is a polynomial of degree $$\leq 2n-1$$. (There are versions where the integral is with respect to $$e^{-x^2}$$ instead of $$e^{-\frac{x^2}{2}}$$, by changing the type of Hermite polynomial employed).

My question is : is there such an exact equality formula for B-spline basis functions? I am looking to express the integral at the beginning of this question as a sum analogously to the Gauss-Hermite quadrature.

The problem seems to be that even though $$B_i^k$$ is known to have finite support, it is not itself a polynomial: each of the restrictions $$B_i^k|_{(t_j;t_{j+1})}$$ is a polynomial, without the full function being a polynomial. Otherwise, the answer would have been a trivial application of the Gauss-Hermite quadrature. Is is possible that there is a Gauss-Hermite-type quadrature for integration domains that are compact intervals (as opposed to integration domains that are $$\mathbb{R}$$) ?

• So the answer below explains that case c) in your query applies. An exact quadrature formula does not exist because $\int_a^b x^p e^{-x^2}\,dx$ has no expression in terms of elementary functions if $p$ is an even integer. Sep 12, 2021 at 15:23

Since a B-spline is a piecewise polynomial function, the question is whether there exists an exact equality formula for the integral $$\int_{-a}^{b}u^pe^{-u^2/2}du$$. This integral equals an elementary function of $$a$$ and $$b$$ for $$p$$ an odd integer, while for $$p$$ an even integer it contains error functions. In general the B-spline will contain both even and odd powers, so no "exact equality formula" in terms of elementary functions will be forthcoming.

For example, the uniform B-spline of order 3 with knots at 0,1,2,3 is given by $$B(u)=\begin{cases} 0&\text{if}\;\; u<0,\\ u^2/2&\text{if}\;\; 0 \le u < 1,\\ (-2u^2+6u-3)/2&\text{if}\;\; 1 \le u < 2,\\ (3-u)^2/2&\text{if}\;\; 2 \le u < 3,\\ 0&\text{if}\;\; u\ge 3, \end{cases}$$ and the integral $$\int_{-\infty}^\infty B(u)e^{-u^2/2}\,du$$ equals $$\frac{1}{2} \sqrt{\frac{\pi }{2}} \left(6 \,\text{erf}\left(\frac{1}{\sqrt{2}}\right)+10 \,\text{erf}\left(\frac{3}{\sqrt{2}}\right)-15\, \text{erf}\left(\sqrt{2}\right)\right)+\frac{3 \left(1-2 e^{5/2}+e^4\right)}{2e^{9/2}}.$$ No further simplification in terms of elementary functions is possible.
• It seems I cannot upvote the answer, because I now have too low reputation.
– Gabe
Sep 13, 2021 at 10:25
• The answer is correct. One has to do the tedious computation, but a semi-analytical formula for integrals of this type does exist. Erf(.) is accurate enough to ensure that the final result obtained by this semi-analytical integration will also be accurate and not cause some convergence issues in the application I had in mind.
– Gabe
Sep 13, 2021 at 10:28
• Is there a general formula for the coefficients of a piecewise polynomial that forms a part of the B-spline basis function ?
– Gabe
Sep 13, 2021 at 14:37
• there is a recursion relation, no closed-form expression; in practice, I would imagine you would use some computer algebra package to find the coefficients and return the integral in terms of exponential functions and error functions. I used Mathematica for the order 3 expression given above. Sep 13, 2021 at 14:50
• for example, with Mathematica you would enter a command like Integrate[BSplineBasis[{d,{u1,u2,…,um}},n,x]*Exp[-x^2],{x,-Infinity,Infinity}] , see reference.wolfram.com/language/ref/BSplineBasis.html Sep 13, 2021 at 15:29