Calculation Issues

How to Calculate the Maximum of a Cubic Trendline in Excel

Bushra ParveenBushra Parveen Nov 4, 2026 868 views

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.

How to Calculate the Maximum of a Cubic Trendline in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Extract the cubic coefficients

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.

2
Calculate the derivative coefficients

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.

3
Apply the quadratic formula

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).

4
Identify the valid maximum

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).

5
Calculate the final Y-value

Substitute your verified maximum x-value back into the original cubic equation (or use the SERIESSUM function) to output the maximum y-value.

Use LINEST and Mathematical Formulas to Find the Peak
Validating the curve shape: Always validate the result. The mathematical curve might actually be U-shaped (producing a minimum instead of a maximum) or the calculated peak might fall far outside your intended data range.
Advanced Spreadsheet Analysis

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. 1. Open your data: Launch WPS Spreadsheet and open your workbook containing the four x-y data points.
  2. 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. 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.
Fully compatible with Microsoft Excel formulas, including LINEST, SERIESSUM, and array operationsAdvanced charting and trendline features to visually verify your cubic and polynomial modelsFree, lightweight, and fast performance when handling complex datasets and statistical modeling
microsoft office alternative - wps office

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.