Given any quadratic equation of the form $y=ax^2+bx+c$, I want to find the minimum value for a specific range of $x$.
My programmer brain can do it in a branchy, algorithmic way as follows, but is there a more elegant solution?
- if the $a$ coefficient is positive,
- and the end of my range is before the lowest point of the quadratic,
- return the end of my range
- and the start of my range is after the lowest point of the quadratic,
- return the start of my range
- and the lowest point of the quadratic occurs in the middle of my range,
- return the lowest point of the quadratic
- and the end of my range is before the lowest point of the quadratic,
- if the $a$ coefficient is negative, etc...