# NDSolve::dsvar error when trying to solve system of differentail equations

I'm currently trying to solve a set of differential equations using NDSolve but I'm getting an error... The following was construced with the help of this answer using Mathematica 11.0.

solution[t_] :=
With[{m = 0.01, L = 0.1, g = 9.81},
NDSolve[{2 m (L^2 - 3 L s[t] + 3 s[t]^2) u''[t] ==
3 L m g Sin[u[t]] + 6 m (L - 2 s[t]) s'[t] u'[t],
m ((L - 2 s[t]) u'[t]^2 + 2 s''[t]) == 0, u == Pi, s == 0,
s' == 1, u' == -0.1}, {u[t], s[t]}, {t, 0, 10}]]

Plot[solution[t], {t, 0, 10}]


The error message is:

NDSolve::dsvar: 0.0002042857142857143 cannot be used as a variable.

NDSolve::dsvar: 0.0002042857142857143 cannot be used as a variable.

NDSolve::dsvar: 0.20428591836734694 cannot be used as a variable.

General::stop: Further output of NDSolve::dsvar will be suppressed during this calculation.


I'm not really sure what to make of the error. I found this post here which to me at least doesn't seem related to my issue.. The initial values should work (I think at least) and I checked a couple of times now if there is any mistake in the equations...

• Correct code: solution[t_] = With[{m = 0.01, L = 0.1, g = 9.81}, NDSolve[{2 m (L^2 - 3 L s[t] + 3 s[t]^2) u''[t] == 3 L m g Sin[u[t]] + 6 m (L - 2 s[t]) s'[t] u'[t], m ((L - 2 s[t]) u'[t]^2 + 2 s''[t]) == 0, u == Pi, s == 0, s' == 1, u' == -0.1}, {u[t], s[t]}, {t, 0, 10}]][[1, All, 2]] – Alex Trounev Apr 5 '19 at 16:59

By giving solution the argument t, what is supposed to be the variable in the iterator {t, 0, 10} has a numeric value when solution[t] is called.

Clear["Global*"]

solution =
With[{m = 0.01, L = 0.1, g = 9.81},
NDSolve[{2 m (L^2 - 3 L s[t] + 3 s[t]^2) u''[t] ==
3 L m g Sin[u[t]] + 6 m (L - 2 s[t]) s'[t] u'[t],
m ((L - 2 s[t]) u'[t]^2 + 2 s''[t]) == 0, u == Pi, s == 0,
s' == 1, u' == -0.1}, {u, s}, {t, 0, 10}]];

Plot[Evaluate[{s[t], u[t]} /. solution],
{t, 0, 10},
PlotLegends -> Placed[{s[t], u[t]}, {0.85, 0.55}]] 