Consider the functions phi(t_)
and psi(t_)
defined in the code below. These are used as basis functions for interpolation purposes. Consider a “time” variable T
, a total number of interpolation nodes n0
and a step h0
. Consider the values at nodes given by variables a
and b
. The required interpolation is defined by the function q(t_)
defined below as the sum of a
times phi
plus b
times psi
.
phi(t_) := Boole(-1 <= t <= 1) (1 - Abs(t))^2 (1 + 2 Abs(t));
psi(t_) := Boole(-1 <= t <= 1) t (1 - Abs(t))^2;
T = N@Pi
n0 = 500;
h0 = T/n0;
a = Table(Cos(i*h0), {i, 0, n0});
b = Table(Sin(i*h0), {i, 0, n0});
q(t_) = Sum(a((k + 1))*phi(t/h0 - k) + h0*b((k + 1))*psi(t/h0 - k), {k, 0, n0});
When constructing the interpolated function q(t_)
in this kind of manner results in operations on q(t_)
taking way too long. A simple plot for example
AbsoluteTiming(Plot(q(t), {t, 0, T}))
takes more than 4 seconds to compute in my machine. Integrating this function with
NIntegrate(q(t), {t, 0, Pi/2})
sends the message
NIntegrate`SymbolicPiecewiseSubdivision::maxpwc: The number of piecewise regions has exceeded the maximum value specified by the option MaxPiecewiseCases -> 100. The integration will continue with no piecewise subdivision.
I can get around the integration issue by reducing the number of interpolation nodes to no more than 200, however, this begs the question of whether or not I am doing this the right way. Is there a better way to construct the q(t_)
function?
Note that I cannot define q(t_)
in the “set delayed” way because my a
and b
coefficients are constantly changing to approach other functions, and I need to store every interpolated function separately.