Double pendulum simulation
equations =
{x1''[t] = -(alpha'[t])^2*l1*sin[alpha[t]] + alpha''[t]*l1*cos[alpha[t]],
y1''[t] = (alpha'[t])^2*l1*cos[alpha[t]] + alpha''[t]*l1*sin[alpha[t]],
x2''[t] = x1''[t] - (beta'[t])^2*l2*sin[beta[t]] + beta''[t]*l2*cos[beta[t]],
y2''[t] = y1''[t] + (beta'[t])^2*l2*cos[beta[t]] + beta''[t]*l2*sin[beta[t]]};
lcond =
{(x1)^2[t] + (y1[t])^2 = l1^2,
(x2[t] - x1[t])^2 + (y2[t] - y1[t])^2 = l2^2};
begin =
{x1[0] == 2, y1[0] == 0, y1'[0] == 0, x2[0] == 2, y2[0] == 2, y2'[0] == 0};
jie =
NDSolve[
{equations, lcond, begin},
{x1[t], y1[t], x2[t], y2[t], alpha[t], beta[t]}, {t, 0, 15}]
NDSolve::deqn: Equation or list of equations expected instead of -3 sin[alpha[t]] (alpha^′)[t]^2+3 cos[alpha[t]] (alpha^′′)[t] in the first argument {{-3 sin[alpha[t]] (alpha^′)[t]^2+3 cos[alpha[t]] (alpha^′′)[t],3 cos[alpha[t]] (alpha^′)[t]^2+3 sin[alpha[t]] (alpha^′′)[t],-3 sin[alpha[t]] (alpha^′)[t]^2-2 sin[beta[t]] (beta^′)[t]^2+3 cos[alpha[t]] (alpha^′′)[t]+2 cos[beta[t]] (beta^′′)[t],3 cos[alpha[t]] (alpha^′)[t]^2+2 cos[beta[t]] (beta^′)[t]^2+3 sin[alpha[t]] (alpha^′′)[t]+2 sin[beta[t]] (beta^′′)[t]},{9,4},{(3 sin alpha[t])[0]==2,(-3 cos alpha[t])[0]==0,((-3 cos alpha[t])^′)[0]==0,(3 sin alpha[t]+2 sin beta[t])[0]==2,(-3 cos alpha[t]-2 cos beta[t])[0]==2,((-3 cos alpha[t]-2 cos beta[t])^′)[0]==0}}.**
Sin[...]
andCos[...]
etc for starters. Then equations are entered with theEqual
sign (==
, a double equal). The single equal corresponds to assignment. Once you make those changes, quit the kernel and restart it to clear all your mistaken definitions (e.g.Quit[]
orClearAll[“Global`*”]
. $\endgroup$ – MarcoB Jan 21 at 13:43deqn
comes up inNDSolve
orDSolve
. In addition to Marco's suggestion, you might need to doClear[Derivative]
. $\endgroup$ – Michael E2 Jan 21 at 14:35