Solving Cauchy's problem with a discontinuous function

I have the Cauchy problem: $$\begin{cases} f'=g(t)+2(f-5) \\ f(0)=2\end{cases}$$

Now $$g(t)$$ is a periodic function: $$g(t)=\begin{cases} 0,t\in(24k,24k+8)\\ 2,t\notin(24k,24k+8) \end{cases}$$

for $$k=1,2,3...$$ How can I solve this Cauchy Problem? Since $$g$$ is not continuous I don't know what to do.

I am using sagemath to solve it.

• Use Laplace transform. – Jacky Chong Nov 24 '18 at 0:47

Rewrite as

$$f' - 2f = g - 10$$

A Fourier method is appropriate here. Since $$g$$ has a period of $$24$$, we can assume a series solution of similar periodicity

$$f(t) = f_0 + \sum_{n=1}^\infty \left[f_n\cos\left(\frac{n\pi}{12}t\right) + f_n^*\sin\left(\frac{n\pi}{12}t\right) \right]$$

Next, decompose $$g$$ to its Fourier series

$$g(t) = g_0 + \sum_{n=1}^\infty \left[g_n\cos\left(\frac{n\pi}{12}t\right) + g_n^*\sin\left(\frac{n\pi}{12}t\right) \right]$$

From the usual definitions:

$$g_0 = \frac{1}{24}\int_0^{24} g(t)\ dt = \int_8^{24} 2\ dt = \frac{4}{3}$$ $$g_n = \frac{1}{12}\int_ 8^{24} 2\cos\left(\frac{n\pi}{12}t\right) dt = -\frac{2}{n\pi}\sin \frac{2n\pi}{3}$$ $$g_n^* = \frac{1}{12}\int_8^{24} 2\sin\left(\frac{n\pi}{12}t\right)dt = -\frac{2}{n\pi}\left[1-\cos \frac{2n\pi}{3} \right]$$

Plug in the 2 series and compare coefficients, we get:

$$-2f_0 = g_0 - 10$$ $$-2f_n + \frac{n\pi}{12}f_n^* = g_n$$ $$-2f_n^* - \frac{n\pi}{12}f_n = g_n^*$$

Solve the above system of the equations to find $$f_n$$ and $$f_n^*$$