# Error in a simple plotting code [closed]

I have the following code:

Clear{x, y, z, t, a, f};
f[t_] := Sin[t];
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 == {{1, 0}, {0, 1}}},
Tr[Z[2 π]], {t, 0, 2 π}, a];
Plot[{y = 2, sols[a]}, {a, 0, 0.001}]


The error message that I'm getting is this:

There are many more dependent variables, {X[t],Y[t],X[t]}, than equations, so the system is underdetermined.

The same code had worked before, when I had not defined f[t]. So I know that the system should not be overdetermined. Where am I going wrong?

• Using "12.0.0 for Microsoft Windows (64-bit) (April 6, 2019)" with or without the first line of your code corrected or deleted works fine for me. Try copying your code from the question and running it in a new Mathematica session. – bbgodfrey Oct 15 at 14:21
• Incidentally, Clear[x, y, z, t, a, f] has no effect on X, Y, and Z, because Mathematica is case-sensitive. – bbgodfrey Oct 15 at 14:27
• In the ParametricNDSolve the first equation equates the derivative of Z to a vector. The right hand size of the equation is a vector times Z[t]. I am a bit confused as to what your intent is. – Jack LaVigne 5 mins ago – Jack LaVigne Oct 15 at 22:12

The following works.

Clear[X, Y, Z, t, a, f];
f[t_] := Sin[t];
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 == {{1, 0}, {0, 1}}},
Tr[Z[2 π]], {t, 0, 2 π}, a];

Plot[{y = 2, sols[a]}, {a, 0, 0.001}] I believe the above plot is worthless; it is only showing the jitter of machine numerics. However, the following plot, over the more reasonable domain [0,1], is probably OK.

Plot[{y = 2, sols[a]}, {a, 0, 1}] You have a syntax error in the first line. Try with:

Clear[x,y,z,t,a,f];

• Thanks. That does not remove the error though – freebird Oct 15 at 13:46