0
$\begingroup$

I'm trying to create an ODE for motion in 2 dimensions. What I have so far is:

x0 = {1.5, -4.}; 
v = {0, 8}; 
DSolve[{x'[t] == v, x[0] == x0}, x[t], t]

This works with one dimension, but when I try and expand the idea for a vector/matrix, I get:

DSolve::nolist: List encountered within {(x^\[Prime])[t]=={0,8}}. There should be no lists on either side of the equations.

How do I fix this?

$\endgroup$
  • $\begingroup$ NDSolve works without problems: NDSolve[{x'[t] == {0, 8}, x[0] == {1.5, -4.}}, x , {t, 0, 1}] $\endgroup$ – Ulrich Neumann Dec 22 '19 at 15:56
  • $\begingroup$ Yeah, I haven't quite figured out why NDSolve is smart enough to deal with a list, but DSolve can't. $\endgroup$ – Quarkly Dec 22 '19 at 16:01
  • $\begingroup$ Nor am I , mysterious! $\endgroup$ – Ulrich Neumann Dec 22 '19 at 16:06
4
$\begingroup$

MMa doesn't know x[t] is a vector, so try this.

x0 = {1.5, -4.};
v = {0, 8};
x[t_] = {x1[t], x2[t]}

eq = x'[t] == v // Thread
(*{x1'[t] == 0, x2'[t] == 8}*)

init = x[0] == x0 // Thread
(*{x1[0] == 1.5, x2[0] == -4.}*)

DSolve[{eq, init}, x[t], t]
(*{{x1[t] -> 1.5, x2[t] -> 8 t - 4.}}*)

x[t] /. %
(*{{1.5, 8 t - 4.}}*)
|improve this answer|||||
$\endgroup$
  • $\begingroup$ This doesn't work. The velocity equation resolves to ${Derivative[1][x][t] == 0, Derivative[1][x][t] == 8}$ and thus DSolve doesn't have enough dependent variables to solve. $\endgroup$ – Quarkly Dec 22 '19 at 0:42
  • $\begingroup$ The threading doesn't do what your comments suggest they should do. $\endgroup$ – Quarkly Dec 22 '19 at 0:54
  • $\begingroup$ Corrected. I had mistakenly commented out the x[t] equation. Now changed the init to x0. Should work for you. $\endgroup$ – Bill Watts Dec 22 '19 at 0:58
  • 1
    $\begingroup$ You must not have the x array assigned. $\endgroup$ – Bill Watts Dec 22 '19 at 2:31
  • 1
    $\begingroup$ @Quarkly it worked for me $\endgroup$ – b3m2a1 Dec 22 '19 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.