Exponential Regression Calculator

Exponential Regression Calculator y = ae^(bx)

Paste your data below (one point per line as x y or x,y). You get the best-fit exponential curve, R², a live plot of the fitted curve, and the equation — with the steps and the NumPy code.

Examples:

This free exponential regression calculator fits the best-fit curve y = ae^(bx) through your data, draws the fitted curve on a live plot, and reports the equation, the coefficients a and b, and R² — then shows the working and the NumPy code. Paste your points above, press Fit curve, and you see exactly how well an exponential model describes growth or decay in your data.

What exponential regression actually does

Exponential regression finds the smooth curve y = ae^(bx) that comes closest to a set of data points whose values grow or shrink by a roughly constant percentage each step. Unlike a straight line, where y changes by a fixed amount for every unit of x, an exponential curve changes by a fixed ratio. That makes it the natural model for anything that compounds: populations, bacteria, radioactive decay, compound interest, viral spread, and the way a learning rate is decayed during neural-network training.

The coefficient a is the value of y when x is zero — the starting level of the curve. The rate b controls how fast the curve rises or falls: a positive b gives exponential growth, a negative b gives exponential decay, and the closer b is to zero, the flatter the curve. Because a is e raised to a real number, it is always positive, which is why this model can only fit data whose y values are all above zero.

How to use the exponential regression calculator

  1. Enter your data, one point per line, as x y or x,y. You need at least two points, and every y must be greater than zero.
  2. Press Fit curve. The best-fit equation, the coefficient a, the rate b, and R² appear instantly, next to a plot with the exponential curve drawn through your points.
  3. Change the decimal places selector if you want a shorter or longer readout, and press Copy result to grab the equation for a report or notebook.
  4. Open Show the working to see the log transform, the sums, and the least-squares formulas that produced a and b.

Try the example presets to see clean exponential growth, exponential decay, and a randomly generated growth series with a little noise — a fast way to build intuition for how a and b shape the curve.

Worked example

Take the growth preset: the points (0, 2), (1, 3.297), (2, 5.436), (3, 8.963), and (4, 14.78). Each y is roughly 1.65 times the one before it, a tell-tale sign of exponential growth. Feeding these into the calculator returns approximately a = 2.0 and b = 0.5, so the fitted model is close to y = 2e^(0.5x), with an R² near 1.0 — an almost perfect fit, because the data were generated from that very equation. That is exactly what you should expect: when the underlying process is genuinely exponential, the log-linear fit recovers the original parameters.

The log-linearization method: why we take ln of both sides

Fitting a curve directly is harder than fitting a line, so this calculator uses a classic trick. Starting from y = ae^(bx), take the natural logarithm of both sides:

ln(y) = ln(a) + b·x

This is now a straight line in the variables x and ln(y): the slope is b and the intercept is ln(a). So we set Y = ln(y) and run ordinary least squares on the transformed points (x, Y). The slope and intercept formulas are the same ones used for linear regression:

b = (n·Σx·lny − Σx·Σlny) / (n·Σx² − (Σx)²)

B = (Σlny − b·Σx) / n, and then a = e^B.

Because ln is only defined for positive numbers, every y in your data must be greater than zero — that is the single hard requirement of this method, and the calculator stops with a clear error if any y is zero or negative.

R-squared on the log scale

The R² reported here is measured on the linear fit of x against ln(y), not on the original y values. In formula form it is R² = r² where r is the correlation between x and ln(y). This is the standard, most widely reported R² for log-linearized exponential regression, and it answers the question “how well does a straight line describe the logged data?” An R² near 1 means the logged points sit almost exactly on a line, which in turn means the original points sit almost exactly on an exponential curve. Be aware that because the fit is done in log space, it gives proportionally more weight to small y values than a direct nonlinear fit would; for most growth and decay work the difference is minor, but it is worth knowing when you compare against a tool that fits the curve directly.

When to use exponential regression

Reach for exponential regression when a quantity changes by a roughly constant percentage per step rather than a constant amount. Classic growth cases include population size, unchecked bacterial or viral spread, compound interest, and the number of transistors on a chip over time. Classic decay cases include radioactive material, drug concentration in the bloodstream, the cooling of an object, and — in machine learning — a learning-rate schedule that shrinks each epoch. If a scatter plot curves upward ever more steeply, or falls fast then levels off toward zero, an exponential model is a strong candidate. If the data curve but also turn back down, a quadratic or polynomial fit is usually the better choice.

A quick diagnostic is to look at the ratios between successive y values. If those ratios are roughly constant — each point about the same multiple of the one before — the process is exponential and this model will fit well. If instead the differences between successive values are roughly constant, the data is linear and you should use linear regression. And if the ratios themselves drift in a clear pattern, the growth rate is not constant, which usually points to a logistic or polynomial model rather than a pure exponential one.

Exponential regression in Python

The same log-linearization is a one-liner in NumPy. Take the log of y, fit a degree-one polynomial, then exponentiate the intercept:

import numpy as np
x = np.array([0, 1, 2, 3, 4])
y = np.array([2, 3.297, 5.436, 8.963, 14.78])
b, B = np.polyfit(x, np.log(y), 1) # slope, intercept
a = np.exp(B)
print(a, b) # about 2.0, 0.5

For a fit done directly in the original units instead of log space, use SciPy’s curve_fit:

from scipy.optimize import curve_fit
def f(x, a, b):
    return a * np.exp(b * x)
params, _ = curve_fit(f, x, y, p0=[1, 0.1])
a, b = params

This calculator matches the np.polyfit(x, np.log(y), 1) approach, so you can prototype here and reproduce the numbers in code.

Common mistakes
Every y must be positive — the log transform is undefined for zero or negative values, so the calculator will refuse to fit data that contains them. And do not extrapolate an exponential fit too far beyond your data: exponential growth explodes and exponential decay flattens to near zero very quickly, so a curve that looks perfect on your sample can give wildly unrealistic predictions a few steps out.

Where exponential curves show up in machine learning

Exponential functions are everywhere in machine learning. Learning-rate schedules often decay the step size exponentially so training settles smoothly; exponential moving averages smooth gradients and metrics in optimizers such as Adam; and growth models built on e^(bx) describe how quantities like loss or accuracy can change over training. The softmax function that turns logits into probabilities is built from e^x as well. Understanding how a and b shape an exponential curve, and how the log transform linearizes it, makes all of these easier to reason about.

Frequently asked questions

Why must all my y values be positive?

The model is y = ae^(bx) with a > 0, and an exponential is always positive, so it can never produce zero or negative outputs. The fit also relies on taking ln(y), which is undefined for values that are not positive. If any y is zero or below, the calculator shows an error instead of a misleading result.

What do a and b mean?

The coefficient a is the value of y at x = 0, the starting level. The rate b sets the speed of change: positive b means growth, negative b means decay, and the size of b controls how steep the curve is.

How is this R-squared different from a normal one?

It is computed on the log-transformed data — the correlation between x and ln(y), squared. It tells you how straight the logged data is, which is equivalent to how exponential the original data is. A tool that fits the curve directly may report a slightly different R².

Can I use it for exponential decay?

Yes. Decay simply produces a negative rate b. The decay preset above returns a b near -0.5, describing values that fall by about the same ratio each step.

Is the calculator free?

Completely free, no sign-up, and it runs entirely in your browser — including the chart, which never sends your data anywhere.

Related calculators

Compare model types with the general regression calculator, fit a straight line with the linear regression calculator, or model a curve that bends both ways with the quadratic regression calculator.