# Bizarre failure of integrating factor in elementary differential equation

I have an issue with an extremely elementary problem.

Consider the differential equation $y' + \cot(x) y = 1$. Obviously, one can use an integrating factor of $e^{\int \cot(x) dx} = e^{\ln(\sin(x)) }$ (the arbitrary constant would cancel out) $= \sin(x)$ to solve the differential equation, obtaining the correct answer $y = - \cot(x) + C \csc(x)$.

However, the assertion $\int \cot(x) dx = \ln(\sin(x)) +C$ is true only modulo subtle things involving branches of $\ln$ in the complex plane. Restricted to the real line, we use $\int \cot (x) dx = \ln |\sin(x)| +C$.

If we do the above method, we get an integrating factor not of $\sin(x)$ but of $|\sin(x)|$: $$|\sin(x)| y' + \cot(x) | \sin(x)| y = |\sin(x)|$$

Indeed, $\frac{d}{dx} |\sin(x)| = \cot(x) | \sin(x)|$, so this is a valid alternate choice of integrating factor.

Proceeding, we have $$\frac{d}{dx} ( |\sin(x)| y ) = |\sin(x)|$$ $$y = \frac{\int |\sin(x)| dx}{|\sin(x)|}$$

But this is not equal to the correct answer of $- \cot(x) + C \csc(x)$!

What is going on?

EDIT: It seems every calculus solution manual ever is wrong.

EDIT 2: Alternatively, it seems every introductory calculus textbook, including Stewart, gives the wrong definition of "general solution".

• The point is that the "correct answer" you gave isn't really the correct answer. For instance, the function $$y(x) = \begin{cases} -\cot(x)+3 \csc(x), & -\frac{\pi}{2} < x < \frac{\pi}{2} \\ -\cot(x) + 4 \csc(x), & \text{otherwise}\end{cases}$$ is a solution of the given equation, but it isn't of the form given in the "correct" answer. – Nate Eldredge Apr 21 '16 at 23:38
• Yes, thank you. I now realize what is happening. The "correct answer" is correct over $\mathbb{C}$, but not over $\mathbb{R}$. It is too bad that students of introductory calculus are being taught completely wrong, as I was. Any solution manual would give the wrong answer. – vhspdfg Apr 21 '16 at 23:43
• Alternatively, the "correct" answer is correct over $(-\pi/2, \pi/2)$. For instance, if we were given an initial value $y(0)=y_0$, the solution would be uniquely determined over that interval, but not beyond. But that's probably what you would want for a real-life application - you know your physical system is going to explode at time $\pi/2$, so what's the point in asking what happens after that? This is pretty common - you only care about what happens up until the next singularity, and the given answer is consistent with that. – Nate Eldredge Apr 21 '16 at 23:46
• Yes, the incorrect general solution would still suffice for any initial value problem if we restrict the domain, but only if. – vhspdfg Apr 21 '16 at 23:49
• Oh, I think all my $x$ values above are off by $\pi/2$ or so, I mixed up tangent and cotangent. But you get the idea. I guess what I am saying is that in applications, you would always restrict the domain, and the author of the book may have a (stated or unstated) standing assumption that this is what will be done. So I'm not really bothered by it as much as you are - "completely wrong" seems a little harsh to me. – Nate Eldredge Apr 21 '16 at 23:50

On any interval between multiples of $\pi$, $\dfrac{\int |\sin(x)|\; dx}{|\sin(x)|}$ is indeed of the form $-\cot(x) + C \csc(x)$ for some constant $C$. The "constant" changes from interval to interval. However, the differential equation is singular at multiples of $\pi$, so there is no reason why the constants should be the same.
• This is what I was thinking, but there is the issue of the constant changing from interval to interval. I see how the result is a solution, but then the solution $y = -\cot(x) + C \csc(x)$ is not the general solution! The constant can change interval to interval! But wolframalpha and any solution manual would say $y = -\cot(x) + C \csc(x)$ is the general solution. – vhspdfg Apr 21 '16 at 23:24
• But this still doesn't make sense, as if we use $\sin(x)$ as an integrating factor, we get only one degree of freedom in the general solution, and thus the wrong answer (if we're working over $\mathbb{R}$). Please explain that discrepancy. – vhspdfg Apr 21 '16 at 23:27
• Is the resolution that, if, after the fact, the ostensible solution $y$ has vertical asymptotes, the constant can change in each region? It seems so. But then students are being taught completely wrong! Every introductory calculus book and solution manual are wrong! Wow. – vhspdfg Apr 21 '16 at 23:37
• In the complex numbers, the singularities at multiples of $\pi$ are not barriers to analytic continuation: you can go around them! $-\cot(x) + C \csc(x)$ is indeed the general solution in that context. But in the real numbers, there is no connection between what happens in $(0, \pi)$ and what happens in $(\pi,2\pi)$, and you are free to mix and match solutions. – Robert Israel Apr 21 '16 at 23:38