Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Following the fundamental theorem of algebra, I can (as stated here in Sec. 1.1.4) factor an $n$th-order linear ordinary differential equation $$ a_n \frac{d^n x}{dt^n} + a_{n-1} \frac{d^{n-1} x}{dt^{n-1}} +\cdots+a_1 \frac{dx}{dt}+a_0 = 0 $$ into $$ a_n \left( \frac{d}{dt} - r_1 \right) \left( \frac{d}{dt} - r_2 \right) \cdots \left( \frac{d}{dt} - r_n \right) x = 0 . $$

The Mathematica representation of the former is trivial, and I would represent the latter as

difOp[t, r] = (Dt[#, {t}] - r) &
an difOp[t, r1][ difOp[t, r2][x[t]] ] == 0

Is there any way to get the Mathematica kernel to connect the two, e.g. to compute the second from the first?

share|improve this question
If you just want to get $r_1, r_2,\cdots,r_n$ you can simply Solve $ a_n x^n + a_{n-1} x^{n-1} +\cdots+a_1 x+a_0 = 0 $. – xzczd Jul 18 '14 at 7:02
up vote 5 down vote accepted

The differential operator in the first form can be written as

dd1[n_] := (Sum[a[k] D[#, {t, k}], {k, 0, n}]) &

and is applied for example as


a[0] x[t] + a[1] Derivative[1][x][t]


dd1[2] @x[t]

a[0] x[t] + a[1] Derivative[1][x][t] + a[2] (x^\[Prime]\[Prime])[t]

In the second (product) form we would perhaps try

d2[n_] := a[n] Expand[Product[D[#, t] - r[k], {k, 0, n}]] & 

But application leads to


a[2] (-r[0] r[1] r[2] + r[0] r[1] Derivative[1][x][t] + 
   r[0] r[2] Derivative[1][x][t] + r[1] r[2] Derivative[1][x][t] - 
   r[0] Derivative[1][x][t]^2 - r[1] Derivative[1][x][t]^2 - 
   r[2] Derivative[1][x][t]^2 + Derivative[1][x][t]^3)

which is not the result we want.

So let us proceed step by step.

First we refrain from using D[] immediately but replace it by the symbol d:

d2[n_] := a[n] Expand[Product[d - r[k], {k, 0, n}]]


a[1] (d^2 - d r[0] - d r[1] + r[0] r[1])

Ok. Now in this expression we replace d^m by D[#,[t,m}] for m=1, 2, ..., n which gives us

dd2[n_] := a[n]*Expand[Product[d - r[k], {k, 1, n}]] /. 
         d^(m_) -> D[#1, {t, m}] /. d -> D[#1, {t, 1}] & 

Notice that we need to replace the the first power of d separately because it does not match te pattern d^m_.

Applying it


a[2] (r[1] r[2] - r[1] Derivative[1][x][t] - 
   r[2] Derivative[1][x][t] + (x^\[Prime]\[Prime])[t])

shows that it is correct.

Now the quantities r[i] are of course the roots of the equation

eq[n_] := 0 == Sum[a[k] r^k, {k, 0, n}]


0 == a[0] + r a[1]


0 == a[0] + r a[1] + r^2 a[2]

These can be written explicitly thus

r[n_, k_] := Root[Sum[a[j] #1^j , {j, 0, n}] &, k]

r[5, 2]

Root[a[0] + a[1] #1 + a[2] #1^2 + a[3] #1^3 + a[4] #1^4 + a[5] #1^5 &, 2]

Summarizing, we have provided all contructs requested in the question.

Regards, Wolfgang

share|improve this answer
I had thought about something like this, as an FDTD book I've got does it. Is there a name in mathematics for this type of operation, converting a differential operator to a symbol and back? I know the FDTD book references a paper in connection with this; it appears there in an analytic context (computing a vector calculus identity). Thank you. – timdewolf Jul 19 '14 at 23:49
@timedewolf: Sorry for replying so late. I was on vacation. My answer to your question is: not that I'm aware of. I just used this bidirectional replacement in the context of this specific Problem. – Dr. Wolfgang Hintze Aug 10 '14 at 20:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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