Problem of first order differential equation.

Let $y$ be the solution of

$$y'+y=|x|, x \in \mathbb R , y(-1)=0$$

Then $y(1)$ is equal to

1) $\frac{2}{e}-\frac{2}{e^2}$

2) $\frac{2}{e}- {2}e^2$

3) $2-\frac{2}{e^2}$

4) $2-2e$

Now i solve it by method $\frac{dy}{dx}+Py=Q$ by finding Integrating factor

$e^x$ and then solution is given by $ye^x=\int e^x|x|dx$+c

Now further since x is in $\mathbb R$ so i make two separate cases one when $x\gt 0$ and other for $x\lt 0$, but the problem is now for $x\gt 0$ i am unable to find out the constant value. Is this correct way to deal this problem?

• You can make your life easier by using a definite integral to write down the value of the solution at 1. You can then split this definite integral as required. – Ian Mar 10 '16 at 3:31
• Which constant value? Since $y(-1)=0$, one has, for every $x$, $$e^xy(x)=\int_{-1}^x|t|\,e^t\,dt.$$ In particular, $$ey(1)=\int_{-1}^1|t|\,e^t\,dt=\int_0^1t\,(e^t+e^{-t})\,dt=\ldots$$ – Did Mar 10 '16 at 7:04
• Thanks. This thing i don't know but now i got it. – kapil Mar 10 '16 at 9:45

$$y'(x)+y(x)=|x|\Longleftrightarrow$$

Let $r(x)=\exp\left[\int1\space\text{d}x\right]=e^x$.

Multiply both sides by $r(x)$:

$$e^xy'(x)+e^xy(x)=e^x|x|\Longleftrightarrow$$

Substitute $e^x=\frac{\text{d}}{\text{d}x}\left(e^x\right)$:

$$e^xy'(x)+\frac{\text{d}}{\text{d}x}\left(e^x\right)\cdot y(x)=e^x|x|\Longleftrightarrow$$

Apply the reverse product rule to the left-hand side:

$$\frac{\text{d}}{\text{d}x}\left(e^xy(x)\right)=e^x|x|\Longleftrightarrow$$ $$\int\frac{\text{d}}{\text{d}x}\left(e^xy(x)\right)\space\text{d}x=\int e^x|x|\space\text{d}x\Longleftrightarrow$$ $$e^xy(x)=\int e^x|x|\space\text{d}x\Longleftrightarrow$$

When $x\in\mathbb{R}$:

$$e^xy(x)=\left(e^x(x-1)+1\right)\text{sgn}(x)+1+\text{C}\Longleftrightarrow$$ $$y(x)=\frac{\left(e^x(x-1)+1\right)\text{sgn}(x)+1+\text{C}}{e^x}$$

Now, when $y(-1)=0$, we can solve $\text{C}$:

$$0=\frac{\left(e^{-1}((-1)-1)+1\right)\text{sgn}(-1)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$ $$0=\frac{\left(e^{-1}(-2)+1\right)\left(-1\right)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$ $$0=\frac{\left(1-\frac{2}{e}\right)\left(-1\right)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$ $$0=\frac{\frac{2}{e}+\text{C}}{e^{-1}}\Longleftrightarrow$$ $$0=2+e\text{C}\Longleftrightarrow$$ $$-2=e\text{C}\Longleftrightarrow$$ $$\text{C}=-\frac{2}{e}$$

So:

$$y(x)=\frac{\left(e^x(x-1)+1\right)\text{sgn}(x)+1-\frac{2}{e}}{e^x}$$

And now we can find $y(1)$:

$$y(1)=\frac{\left(e^1(1-1)+1\right)\text{sgn}(1)+1-\frac{2}{e}}{e}=\frac{1+1-\frac{2}{e}}{e}=\frac{1+1-\frac{2}{e}}{e}=\frac{2-\frac{2}{e}}{e}$$