If $\int_a^b e^{cosx}(380-x-x^2)dx$ attains its maximum value for some $(a,b)$ such that $a\leq b$, then the value of $b-a$ is?
My attempt
Factorized the integrand to reduce it to $\int_a^b e^{cosx}(20+x)(19-x)dx$, now my first instinct was to take $b-a=c$, treat $a$ as a constant and then use the Newton-Leibniz formula to differentiate the integral $\int_a^{a+c} e^{cosx}(20+x)(19-x)dx$ with respect to c, which gives me values of $a+c$ but doesn't seem to lead anywhere. Along with this taking $a$ as a constant is pretty random and has no basis. I suspect some property of definite integration may be involved but am unable to find something to lead me anywhere.
Hints or solutions are appreciated
The question is about the global maximum of the two variable function $$ F(a,b)=\int_a^b e^{\cos x}(380-x-x^2)dx. $$
Since this is a differentiable function in an open set ($\mathbb{R}^2$), the maximum must occur in a stationary point, which satisfies the conditions
$$F'_a = - e^{\cos a}(380-a-a^2) = 0, \quad F'_b=e^{\cos b}(380-b-b^2) = 0.$$
We can check that the possible values for $a,b$ are $-20,19$. We can rule out the case $a=b$ because $F(a,a)=0$ is not the maximum e conclude that the maximum is attained for $a=-20, b=19$. So, $b-a = 39$, and the maximum is approximately $12457.1$.