# NDSolve with Solution Dependent Parameters

I am trying to solve a fairly simple ODE system using NDSolve and am having a problem with the variables. I want to solve the system below:

eqs={x'[t]==0.01+k[x[t]]*Sin[x[t]], k'[x[t]]==(1/100)*(Sin[x[t]] - 3/4^10), k[x[0]]==1, x[0]==0};
sol=NDSolve[eqs, {x, k}, {t, 0, 1000}]


However, when I run this I get "NDSolve::overdet: There are fewer dependent variables, {x[t]}, than equations, so the system is overdetermined." I assume that it is because of how I have entered my initial conditions / passed x[t] through all of k[x[t]], but I don't know this for sure.

I have managed to get the above code to run if I change the following:

eqs={x'[t]==0.01+k[t]*Sin[x[t]], k'[t]==(1/100)*(Sin[x[t]] - 3/4^10), k[0]==1, x[0]==0};
sol=NDSolve[eqs, {x, k}, {t, 0, 1000}]


removing all of the times I passed x[t] through k[x[t]] and replacing it with k[t]. But what I don't know is are these things the same to Mathematica? That is, is the second example solving what I tried to with the first one?

Try the following. First, let us solve the equation for k[x]:

DSolve[{k'[x] == (1/100)*(Sin[x] - 3/4^10), k[0] == 1}, k, x]

(*  {{k -> Function[{x}, (105906176 - 3 x - 1048576 Cos[x])/104857600]}}  *)


Then let us use this solution in the equation for x[t]:

nds = NDSolve[{x'[t] ==
0.01 + ((105906176 - 3 x[t] - 1048576 Cos[x[t]])/104857600)*
Sin[x[t]], x[0] == 0}, x, {t, 0, 1000}][[1, 1]]


Let us look at the solution:

Plot[x[t] /. nds, {t, 0, 1000}, PlotRange -> All]


Have fun!

• Your tricky solution becomes a little bit nicer ( ;-) )with K = DSolveValue[{k'[x] == (1/100)*(Sin[x] - 3/4^10), k[0] == 1}, k, x];X = NDSolveValue[{x'[t] == 0.01 + K[ x[t]]*Sin[x[t]], x[0] == 0}, x, {t, 0, 1000}];Plot[X[t], {t, 0, 1000}, PlotRange -> All] Commented Sep 21, 2021 at 10:25
• @Ulrich Neumann I agree with everything except the word "tricky." Commented Sep 21, 2021 at 19:54
• @AlexeiBoulbitch Thank you both for your very simple solutions! I had not thought about doing it as DSolve first, before doing the NDSolve, thanks again! Commented Sep 23, 2021 at 8:33