Your second equation is not as you write in the question, but , in other words . This has the well-known solution . So now you have the solutions and . Now, for the most difficult part of the trick, you need to find all ways to glue intervals of these solutions together so the derivative matches across the glue point ... which means (consult the differential equations again!) that the gluing point(s) has to lie on the line .