s = DSolveValue[m*x''[t] + k*x[t] + b*x'[t] == 0, x[t], t]
s /. {m -> 1, b -> 6, k -> 9}

(* This gives me c1*exp(-3t)+c2*exp(-3t) which is wrong. Should be c1*exp(-3t)+c2*t*exp(-3t). The true result is given by *)

DSolveValue[x''[t] + 9*x[t] + 6*x'[t] == 0, x[t], t]

(* STRANGE! *)

  • 1
    $\begingroup$ You simply had bad luck. Mathematica tries to perform computations for generic values of m, b and k. Unfortunately, the discriminant Sqrt[b^2 - 4 k m] in the generic solution becomes 0 for you specified values. That tells me that some eigenvalue of your ODE has multiplicity 2 but the according matrix is not diagonalizable. In that case, the generic formula for solutions is no more valid. $\endgroup$ – Henrik Schumacher Apr 6 '18 at 19:27

User Henrik Schumacher has already given a good answer. I want to add a simple but important remark: the correct solution is returned under the substitution {m -> 1, b -> 6, k -> 9} if the latter is taken as a limit. You cannot perform the substitution directly because the roots of the characteristic polynomials become degenerate for your parameters, and therefore the solution is singular.

You can use the following:

s = DSolveValue[{m*x''[t] + k*x[t] + b*x'[t] == 0, x[0] == x0, x'[0] == v0}, x[t], t];
Limit[s /. {m -> 1, b -> 6}, k -> 9]

(* E^(-3 t) (x0 + t (v0 + 3 x0)) *)

which is the expected solution. Note that the substitution {m -> 1, b -> 6} can be performed without limits because the latter is non-singular. You can replace any two parameters directly (essentially, it's a choice of units, so nothing can diverge there), but not the third one.

| improve this answer | |

Your second order ODE is equivalent to solving the first order ODE system

A = {{-b/m, -k/m}, {1, 0}};
{u'[t], x'[t]} == A.{u[t], x[t]}

That can be solved by MatrixExp[A t].{C[1],C[2]}. However, when A is symbolic, Mathematica computes the matrix exponential by computing a symbolic eigensystem. In the generic case, Mathematica may assume that the eigenvalues are different from each other so that A is diagonalizable. In this case, the matrix exponential can be obtained by

{λ, U} = Eigensystem[A];
Transpose[U].(Exp[λ t] Inverse[Transpose[U]])

However, this breaks down when we insert your specific values:

Eigensystem[A /. {m -> 1, b -> 6, k -> 9}]

{{-3, -3}, {{-3, 1}, {0, 0}}}

The second returned "eigenvector" being {0,0} tells us that there is no second eigenvector and that A is not diagonalizable. In that case, one has to take care of a generalized eigenvector and one has to apply a Jordan decomposition. This is accurately done by Mathematica if you present the numerical values {m -> 1, b -> 6, k -> 9} before submitting the ODE to DSolve.

| improve this answer | |
  • 1
    $\begingroup$ To use the term of art: MatrixExp[] works differently if the matrix is defective, as opposed to when the matrix is diagonalizable. For instance: With[{m = 1, b = 6, k = 9}, {vm, jm} = JordanDecomposition[{{-b/m, -k/m}, {1, 0}}]]. $\endgroup$ – J. M.'s discontentment Apr 7 '18 at 20:21

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.