# Second order linear ODE with nonconstant coefficients: Why can we not use the ansatz $e^{\lambda x}$?

For a constant-coefficient case, it is guaranteed that the solutions we get from taking $$e^{\lambda x}$$ to be the ansatz and finding out the value of $$\lambda$$ are valid. Generally, for a homogeneous equation

$$ay''+by'+cy=0$$

it is equivalent to taking the linear differential operator as $$\mathcal{L}=aD^2 + bD + c$$ where $$D = d/dx$$, and saying that

$$\mathcal{L}y=0$$

So I would say that $$e^{\lambda x}$$ is a basis for the eigenspace of $$\mathcal{L}$$ which corresponds to the eigenvalue of $$\Lambda=a\lambda^2 + b\lambda +c$$

henceforth making the equation $$\mathcal{L}y=\Lambda y$$.

However, this method does not work for a nonconstant-coefficient case. But I don't see why it doesn't work. Instead of talking about general cases, I will use a specific example from now on. Consider the equation

$$y''+xy'+y=0$$

I found that it is entirely valid up to carrying out the characteristic equation.

$$\lambda^2 e^{\lambda x} + x \lambda e^{\lambda x} + e^{\lambda x}=0$$

$$(\lambda^2+x\lambda+1)e^{\lambda x}=0$$

Since $$e^{\lambda x}>0$$, $$\lambda^2+x\lambda+1 = 0$$

Then we can find $$\lambda$$ using the quadratic formula (admitting that $$\lambda$$ is a function of $$x$$):

$$\lambda_1(x) = \frac{-x + \sqrt{x^2-4}}{2},\ \lambda_2(x) = \frac{-x - \sqrt{x^2-4}}{2}$$

Since the equation is linear, we can guarantee that the span of $$\{e^{\lambda_1 x}, e^{\lambda_2 x}\}$$ is a solution. Thus,

$$y(x) = e^{-x/2} \times [Ae^{+\frac{\sqrt{x^2-4}}{2}x} + Be^{-\frac{\sqrt{x^2-4}}{2}x}]$$

Except for the fact that the eigenvalue $$\lambda$$ is a function of $$x$$ there is nothing peculiar about it. I thought it is fine, because what we are taking as "vectors" is the solution function $$y$$, not the independent variable $$x$$ underlying at the back of this function.

It doesn't work in your example because when you differentiated $$e^{\lambda x}$$ to obtain the characteristic equation $$\lambda^2+x\lambda+1 = 0$$, you implicitly assumed that $$\lambda$$ is a constant. However, if $$\lambda$$ is a function of $$x$$, then $$(e^{\lambda x})'=(\lambda'x+\lambda)e^{\lambda x}\neq \lambda e^{\lambda x}.$$

You can use the ansatz $$e^{\lambda x}$$, but in order to determine $$\lambda$$ you have to solve a differential equation, not an algebraic one.

• Specifically if you assume $y=e^{f(x)}$ then $y'=e^f f',y''=e^f(f'^2+f'')$ so the equation in the question becomes $f''+f'^2+xf'+1=0$. OP is assuming $f'=\lambda$ so that $f''=0$ but this cannot be right in this context.
– Ian
May 8, 2021 at 2:32
• That ode is more complicated than the original one @Ian May 8, 2021 at 2:55
• @Aryadeva Yup. But that is what you get out of the ansatz.
– Ian
May 8, 2021 at 13:44

$$\lambda^2 e^{\lambda x} + x \lambda e^{\lambda x} + e^{\lambda x}=0$$ This must be true for all $$x \in \mathbb{R}$$: $$\lambda^2+x\lambda+1 = 0$$ For $$x=0 \implies \lambda=\pm i$$

For $$x=1 \implies \lambda^2+\lambda +1=0$$

So it dosen't work since your solution depends on the variable $$x$$. The DE is easy to integrate: $$y''+xy'+y=0$$ $$y''+(xy)'=0$$ Reduce the order by integation. $$y'+xy=C_1$$ It's a first ODE you can easily solve.