numerical integration - NDSolve will try solving the system as differential-algebraic equations but it didn't get the solution
Please help me deal with this kind of question about ODEs. My codes are as follows
m = 100;
a = D[x[t], {t, 2}];
t1up = 2 x''[t] + 1/2 (490 + 34 x''[t] + 2 (490 + 50 x''[t]));
t1down = 490 + 53 x''[t];
t1 = Piecewise[{{t1up, x'[t] >= 0}, {t1down, x'[t] < 0}}]
equa00 = t1 == m*a
t0 = 50;
s1 = NDSolve[{equa00, x[0] == 1, x'[0] == 1}, x, {t, 0, 50}]
However, I get an error:
NDSolve::ntdvdae: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system as differential-algebraic equations. >>
So is it a differential-algebraic equation? How to solve it?
I have another question, too: How to plot the t1-t
figure after we get the s1
? I have tried the following codes:
t1upvalue = (t1up /. {x'[t] -> (x'[t] /. s1), x''[t] -> (x''[t] /. s1)})
t1downvalue = (t1down /. {x'[t] -> (x'[t] /. s1), x''[t] -> (x''[t] /. s1)})
t1value = Piecewise[{{t1upvalue, (x'[t] /. s1) >= 0}, {t1downvalue, (x'[t] /. s1) < 0}}],
Plot[t1value[[1]], {t, 0, t0},PlotRange -> All]
However it doesn't work.
Answer
Another solution is to use Simplify`PWToUnitStep
:
s1 = NDSolve[{equa00 // Simplify`PWToUnitStep, x[0] == 1, x'[0] == 1}, x, {t, 0, 50}]
Comments
Post a Comment