Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

I am stuck solving the diff-eq. $u''(x)+u(x) =|\cos(x)| $.

How do I find the general solution to this?

The homogeneous part is no problem, but how do I deal with the absolute value of the cosine?

share|cite|improve this question
up vote 4 down vote accepted

You can re-write it in the following form: $$u''(x)+u(x)=\left\{ \begin{array}{rc}\cos x& -\frac{\pi}{2}+2\pi k\leq x<\frac{\pi}{2}+2\pi k\\-\cos x& \frac{\pi}{2}+2\pi k\leq x<\frac{3\pi}{2}+2\pi k \end{array}\right.$$ And find the solution according to the segement.

share|cite|improve this answer
Shouldn't the OP combine the finial answers as one answer? – Babak S. Nov 1 '12 at 13:56
It depends on whether it is possible: the resulted function could be not-differentiable on the segment edges. – Dennis Gulko Nov 2 '12 at 9:55

You need to solve the following equation for particular solutions

$$ u''(x)+u(x) = \cos(x) \,\quad \cos(x)\geq 0 \,,$$


$$ u''(x)+u(x) = -\cos(x) \,\quad \cos(x)< 0 \,. $$

share|cite|improve this answer

$\newcommand{\+}{^{\dagger}} \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\down}{\downarrow} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\isdiv}{\,\left.\right\vert\,} \newcommand{\ket}[1]{\left\vert #1\right\rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert} \newcommand{\wt}[1]{\widetilde{#1}}$ $\ds{{\rm u}''\pars{x} + {\rm u}\pars{x} = \verts{\cos\pars{x}}:\ {\large ?}}$

Let $\ds{\xi\pars{x} \equiv {\rm u}'\pars{x} + \ic{\rm u}\pars{x}}$ such that $\ds{{\rm u}\pars{x} = \Im\xi\pars{x}}$ and

$\ds{{\rm u}''\pars{x} + {\rm u}\pars{x} = \xi'\pars{x} - \ic\xi\pars{x} =\verts{\cos\pars{x}}}$

Then, $$ \expo{-\ic x}\verts{\cos\pars{x}} =\expo{-\ic x}\xi'\pars{x} - \ic\expo{-\ic x}\xi\pars{x} =\totald{\bracks{\expo{-\ic x}\xi\pars{x}}}{x} $$

$$ \expo{-\ic x}\xi\pars{x}=\int\expo{-\ic x}\verts{\cos\pars{x}}\,\dd x + A \quad\mbox{where}\quad A\ \mbox{is a constant}\quad\mbox{and}\quad A \in {\mathbb C} $$

$$ \xi\pars{x}=\expo{\ic x}\int\expo{-\ic x}\verts{\cos\pars{x}}\,\dd x + A\expo{\ic x} $$

$$ {\rm u}\pars{x}= \Im\pars{\expo{\ic x}\int\expo{-\ic x}\verts{\cos\pars{x}}\,\dd x + A\expo{\ic x}} $$ The constant $\ds{A}$ is determined by the boundary conditions.

share|cite|improve this answer

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.