The right way to solve y' + y = x (with y(0) = 4) ?

saadjumani

New member
Joined
Mar 30, 2019
Messages
2
Hi, everyone. I had a test today and one of the questions was to solve the following equation:

y' + y = x
initial value was given as y(0) = 4.
I am newbie at differential equations and was not really that prepared for the test. So I just solved it the following way:

re-write the equation as:

dy/dx = x - y

=> dy = xdx - ydx

=> ∫ dy = ∫xdx - y∫dx

after integrating

=> y = (x^2)/2 - xy + c

then I proceeded to substituting the values y(0)=4. to find the value of C.

During discussion with a couple of my class mates, they said this approach to solution is wrong but I couldn't exactly understand why.
Can anyone explain whether it is really wrong. and if yes, why?
 
Hi, everyone. I had a test today and one of the questions was to solve the following equation:

y' + y = x
initial value was given as y(0) = 4.
I am newbie at differential equations and was not really that prepared for the test. So I just solved it the following way:

re-write the equation as:

dy/dx = x - y

=> dy = xdx - ydx

=> ∫ dy = ∫xdx - y∫dx

after integrating

=> y = (x^2)/2 - xy + c

then I proceeded to substituting the values y(0)=4. to find the value of C.

During discussion with a couple of my class mates, they said this approach to solution is wrong but I couldn't exactly understand why.
Can anyone explain whether it is really wrong. and if yes, why?
Did you check whether the equation you derived satisfies the given DE?

After that we can discuss the validity of your approach.
 
Did you check whether the equation you derived satisfies the given DE?

After that we can discuss the validity of your approach.

Thanks for your response. If im not wrong, in order to verify a differential equation's solution you differentiate the answer and see if the resulting solution forms the original equation, right? doing that:

dy/dx = dy/dx((x^2)/2 - xy + c)

gives dy/dx = x-y which is the original equation.

Or is there any other way to verify the solutions?

On a side note, if you haven't guessed it already, im having a hard time transitioning from calculus to differential equations. Basically I don't have much problem integrating or differentiating individual expressions, but treating differentials/integrals as a part of larger equation is getting really confusing for me. So can you recommend some resources that would make this transition from calculus to differential equations any easier?
 
Thanks for your response. If im not wrong, in order to verify a differential equation's solution you differentiate the answer and see if the resulting solution forms the original equation, right? doing that:

dy/dx = dy/dx((x^2)/2 - xy + c)

gives dy/dx = x-y which is the original equation.

Or is there any other way to verify the solutions?

On a side note, if you haven't guessed it already, im having a hard time transitioning from calculus to differential equations. Basically I don't have much problem integrating or differentiating individual expressions, but treating differentials/integrals as a part of larger equation is getting really confusing for me. So can you recommend some resources that would make this transition from calculus to differential equations any easier?
d/dx[x*y] needs to use product rule of differentiation.

d/dx[x*y] = x * d/dx[y] + y * d/dx[x] = x * y' + y

Reviewing this, go back to your original attempt and see if you can locate the "mistake" you made.
 
You may be a newbie at differential equations but you should know Calculus! And you should know that \(\displaystyle \int y dx\), when y is a function of x, is NOT "\(\displaystyle y\int dx= yx\)".

There are many different ways to solve a differential equation like this. The simplest is to first ignore the "x" on the right side. The equation y'+ y= 0 can be written as \(\displaystyle \frac{dy}{dx}= -y\) so that \(\displaystyle \frac{dy}{y}= -dx\). Notice that now there is no "x" on the left side and no "y" on the right. We have separated the variables and can now integrate both sides: \(\displaystyle ln(y)= -x+ C\) so, taking the exponential of both sides, \(\displaystyle y= e^{-x+ C}= e^{C}e^{-x}= C'e^{-x}\) where C' is \(\displaystyle e^{C}\).

