How to Calculate the Maximum of a Cubic Trendline in Excel
Question details
The user needs a method to automatically calculate the maximum x-value and y-value (peak) of a third-degree polynomial (cubic) trendline without manually inspecting the chart.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Analyzing specific sets of four data points that follow an increasing-then-decreasing pattern, and seeking a fully automated way via formulas or VBA to pinpoint the exact peak of the fitted curve.
- Observed behavior
- Currently, the peak and corresponding y-value are determined manually by looking at the graph, which is inefficient for processing multiple sets of points.
Ensure your data points genuinely follow a curve with a clear peak. Fitting a third-degree polynomial to exactly four points will always mathematically fit perfectly (R-squared = 1), but this does not guarantee it represents a realistic trendline outside those specific points.
Use LINEST and Mathematical Formulas to Find the Peak
This method uses Excel's built-in LINEST function to extract the cubic coefficients, differentiates the polynomial into a quadratic equation, and solves for the peak using standard mathematical formulas.
By extracting the exact parameters of the cubic trendline equation (y = ax³ + bx² + cx + d), you can calculate the derivative (y' = 3ax² + 2bx + c). Setting this derivative to zero allows you to use the quadratic formula to find the exact x-values of the turning points automatically.
Select four horizontal cells. Type the formula =LINEST(Y_range, X_range^{1,2,3}) and press Ctrl+Shift+Enter. This array formula outputs the coefficients a, b, c, and the intercept d.
In new cells, multiply the 'a' coefficient by 3 to get your new A value. Multiply the 'b' coefficient by 2 to get your new B value. The 'c' coefficient becomes your new C value. This represents the quadratic equation of the derivative.
Use the standard quadratic formula x = (-B ± SQRT(B^2 - 4*A*C)) / (2*A) in two separate cells to find the two roots (the potential stationary points).
Use an IF statement to check which of the two roots falls within your original data's x-value range and confirms a maximum (where the second derivative 6ax + 2b is less than 0).
Substitute your verified maximum x-value back into the original cubic equation (or use the SERIESSUM function) to output the maximum y-value.

Use VBA to Automate the Calculation
If you process many datasets, a custom VBA macro can run the LINEST operation in the background and output the maximum coordinates directly.
Calculate Complex Trendlines with WPS Spreadsheet
WPS Spreadsheet offers powerful built-in mathematical functions, easily processing complex calculations like derivatives and matrix functions. It completely supports the array formulas needed to find polynomial trendline maximums.
- 1. Open your data: Launch WPS Spreadsheet and open your workbook containing the four x-y data points.
- 2. Enter the LINEST array formula: Select an output range, enter the LINEST array formula to extract your cubic coefficients, and press Ctrl+Shift+Enter.
- 3. Automate the peak finding: Use standard cell formulas in WPS to apply the quadratic formula, pinpointing the exact maximum of your data trend effortlessly.

Frequently Asked Questions
Why does a cubic trendline applied to four points have an R-squared value of 1?
A third-degree polynomial has exactly four variables (a, b, c, d). Because there are four unknown parameters and four data points, the mathematical model solves perfectly, crossing through every single point. This naturally results in an R-squared of 1, but it does not mean the trendline is a good predictive model for data outside those specific points.
What happens if my data points do not represent an increasing-then-decreasing curve?
If the data simply increases or decreases linearly, or forms a U-shape, the calculated stationary points might represent a minimum instead of a maximum, or the mathematical peak might fall entirely outside the logical range of your data points. You must validate the points by checking the second derivative or visually plotting a scatter chart.
Can I use the MAX function on the trendline itself?
No, Excel's MAX function only evaluates the exact static values inside a cell range. A trendline is a visual representation of an equation. To find the maximum point of that equation, you must extract its coefficients using LINEST and calculate the peak mathematically.




