Integral of angle between tangent and line I have a problem like this but still haven't figured out how to solve it or what this concept is called in math.
Let's say I have a continuous and differentiable curve $S: y=f(x)$ from $A$ to $B$. $L$ is an arbitrary line with the formula $y=ax+b$. For every point $M$ within $A-B$ in $S$, $\alpha$  is the angle between the tangent of $S$ at $M$ and $L$. What is $\int \alpha(x) \, \mathrm{d}x$ from $A$ to $B$?

In fact I want to find the line(s) L where $\int \alpha(x) \, \mathrm{d}x$ is minimum. Thank you
I think this is unsolvable with math but easily do it with computer.
$\int \alpha(x) \, \mathrm{d}x$ = $\int \arctan{a} \, \mathrm{d}x$ - $\int \arctan{f'(x)} \, \mathrm{d}x$
And the later part is complicated or unsolvable, I tried with wolfram Alpha.

Since $\arctan(-x) = -\arctan(x)$ and $\arctan$ is strictly increasing, if
$$
\int_R\arctan(f(x))dx=0
$$
then it must be that
$$
\int_R f(x)dx=0
$$
So if you have a value of $a$ such that
$$
\int_A^B \arctan(a-f'(x)) dx = 0
$$
then you must also have
$$
\int_A^B (a-f'(x)) dx = 0
$$
so the solution is $a=f(B) - f(A)$.
