Salt in a container - ODE problem We work with a water container that can hold up to 1000 liters. The water container initially contains 500 liters of water, in which 20 kg of salt has been dissolved. There is agitation in the container, so the salt concentration is the same everywhere.
Clean water flows into the container at a speed of 4L / min. At the same time, saltwater flows out of the container at a speed of 2L / min. This causes problems as the container is only at 1000L. After a while, an alarm sounds due to a filled container.
(a) At what time does the alarm sound?
The differential equation that describes this problem is given by
$$y'=-\frac{2}{500+2t}\cdot y$$
It is stated that the salt content is 10kg when the alarm rings, i.e. $y(250)=10$. Just as the alarm sounds, the inflow changes so that salt water now flows with 35g of salt per. liters in at the rate of 1L / min. There is still 2L flowing out per. minute.
(b) How much salt is in the container when there is again 500L in the container?

My answer: Well (a) was quite easy, I obtained that the alarm will sound after 250 minutes since $500+2\cdot 250=1000$ and then the alarm will ring. But the last part, i.e. (b) is not easy for me. I believe that I have to make an ODE from the information I just got, but here I tried many times. Notice that this problem came from a book where there was more question, I just picked the relevant part. (b) is also stated as "voluntary" in the book. Notice this is not a homework problem.
 A: For part (b),
you have $1000$ liter of water to start with which has $10$ kg of salt.
The volume of water is reducing at the rate of 1 liter / min (1 liter flowing in and 2 liter flowing out every minute). It will take $500$ minute to reduce from $1000$ liter to $500$ liter.
So volume of water left in the tank after time $t$ mins $= 1000 - t$
Salt is flowing in at the rate of $0.035$ kg / min.
Say there is $y$ kg of salt at a given time $t$ in $1000-t$ liter of water.
Then at time $t$, salt is flowing out at the rate of $\frac{y}{1000-t} \times 2$ (as $2$ liter per minute flowing out)
So rate of change of salt $\frac{dy}{dt} = 0.035 - \frac{2y}{1000-t}$
Let's say $x = 1000 - t$ then with substitution,
$- \frac{dy}{dx} = 0.035 - \frac{2y}{x}$
$\frac{dy}{dx} = \frac{2y}{x} - 0.035$ ...(i)
Now to solve this linear equation, we have to use integrating factor. I used WolframAlpha to verify.
$\mu = e^{\int{-2/x \, dx}} = \frac{1}{x^2}$
Multiplying both sides by $\mu$ in (i),
$\frac{1}{x^2} \frac{dy}{dx} - \frac{2y}{x^3} = - \frac{0.035}{x^2} $
$\frac{1}{x^2} \frac{dy}{dx} + \frac{d}{dx}(\frac{1}{x^2})y = - \frac{0.035}{x^2} $
$\int d(\frac{y}{x^2}) = - \int \frac{0.035}{x^2}dx $
$\int d(\frac{y}{x^2}) = - \int \frac{0.035}{x^2}dx $
$y = 0.035x + cx^2$
Substituting back $x = 1000 - t$
$y = 35 - 0.035t + c(1000-t)^2$
At $t = 0$, there is $10$ kg of salt.
$10 = 35 + c \times 1000^2$
So, constant $c = -\frac{25}{1000^2}$
At $t = 500$,
Total salt $y = 35 - 0.035 \times 500 - \frac{25}{1000^2} \times 500^2 = 11.25$ kg.
