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

Given the differential equation,

$y'=|x|$, $y(-1)=2$

I believe I understand how to solve the implicit solution but have questions about using the initial condition to solve the explicit solution. I have outlined my solution below in case there is a mistake I have overseen.

I rewrite the differential equation piecewise and solve each piece independently.

$y'=x$ for $x\ge0$

$y'=-x$ for $x<0$

This yields,

$y_1=\frac{1}{2}x^2+c_1$ for $x\ge0$

$y_2=-\frac{1}{2}x^2+c_2$ for $x<0$

I use the initial condition to solve for $c_2$ and get,

$y_2=-\frac{1}{2}x^2+\frac{5}{2}$ for $x<0$

Does this mean that the solution is only $y_2$? I am thinking that if possible we want to find $c_1$ such that the solution is continuous and differentiable for the largest possible interval of definition. If $c_1=c_2$ then the piecewise solution is continuous and differentiable for all reals and satisfies the initial condition.

Thank you in advance for your time and assistance.

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

Those constants aren't independent (there's really only one). $|x|$ is continuous, so the derivative $y'$(and therefore $y$ itself) must also be continuous. So you really only have the one function, defined over all $\mathbb{R}$:

$$y=-\frac 1 2 x^2 + \frac 5 2, x<0$$ $$y=\frac 1 2 x^2 + \frac 5 2, x\geq 0$$

This passes through $(-1,2)$ and solves the equation, like you said. In general the interval on which the solution is defined is taken to be the largest possible such interval. In this case that's the entire real number line.

share|cite|improve this answer

This differential equation can be integrated directly. We must calculate $$y(x) = 2 + \int_{-1}^x dt\, |t|.$$ Note that we have built in the boundary condition $y(-1) = 2$.

If $x < 0$, $$\begin{eqnarray*} y(x) &=& 2 - \int_{-1}^x dt\, t \\ &=& -\frac{1}{2}x^2 + \frac{5}{2}, \end{eqnarray*}$$ otherwise $$\begin{eqnarray*} y(x) &=& 2 - \int_{-1}^0 dt\, t + \int_0^x dt\, t \\ &=& \frac{1}{2}x^2 + \frac{5}{2}. \end{eqnarray*}$$

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.