Optimize Intervals for Piecewise Function Let's say I want to maximize $\int_{a}^{b}f(x)dx$ where:
$f(x)=\begin{cases}
g(x),  & \text{if } x \leq c \\
h(x), & \text{if } x > c
\end{cases}$
$a, b$ are constants and $c$ is my parameter for optimization.
Can I find a differentiable function in terms of $c$? Or how else may I go about optimizing my objective function?

You want to maximize
$$p(c) = \int_a^b f(x)\mathrm{d}x = \int_a^c g(x)\mathrm{d}x + \int_c^b h(x)\mathrm{d}x 
= \int_a^c g(x)\mathrm{d}x - \int_b^c h(x)\mathrm{d}x.$$
By the Fundamental Theorem of Calculus,
$$p'(c) = g(c) - h(c).$$
Now examine the critical points with $g(c)=h(c)$, as well as the two endpoints $c=a$ and $c=b$.
