# Manipulate a plot of coupled differential equations

Good afternoon,

I am attempting to construct a graph showing the trajectory of two variables over time, based on a coupled system of differential equations and some arbitrary initial conditions which I'll invariably end up changing later.

The model comes from a Latent Differential Equation model, a form of Structural Equation Modelling. A picture of the structural model I'm trying to build is attached below. From it, a coupled system of differential equations can be formed. I'm trying to plot a graph so I can show the behaviour over time based on different coefficients. As such, I'm trying to make a diagram which enables me to manipulate these coefficients. The bulk of my code is below:

sol[etax_, zetax_, gammay_, gammaydot_, etay_, zetay_, gammax_, gammaxdot_] := NDSolve[{
x''[t] - etax*x[t] - zetax*x'[t] - gammay*y[t] - gammaydot*y'[t] == 0,
y''[t] - etay*y[t] - zetay*y'[t] - gammax*x[t] - gammaxdot*x'[t] == 0,
x == 0.1,
x' == 0.1,
y == 0.1,
y' == 0.1},
y, {x, 0, 10}]
Manipulate[
Plot[Evaluate[y[x] /. sol[etax, zetax, gammay, gammaydot, etay, zetay, gammax,
gammaxdot]], {x, 0, 10},PlotRange -> {Automatic, {-10, 10}}],
{{etax, 1, "etax"}, -3, 3, Appearance -> "Labeled"},


When attempting this, I get a large list of warning messages. I am a little new to the Mathematica/Differential Equations circuit so have probably made a rookie error somewhere, but would really appreciate if anyone could offer any corrections or recommendations which help me with this model building.

Many thanks, • Best to supply all of the minimal amount of code the replicates the issue. Oct 19, 2020 at 17:51
• A couple of observations: (1): Within the NDSolve in your sol function, I think you want== (Equal, returns True if lhs and rhs are identical) rather than =(Set). (2) The NDSolve does not specify a domain for t, again, I think you want something, e.g., like {x, 0, 10}, {t, 20} at the end of the NDSolve using whatever appropriate values you need for t. I don't see much else one can do to help without more of your code. Oct 19, 2020 at 18:12

Your NDSolve code is not valid: you should solve for the unknown functions x and y for a range {t,0,tmax}. After fixing this issue sol works. You can then incorparate the method into a Manipulate function e.g.:
sol[etax_,zetax_,gammay_,gammaydot_,etay_,zetay_,gammax_,gammaxdot_,tmax_]:=NDSolve[{x''[t]-etax*x[t]-zetax*x'[t]-gammay*y[t]-gammaydot*y'[t]==0,y''[t]-etay*y[t]-zetay*y'[t]-gammax*x[t]-gammaxdot*x'[t]==0,x==0.1,x'==0.1,y==0.1,y'==0.1},{x[t],y[t]},{t,0,tmax}] You could use a similar approach to using Plot to plot the x and y component over t instead of the using ParametricPlot or you could use ParametricPlot3D to plot x, y and t simultaneously.