Let $f$ be a function defined on the real line. M. Stemlund proved in 2001 (The College Mathematics Journal, 32, 194-196) the following:
The function $f(x)$ is a quadratic polynomial if and only if for any $a$ and $b$ the intersection point of the tangents lines to $f(x)$ at $(a, f(a))$ and $(b, f(b))$ happens at $x=(a+b)/2$.
We wish to investigate this. Here are some tools for our toolbelt:
using Plots
using Roots
Base.ctranspose(f::Function) = D(f)
tangent(f, c) = x -> f(c) + f'(c)*(x-c)
tangent (generic function with 1 method)
We can graph two tangent lines using this pattern:
Here we can see the intersection point is not at (a+b)/2 = 1.5, but a bit to the right of that.
repeat the above for the function $f(x) = x^2$ and show graphically that the intersection point of the tangent lines is at $(a+b)/2$.
Pick another pair of values for a and b using a,b = sort(4*rand(2)) and show graphically that this is not a coincidence.
Now, show numerically (using fzero or fzeros) that the intersection point is equal to (a+b)/2 for the function $f(x) = x^2 + 2x + 3$ with $a=1$ and $b=2$.