# How to define a differential operator?

I have a linear differential operator, for instance, $L\left (\partial _{t} \right )=\partial _{tt} - 3\partial _{t} + 2$. I use it in 2 different ways:

• apply the operator to a function: $L\left (\partial _{t} \right )\sin(t)=-\sin(t)-3\cos(t)+2\sin(t)=\sin(t)-3\cos(t)$

• find roots of the polynomial $L(p)=0$, in this case $p=1,p=2$

What is the best way to define such operator?

-
You should include in your question your attempts to define such an operator. What have you tried ? In any case take a look at this post where a dalambertian was defined : mathematica.stackexchange.com/questions/5434/…. Perhaps you know there are in Mathematica 9 new differential operators like Div, Curl, Laplacian etc. – Artes Dec 3 '12 at 11:59
I am new to Mathematica, so my only guess was to create 2 distinct functions, one behaving like differential operator, other like a polynomial. I was wondering if there was a way to write it in 1 statement. – prazuber Dec 3 '12 at 14:44
The section "Some noncommutative algebraic manipulation" in the notebook at this link might be useful for some of what you are trying to do. (probably not much help with factoring differential operators though). – Daniel Lichtblau Dec 3 '12 at 16:05
A closely related question is Having the derivative be an operator – Jens Dec 3 '12 at 18:17

Define the operator as

op[t_]=(D[#,{t,2}]-3D[#,t]+2#)&


Then you get

op[t][Sin[t]]

(* -3 Cos[t]+Sin[t] *)


and also

op[t][Exp[p t]]/Exp[p t]//Factor

(* (-2+p) (-1+p) *)


where I have used that $\partial_t \exp(p t) = p\exp(p t)$ to "convert" the action of the operator $\partial_t$ into multiplication by $p$, and then I tidy up by dividing out the $\exp(p t)$ afterwards.

-
Thanks! Shame that it's a bit more complicated than I thought to get the roots of a polynomial, but that will work. – prazuber Dec 3 '12 at 14:46
Try this: op[x, t][Exp[p t] Exp[q x]]/(Exp[p t] Exp[q x]) // Factor. The comment this addresses has disappeared. It was to do with how to handle the case where the operator depended on both t and x. – Stephen Luttrell Dec 3 '12 at 15:10
Oh, I deleted it because I came up with a solution op[x,t][Exp[x t]]/Exp[x t], where I've actually gotten my polynomial, though with the variables that switched places. But your solution is much more generic, thanks again! – prazuber Dec 3 '12 at 15:17
Re: your previous comment on getting the roots of a polynomial, Factor alone does that for you. The Exp trick/hack was for converting your particular operator-valued problem into an algebraic one, which Factor could then get to work on. – Stephen Luttrell Dec 3 '12 at 15:25

The following slides are from a I talk I gave on implementing polynomial differential operators and teaching with them: http://www.cs.hmc.edu/~is/talks/JMM2011.nb

-
Please consider adding some more information to your answer itself, should for example the .nb file become unavailable. Answers that are merely single links to an external resource are discouraged, no matter how good that resource may be. – Mr.Wizard Dec 4 '12 at 13:38