# Error after defining a piecewise function

I have the following code:

ClearAll {x, y, z, t, a};
f[t_] := Piecewise[{{-(t/\[Pi])^2 + (2/\[Pi])*t + 1,
0 <= t <= \[Pi]}, {(-1/\[Pi]) t + 3, \[Pi] <= t <= 2 \[Pi]}}];
X[t_] := a*f[t]* Cos[t];
Y[t_] := a*f[t]*Sin[t];
sols = ParametricNDSolveValue[
{Z'[t] == {{X'[t], Y'[t]}, {Y'[t], -X'[t]}}.Z[t],
Z[0] == {{1, 0}, {0, 1}}},
Tr[Z[2 \[Pi]]],
{t, 0, 2 \[Pi]},
a];
Plot[{y = 2, sols[a]}, {a, 0, 0.2}]


I have defined a piecewise function $$f[t]$$, and am then using it to define $$X[t]$$ and $$Y[t]$$.

Before having defined $$f[t]$$, the code was working perfectly. However, now I'm getting an error. What am I doing wrong?

• Sorry, I don't know how to delete this question. I suppose it was because the function that I have defined is not differentiable at $t=\pi$. – freebird Oct 8 at 19:45