Desmos Exponential Regression Calculator Guide
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This page explains how to perform exponential regression using Desmos, the free online graphing calculator. You enter your x and y data points, and Desmos fits an exponential curve of the form y = a·b^x to your data, displaying the values of a and b along with the correlation coefficient R². The calculator also plots the curve over your data so you can visually assess the fit.
Formula
Exponential regression fits data to the model y = a · bx, where:
- x is the independent variable (input), often time.
- y is the dependent variable (output), the quantity being measured.
- a is the initial value (the predicted y when x = 0).
- b is the growth factor (if b > 1, growth; if 0 < b < 1, decay).
The coefficients are found by linearizing the model: taking the natural logarithm of both sides gives ln(y) = ln(a) + x·ln(b). Desmos then performs a linear least-squares fit on the transformed data (x, ln(y)). The slope of that line equals ln(b), and the intercept equals ln(a). The formulas in the calculator above implement this directly using the least-squares equations.
Worked Example
Using the default data: x = 1, 2, 3, 4, 5 and y = 3, 6, 12, 24, 48.
- Compute the necessary sums:
sum(x) = 15, sum(x²) = 55, sum(ln(y)) = ln(3)+ln(6)+ln(12)+ln(24)+ln(48) ≈ 1.0986+1.7918+2.4849+3.1781+3.8712 = 12.4246,
sum(x·ln(y)) = 1·1.0986 + 2·1.7918 + 3·2.4849 + 4·3.1781 + 5·3.8712 = 1.0986+3.5836+7.4547+12.7124+19.356 = 44.2053. - Calculate ln(b) = (n·sum(x·ln(y)) – sum(x)·sum(ln(y))) / (n·sum(x²) – (sum(x))²) = (5·44.2053 – 15·12.4246) / (5·55 – 225) = (221.0265 – 186.369) / (275 – 225) = 34.6575 / 50 = 0.69315.
Thus b = e^0.69315 ≈ 2.000. - Calculate ln(a) = (sum(ln(y)) – ln(b)·sum(x)) / n = (12.4246 – 0.69315·15) / 5 = (12.4246 – 10.39725) / 5 = 2.02735 / 5 = 0.40547.
Thus a = e^0.40547 ≈ 1.500. - So the regression equation is y = 1.5 · 2x. For x=1, predicted y = 3; for x=5, predicted y = 48. The R² value is 1 because the data fits perfectly.
How to Perform Exponential Regression in Desmos
Desmos makes this process straightforward:
- Go to desmos.com/calculator.
- Enter your x-values in a list, e.g., type
x_1 = [1,2,3,4,5]. - Enter your y-values in another list, e.g.,
y_1 = [3,6,12,24,48]. - Type
y_1 ~ a b^{x_1}in a new expression line. Desmos will automatically fit the exponential model. - Read the values of a and b from the output, along with R² and the residual plot.
If you prefer a different form, you can use y_1 ~ a e^{kx_1} for the natural exponential model y = a·e^(kx). The two are related: b = e^k.
Choosing Between Exponential and Other Models
Exponential regression is appropriate when the rate of change is proportional to the current value – typical for population growth, radioactive decay, compound interest, and bacterial growth. To check if exponential is right:
- Plot your data and see if it curves upward (or downward) consistently, not like a straight line or a parabola.
- If the log of y versus x looks roughly linear, exponential is a good fit.
- Compare R² values with linear or polynomial fits. Exponential often has a high R² for growth data, but beware of overfitting with higher-degree polynomials.
If your data has a horizontal asymptote (e.g., cooling toward room temperature), a logistic or logarithmic model may be better.
Common Mistakes and Pitfalls
- Using raw y values when y is zero or negative: Exponential regression requires y > 0 because you take logarithms. If any y is ≤ 0, the model fails.
- Misinterpreting a and b: a is the y-intercept (value at x=0), not the first data point. b is the multiplier per one unit increase in x, not the percentage change. For example, b=1.05 means a 5% increase per unit.
- Ignoring units: If x is in years, b is the factor per year. If x is in months, b is per month. Be consistent when making predictions.
- Extrapolating too far: Exponential models grow quickly; predictions far beyond your data range are highly uncertain.
- Confusing R² with correlation: R² tells you how well the curve fits, but a high R² does not guarantee the model is correct.
Limitations of Exponential Regression
Exponential regression assumes a constant growth factor. Real-world data often deviates: growth may slow due to resource limits (logistic), or the process may be better described by a power law (y = a·x^b). Also, outliers can heavily skew the fit because the least-squares method on log-transformed data gives more weight to small y values. Always plot residuals to see if the pattern is random or systematic.
Alternatives to Desmos for Exponential Regression
Several other tools can perform exponential regression:
- Excel/Google Sheets: Use the LOGEST function or add a trendline with exponential option.
- TI-84 calculator: Use the ExpReg command in the STAT menu.
- Python (numpy/scipy): Use
curve_fitwith an exponential function. - R: Use
lm(log(y) ~ x).
Desmos is unique for its ease of use and immediate visualization, making it ideal for learning and quick checks.
Frequently Asked Questions
How do I get the regression equation in Desmos?
Type your data as lists (e.g., x_1 and y_1), then type y_1 ~ a b^{x_1}. Desmos will display the fitted values of a and b in the expression line.
What does R² mean in exponential regression?
R² (coefficient of determination) measures how well the regression curve explains the variation in y. Values close to 1 indicate a strong fit; 0.9 or higher is often considered good for many applications.
Can I use exponential regression if my y-values are negative?
No, because the model requires taking the natural logarithm of y. If any y is zero or negative, you cannot use exponential regression directly. Consider adding a constant to shift the data, or use a different model.
What is the difference between y = ab^x and y = ae^(kx)?
They are equivalent: b = e^k, so k = ln(b). The first form emphasizes the growth factor per unit x, while the second uses the continuous growth rate k. Desmos can fit either; choose based on your preference.
How do I predict future values using the regression?
Once you have a and b, plug in the desired x (e.g., future time) into y = a·b^x. For example, if a=100 and b=1.05, then at x=10 years, y = 100·1.05^10 ≈ 162.89.
Why does my exponential fit look bad even with high R²?
R² can be high even when the model is systematically wrong, especially if data spans several orders of magnitude. Always check a residual plot: if residuals show a pattern (e.g., U-shape), the exponential model may be inappropriate.
Related
Formula used
in x | X values | - | 1, 2, 3, 4, 5 | 0 in y | Y values | - | 3, 6, 12, 24, 48 | 0 out a | a (initial value) | - | exp((sum(ln(y)) * sum(x^2) - sum(x) * sum(x*ln(y))) / (count(x) * sum(x^2) - sum(x)^2)) | 4 out b | b (growth factor) | - | exp((count(x) * sum(x*ln(y)) - sum(x) * sum(ln(y))) / (count(x) * sum(x^2) - sum(x)^2)) | 4 out r2 | R² (goodness of fit) | - | 1 - sum((y - a*b^x)^2) / sum((y - mean(y))^2) | 4
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.