I have to solve $[m]x''+[c]x'+[k]x=[p]$ where x is function of $t$ after defining $[m],[c],[k]$ and $[p]$ in mathematica and x[t_]={x1[t],x2[t],x3[t]}

I am using NDSolve as


but I am not getting its solution even I tried


can somebody help me to solve the initial equation?

  • 1
    $\begingroup$ You could take a look at 240947 for some hints on setting up a matrix differential equation. $\endgroup$
    – Tim Laska
    Jun 16, 2021 at 18:10
  • 2
    $\begingroup$ If 240947 does not answer your question, please edit your question to include the matrices in Mathematica format, so that readers can run your actual code. $\endgroup$
    – bbgodfrey
    Jun 16, 2021 at 18:37
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Jun 16, 2021 at 18:37

1 Answer 1


When dealing with matrix equations, I personally use Map[] to turn a matrix or a vector into a list of equations. Example below.

m = {{1, 2},{3, 4}};
c = {{5, 6},{7, 8}};
p = {1, 2};
x[t_] := {x1[t], x2[t]};

equation = m . x'[t] + c . x[t] - p;

    Map[# == 0 &, equation],
    Map[# == 0 &, x[0]]
  , x[t], {t, 0, 10}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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