Now use the fact that this is a linear equation so we can add a single solution to the entire equation to that to find the general solution to the entire equation. I know that the derivative of a polynomial is again a polynomial so seeing that "x" on the right side of y'+ y= x, I would look for a solution of the form y= Ax+ B for some constants, A and B. Then y'= A so y'+ y= A+ Ax+ B= Ax+ (A+ B)= x. The equation Ax+ (A+ B)= x must be true for all values of x so we must have A= 1 and A+ B= 0. A+ B= 1+ B= 0 so B= -1. Ax+ B= x- 1.

So the general solution to y'+ y= x is \(\displaystyle y(x0= C'e^{-x}+ x- 1\). That's easy to check: \(\displaystyle y'= -C'e^{-x}+ 1\) so \(\displaystyle y'+ y= -C'e^{-x}+ 1+ C'e^{-x}+ x- 1= x\).

All that is left is to determine C' so that y(0)= 4. \(\displaystyle y(0)= C'e^0+ 0- 1= C'- 1= 4\) so C'= 5. The solution to this problem is \(\displaystyle y(x)= 5e^{-x}+ x- 1\).
 
Last edited:
You were probably expected to compute an integrating factor.

Consider an ODE of the form:

[MATH]\d{y}{x}+P(x)y=Q(x)[/MATH]
Now, if we define an "integrating factor" as follows:

[MATH]\mu(x)=\exp\left(\int P(x)\,dx\right)[/MATH]
Then it follows that:

[MATH]\d{\mu}{x}=P(x)\mu(x)[/MATH]
And so, multiplying through the ODE by this factor, there results:

[MATH]\mu(x)\d{y}{x}+P(x)\mu(x)y=\mu(x)Q(x)[/MATH]
And we may then write:

[MATH]\mu(x)\d{y}{x}+\d{\mu}{x}y=\mu(x)Q(x)[/MATH]
At this point we should observe that:

[MATH]\frac{d}{dx}\left(\mu(x)\cdot y\right)=\mu(x)\d{y}{x}+\d{\mu}{x}y[/MATH]
And so the ODE may be written:

[MATH]\frac{d}{dx}\left(\mu(x)\cdot y\right)=\mu(x)Q(x)[/MATH]
Now we may integrate w.r.t \(x\) to obtain:

[MATH]\mu(x)\cdot y=\int \mu(x)Q(x)\,dx[/MATH]
Thus:

[MATH]y(x)=\frac{1}{\mu(x)}\int \mu(x)Q(x)\,dx[/MATH]
 
Given the IVP:

[MATH]y+y'=x[/MATH] where \(y(0)=4\)

I would first compute the integrating factor:

[MATH]\mu(x)=\exp\left(\int\,dx\right)=e^x[/MATH]
And the ODE becomes:

[MATH]e^xy+e^xy'=xe^x[/MATH]
Or:

[MATH]\frac{d}{dx}\left(e^xy\right)=xe^x[/MATH]
Integrate:

[MATH]e^xy=(x-1)e^x+c_1[/MATH]
Dividing through by \(e^x\) gives the one-parameter general solution to the ODE:

[MATH]y(x)=x-1+c_1e^{-x}[/MATH]
Now, use the initial values to determine the parameter \(c_1\):

[MATH]y(0)=-1+c_1=4\implies c_1=5[/MATH]
And so the solution to the IVP is:

[MATH]y(x)=x-1+5e^{-x}[/MATH]
Another way to solve would be to observe that the homogeneous solution is:

[MATH]y_h(x)=c_1e^{-x}[/MATH]
And the particular solution must take the form:

[MATH]y_p(x)=Ax+B\implies y_p'(x)=A[/MATH]
Substituting into the ODE (i.e. using the method of undetermined coefficients) we get:

[MATH]A+Ax+B=x[/MATH]
Or:

[MATH]Ax+(A+B)=1x+0[/MATH]
Equating like coefficients, we find:

[MATH]A=1[/MATH]
[MATH]A+B=0\implies B=-1[/MATH]
And so the particular solution is:

[MATH]y_p(x)=x-1[/MATH]
Thus, the general solution to the ODE is:

[MATH]y(x)=y_h(x)+y_p(x)=c_1e^{-x}+x-1[/MATH]
And as before, we would use the initial values to determine the value of the parameter. :)
 
Top