# Find f ?

## $f ' ' \left(x\right) + f \left(x\right) = 1$ , $x$$\in$$\mathbb{R}$

Apr 19, 2018

$f \left(x\right) = 1 + A \cos x + B \sin x$

#### Explanation:

The quickest way of solving this equation is to note that the function

$g \left(x\right) = f \left(x\right) - 1$

satisfies

g''(x) = f" (x) = 1-f(x) = -g(x)

or

$g ' ' \left(x\right) + g \left(x\right) = 0$

This is a familiar equation with the well known solution

$g \left(x\right) = A \cos x + B \sin x$

where $A$ and $B$ are arbitrary real constants.

Apr 19, 2018

$f \left(x\right) = 1 + C \cos \left(x + \phi\right)$

#### Explanation:

If you want a quick solution, see https://socratic.org/s/aQcKQPv8

I will describe a more detailed solution here. This involves much more work, but has the advantage of being a much more general method. It is also a simple introduction to the factorization method for solving differential equations.

Let us denote the operator $\frac{d}{\mathrm{dx}}$ by $D$. Then the equation is

$\left({D}^{2} + 1\right) f \left(x\right) = 1$

We can write

${D}^{2} + 1 = \left(D + i\right) \left(D - i\right)$

where the use of the familiar formula ${a}^{2} - {b}^{2} = \left(a - b\right) \left(a + b\right)$ is legitimate because $D$ commutes with $i$. So, our equation is

$\left(D + i\right) \left(D - i\right) f \left(x\right) = 1$

Denoting $\left(D - i\right) f \left(x\right)$ by $g \left(x\right)$ we see that $g \left(x\right)$ obeys the simple first order linear equation :

$\left(D + i\right) g \left(x\right) = 1 q \quad \text{i.e.} q \quad \frac{\mathrm{dg}}{\mathrm{dx}} + i g = 1$

This is easily solved by introducing the integrating factor ${e}^{i x}$

${e}^{i x} \frac{\mathrm{dg}}{\mathrm{dx}} + i {e}^{i x} g = {e}^{i x} \implies$

$\frac{d}{\mathrm{dx}} \left({e}^{i x} g\right) = {e}^{i x} \implies$

${e}^{i x} g \left(x\right) = \frac{1}{i} {e}^{i x} + A$
where $A$ is a constant of integration. So

$g \left(x\right) = - i + A {e}^{- i x}$

But $g \left(x\right) = \left(D - i\right) f \left(x\right)$, which means that $f \left(x\right)$ obeys the first order linear differential equation

$\frac{\mathrm{df}}{\mathrm{dx}} - i f = - i + A {e}^{- i x}$

This equation has an integrating factor ${e}^{- i x}$, which allows us to write

$\frac{d}{\mathrm{dx}} \left(f {e}^{- i x}\right) = \left(- i + A {e}^{- i x}\right) {e}^{- i x} = - i {e}^{- i x} + A {e}^{- i 2 x}$

This is easily integrated to

$f {e}^{- i x} = {e}^{- i x} + \frac{A}{- 2 i} {e}^{- i 2 x} + B$

$f \left(x\right) = 1 + {A}^{'} {e}^{- i x} + B {e}^{i x}$
This is the required solution, but we have one more step to go. The solution has to be real, and so must be equal to its complex conjugate. It is easy to see that this means that ${A}^{'} = {B}^{\text{*}}$. Introducing two real constant constant $C$ and $\phi$ by
$B = \frac{C}{2} {e}^{i \phi}$
$f \left(x\right) = 1 + C \cos \left(x + \phi\right)$