# How to find maximum of bezier curve

Is there an easy way to find the maximum of a bezier curve/path?

My intention is to draw a vertical line where the curve has its maximum. I did it "by hand" and it does the job, but I'd appreciate a more elegant solution.

here is my code so far.

\begin{tikzpicture}[scale=10, thick]

\draw[name path=cons] (-0.5, 0) .. controls (-0.2, 0.4) and (0.45, 0.6) .. (0.5, 0);
\path[name path=line1] (-1, 0.1) -- (1, 0.1);
\draw[name intersections={of=line1 and cons}] (intersection-1) -- (intersection-2);

\path[name path=line2] (0.175, 0) -- (0.175, 0.4);
\path[name path=intersection1, name intersections={of=line2 and line1}] (intersection-1) coordinate (int1);
\path[name path=intersection2, name intersections={of=line2 and cons}] (intersection-1) coordinate (int2);

\draw (int1) -- (int2);

\end{tikzpicture}


• This task is easier to solve in a “real” programming language. For example, the LuaLaTeX package bezierplot may be useful (“It finds special points such as extreme points and inflection points and reduces the number of used points.”). Using TeX’s built-in “language” can be tedious. – Ruixi Zhang Jan 23 at 1:38
• The other option is to dig into the math of how a Bezier curve is defined. – Teepeemm Jan 23 at 2:43
• @RuixiZhang Thanks for pointing that out! I'm not familiar with LuaLaTeX, but I'll look into it. – ChrisW Jan 23 at 7:54
• @Teepeemm Yes I might be able to do compute it, but not without stuffing a lot of math operations in LaTeX! Well my pictures serves me well for now. I'll post my solution, when I find a good one. – ChrisW Jan 23 at 7:56