For an InterpolatingFunction
$y:\ \mathbb{R}\to\mathbb{R}^2$, Plus
is unaware of this, so when I do any modifications to it in an unevaluated form, it breaks the result
y = Interpolation[Table[{i, RandomReal[{0, 1}, 2]}, {i, 1, 10}]];
y[t]
y[t] + {1, 2}
(* InterpolatingFunction[{{1.,10.}},<>][t]`
{1+InterpolatingFunction[{{1.,10.}},<>][t],2+InterpolatingFunction[{{1.,10.}},<>][t]} *)
I ran into it doing things like:
y = Interpolation[Table[{i, RandomReal[{0, 1}, 2]}, {i, 1, 10}]];
f[t_] := Piecewise[{{ {1, 2} + y[t], t < 5}}];
df[t_] := Evaluate[D[f[t], t]]
df[t]
df[3]
And I can't figure out how to prevent expressions like {1,2} + y[t]
from being evaluated while still being able to differentiate them. If Plus
just realized that y[t]
is $\mathbb{R}^2$ valued, I think that would simplify everything for me. Is there some way to set this property?
y[t_] = {Interpolation[Table[{i, RandomReal[{0, 1}]}, {i, 1, 10}]][t], Interpolation[Table[{i, RandomReal[{0, 1}]}, {i, 1, 10}]][t]}
is not what you're looking for? $\endgroup$