
108 GPGPU Programming for Games and Science
p
0
through p
d
, the least-squares approximation is obtained by minimizing
E(p
0
,...,p
d
)=
b
a
|f(x) − p(x)|
2
dx (3.4)
The coefficients of the polynomial are determined by setting the first-order
partial derivatives of E to zero,
0=
∂E
∂p
j
= −2
b
a
(f(x) − p(x)))x
j
dx (3.5)
which simplifies to
b
a
x
j
p(x) dx =
b
a
x
j
f(x) dx (3.6)
and then to
d
i=0
b
i+j+1
− a
i+j+1
i + j +1
p
i
=
b
a
x
j
f(x) dx = c
j
(3.7)
where the last equality defines the values c
j
.Thisisalinearsystemofd +1
equations in d + 1 unknowns that may be solved numerically for the p
i
.It
is necessary to integrate x
j
f(x), either in closed form or through numerical
quadrature methods, ...