2
$\begingroup$

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[0] == {{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?

$\endgroup$

closed as off-topic by Bob Hanlon, bbgodfrey, Michael E2, m_goldberg, MarcoB Oct 16 at 12:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, bbgodfrey, Michael E2, m_goldberg, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ 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. $\endgroup$ – bbgodfrey Oct 15 at 14:21
  • $\begingroup$ Incidentally, Clear[x, y, z, t, a, f] has no effect on X, Y, and Z, because Mathematica is case-sensitive. $\endgroup$ – bbgodfrey Oct 15 at 14:27
  • $\begingroup$ 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 $\endgroup$ – Jack LaVigne Oct 15 at 22:12
1
$\begingroup$

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[0] == {{1, 0}, {0, 1}}}, 
    Tr[Z[2 π]], {t, 0, 2 π}, a];

Plot[{y = 2, sols[a]}, {a, 0, 0.001}]

plot1

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}]

plot2

$\endgroup$
0
$\begingroup$

You have a syntax error in the first line. Try with:

Clear[x,y,z,t,a,f];
$\endgroup$
  • $\begingroup$ Thanks. That does not remove the error though $\endgroup$ – freebird Oct 15 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.