# On solving the differential equation $y''=y'+y+x$

Now at some point, you might have come across the differential equation$$y'=y+x$$which has the easily verifiable solution$$y(x)=ce^x-x-1$$however, I wanted to try solving$$y''=y'+y+x$$which while it would be more difficult, I thought that I might be able to solve it. Here is my attempt at doing so:

This differential equation looked like the general solution might be a sum of the complementary solution and the particular solution. To find the complementary solution, we need to solve$$y''-y'-y=0$$This is how this is done:

1. Assume that a solution will be proportional to $$e^{\lambda x}$$ for some $$\lambda$$. Substituting that in gets us$$\lambda^2e^{\lambda x}-\lambda e^{\lambda x}-e^{\lambda x}=0$$and dividing all terms by $$e^{\lambda x}$$ gets us$$\lambda^2-\lambda-1=0$$

Wait a second. This looks familiar. The solution to this quadratic is$$\lambda=\phi,\overline\phi$$where $$\overline\phi$$ represents the conjugate of the golden ratio $$\phi$$. So the complementary function is$$y(x)=c_1e^{\phi x}+c_2e^{\overline\phi x}$$Now to find the particular solution to the diff. eq., which is where I'm currently stuck, as I do not know how to do so. So my question is:

### How do I solve the diff. eq. $$y''=y'+y+x$$?

• Are you familiar with tutorial.math.lamar.edu/classes/de/…
– Moo
Commented Jan 10 at 15:26
• @Moo No not really Commented Jan 10 at 15:28
• Hint: Find the complementary solution of $y'' - y' - y = 0$ and then the particular solution using the guess for $y_p(x) = a + b x$. There are other approaches too.
– Moo
Commented Jan 10 at 15:30
• Assume there is some highest term $cx^2$ , then $y$ is linear & $y`$ is Constant , hence there is nothing to "balance" or "cancel" the $cx^2$ term. Similarly when we take higher Powers. Hence , we must have linear function $y=ax+b$ , which will then work out to $y=-x+1$ here !
– Prem
Commented Jan 10 at 15:32
• @Prem Oh my bad Commented Jan 11 at 14:56

Suppose $$f''(x)=f'(x)+f+x$$. The let $$g''(x)-g'(x)-g=0,$$ i.e. g is a solution to the corresponding homogenous equation..

We can often find a $$\lambda(x)$$ so that $$f=\lambda g$$

$$f=\lambda g$$

$$f'=\lambda ' g + \lambda g'$$

$$f''=\lambda'' g + 2\lambda' g' + \lambda g''$$

$$f''-f'-f=\lambda'' g + 2\lambda' g' + \lambda g'' - (\lambda ' g + \lambda g') - \lambda g=\lambda(g''-g'-g)+\lambda '(2g'-g)+\lambda''g=x$$

Now let $$u=\lambda '$$.

Then $$(2g'-g)u+u'g=x$$

$$g$$ is known and the new equation is first order in $$u$$. Thus the technique is called Reduction of Order.

This works for any solution for $$g$$ so you only need one of the two $$Ce^{kx}$$. So we can let $$g=Ce^{kx}$$

$$u'Ce^{kx}+u(2k-1)Ce^{kx}=x\implies u'+u(2k-1)=(x/C)e^{-kx}$$

Now you can introuce an integrating factor $$\mu(x)=e^{(2k-1)x}$$

$$\frac{d}{dx}(ue^{(2k-1)x})=(x/C)e^{(k-1)x}\implies u=e^{-(2k-1)x}\int (x/C) e^{(k-1)x}dx$$

$$\lambda = \int u dx$$ and $$f=\lambda g$$

This is more complicated than the method of Undetermined Coefficients.

$$y''=y'+y+x \implies y = g(x)+p(x)$$ where $$p(x)=ax+b$$.

We have $$p''=0$$ and $$0=p'+p+x=a+ax+b+x=(a+1)x+(a+b)$$. We let $$a=-1$$ and $$a+b=0\implies b=1$$

So $$y=c_1e^{\phi x}+c_2e^{\bar{\phi} x}-x+1$$

While simpler, Reduction of Order is more general and a variation can be used to simplify an equation. For example $$y''+(mx^2+b)y=0$$ can be reduced to an equation of the form $$ag''+bg'+cg=0$$ where $$a,b$$ and $$c$$ are linear functions of $$x$$ and $$y=\lambda(x) g(x)$$ and $$\lambda'' +mx^2\lambda =0$$. In other words, a function is determined with the same asymptotic behavior then the solution is expressed as a multiple of this function. This can simplify the equation and make other methods more convenient, like Taylor Series substitution by lowering the exponent of the first non-zero coefficient.

These methods can essentially be combined via The Method of Frobenius.

• According to my comments to OP , the Solution should involve $-x+1$ , which can be easily verified. This answer currently has $1-x$ which is clearly wrong. It should be rectified for correctness !
– Prem
Commented Jan 11 at 4:13
• A typo in my comment : According to my comments to OP , the Solution should involve $(−x+1)$ , which can be easily verified. This answer currently has $(+x-1)$ , which is negative of that. That is wrong & should be rectified for correctness !!
– Prem
Commented Jan 11 at 15:01
• Thanks. Fixed! Had Left out a term. Commented Jan 11 at 15:22

Hint: We can use Undetermined Coefficients.

Find the complementary solution, $$y_c(x)$$ of $$y'' - y' - y = 0$$.

Then, find the particular solution using the guess for $$y_p(x) = a + b x$$.

The solution will be $$y(x) = y_c(x) + y_p(x)$$

There are other approaches too (Variation of Parameters, Laplace Transform...).