The Physics of Your Product: Understanding the Mathematical Drivers of User Growth
From the publisher’s feed, collected in the ZeroLabs newsroom.
Imagine you are a restaurant owner watching a new regular walk through the door. After their first week of consistent takeout orders, a high-stakes question inevitably crosses your mind: “How much is this customer actually worth to us over the next year?” Will they remain a loyal power-user, or will their order frequency sharply decline after the “honeymoon phase”? At what exact point will their spending plateau?”I’ve been fascinated by these exact questions recently. It turns out, predicting a customer’s Lifetime Value or forecasting the saturation point of their spend isn’t just guesswork it’s a problem perfectly solved by curve fitting.If you’ve ever tried to learn this on your own, you already know it can feel like an arcane, mathematically dense dark art that takes serious time to decipher and implement.That is exactly why I decided to write this guide. I wanted to translate this complex concept into a practical, accessible toolkit. And while it’s an absolute superpower for food delivery analytics, curve fitting is used everywhere to predict the future: pharmacologists use it to model how fast a drug is absorbed into the bloodstream, marketing teams use it to find the point of diminishing returns on ad spend, and engineers use it to forecast exactly when a lithium-ion battery will degrade past the point of usefulness.To make this guide as hands-on as possible, I’ve also built an interactive website where you can play with the mathematical parameters and watch the graphs update in real-time. Let’s dive in.I have created a Interactive lab to go along with this article which can be found here.The Curve Fitting Laboratory: From Linear to Richards & Weibull1. Why Curve Fitting?Imagine you just launched a massive user acquisition campaign for a new app or game. Your Daily Active Users (DAU) spike on Day 1, drop sharply by Day 7, and then begin a slow, bumpy descent. Your product manager walks over and asks: “Where does our baseline DAU stabilize in 6 months?”You can’t just guess, and calculating a simple average of those wildly fluctuating early days will give you a terribly inaccurate forecast. This is exactly where curve fitting shines. By taking the noisy, scattered points of your early DAU data and mathematically finding the function that best “hugs” that trend, you achieve two critical things:Reliable Extrapolation: You can project the curve forward in time to forecast exactly where your user base will bottom out and stabilize, allowing for accurate server and budget planning.Deep Interpretability: Unlike a “black box” machine learning model that just spits out a number, a fitted curve gives you a concrete equation. You can point to specific parameters to explain exactly how fast your users are churning versus how many are sticking around.In short, curve fitting cuts through the daily noise of your metrics to reveal the underlying physics of your product’s growth.2. The Curve CatalogChoosing the right “family” of curves is the most important decision you will make in this process. If the underlying physics of your data is exponential, a linear fit will fail spectacularly no matter how much data you feed it.To help you choose, let’s break down the 9 essential models, their mathematical parameters, and how tweaking those parameters physically changes the shape of your forecast.Part 1: The Basic CurvesThese are your standard mathematical workhorses, ideal for simpler relationships or isolated segments of a user’s lifecycle.LinearEquation: y = ax + bParameters: a (Slope): Controls the constant rate of change. A higher a means steeper growth. b (Intercept) The starting value at day zero.When to use it: When your metric is growing at a perfectly steady, constant rate.2. Polynomial (Quadratic, Cubic, etc.)Equation: y = ax³ + bx² + cx + d (Cubic)Parameters: a (Leading Coefficient): Controls the extreme “tails” of the curve. Because it is cubed, this parameter dominates over time, dictating whether the forecast ultimately shoots up to positive infinity or plunges to negative infinity. b and c, These parameters control the “humps” of the curve the local peaks and valleys where the data temporarily changes direction as well as the inflection point where the curve’s bend flips. d (Intercept), The baseline starting value at day zero.When to use it: Cubics are highly flexible and fantastic for interpolation when your historical data changes direction twice (for example, an initial spike in takeout orders, a mid-month slump, followed by a month-end surge). However, they come with a massive warning label: do not use them for extrapolation. Because of that x³ multiplier, the moment you try to forecast beyond your observed data window, the curve will violently fly off to unphysical extremes.3. ExponentialEquation: y = a · e^(bx)Parameters: a Your starting baseline. b (Growth/Decay Rate) If b is positive, the curve shoots upwards toward infinity (viral growth). If b is negative, it rapidly decays toward zero (radioactive decay).When to use it: Modeling compound growth, like early viral loops or unchecked organic acquisition.4. LogarithimicEquation: y = a + b · ln(x)Parameters: a the baseline starting point. b The rate of change. A higher b means the curve rises more before flattening.When to use it: Modelling compound growth, like early viral loops or unchecked organic acquisition.5. Power LawEquation: y = a · x^bParameters: a The initial scale or starting point. b (Shape parameter) Dictates the speed of decay or growth.When to use it: Modelling compound growth, like early viral loops or unchecked organic acquisition.Part 2: The S-Shaped (Sigmoidal) CurvesIn business, nothing grows forever. Things start slow, accelerate, and eventually plateau. Sigmoidal curves capture this perfectly and are the ultimate tool for forecasting Cumulative Revenue, LTV, and Market Penetration.6. LogisticEquation: y = L / (1 + exp(-k * (x — x0)))Parameters: L (Ceiling) The maximum possible value (the plateau). k (Steepness) How fast the metric grows during its rapid growth phase. x0 (Midpoint) The exact time or day when growth hits its absolute peak before slowing down.When to use it: When you expect symmetric saturation. The journey from 0% to 50% looks exactly like the journey from 50% to 100%. Great for standard market penetration or balanced LTV accumulation.7. GompertzEquation: y = a * exp(-b * exp(-c * x))Parameters: a (Asymptote) The maximum limit or ceiling. b (Displacement) Sets the starting point along the x-axis. c (Growth Rate) Controls how quickly the curve approaches the ceiling.When to use it: When growth is asymmetric. It models rapid early growth that takes a very, very long time to finally reach the ceiling. Perfect for modeling scenarios where early adopters spend fast, but the late majority trickles in slowly.8. Richards (Generalized Logistic)Equation: y = A + (K — A) / (1 + Q * exp(-B * x))^(1 / v)Parameters: A (Lower Asymptote) The starting baseline (e.g., Day 1 spend). K (Ceiling) The upper limit or maximum LTV. B (Velocity) The base growth rate. Q (Initial state) Shifts the curve near the origin. v (Asymmetry) The magic parameter that dictates whether the fastest growth happens early in the lifecycle (whales) or late in the lifecycle (subscriptions).When to use it: The “Master Curve” for LTV forecasting. By tweaking the ‘v’ parameter, the Richards curve can literally shape-shift into a Logistic or Gompertz curve, making it the most robust and adaptable tool in your catalog.9. WeibullEquation: y = c — (c — a) * exp(-(x / b)^d)Parameters: c (Ceiling) The maximum value. a (Starting Value) The baseline or Day 0 value. b (Scale) Stretches or compresses the curve along the timeline. d (Shape) The critical parameter that controls how the curve bends and dictates the saturation speed.When to use it: Highly flexible. Originally used in reliability engineering to predict machine failure, it’s excellent for modeling user churn over time or highly variable retention behavior.3. The Optimization Engine: Finding the “Best Fit”Now that you have selected the perfect mathematical curve from the catalog, how do you actually find the specific parameters (the a, b, c, etc.) that make the curve “hug” your data perfectly?This is an optimization problem. The goal of an optimizer is to guess a set of parameters, measure how far off the resulting curve is from your actual data (usually calculating the Sum of Squared Residuals), and then intelligently adjust those parameters until the error is minimized.In Python, the workhorse for this is scipy.optimize.curve_fit. When you run this function, you are handing your data over to one of three powerful algorithms under the hood. Choosing the right one is the secret to avoiding errors and getting a reliable forecast.1. Levenberg-Marquardt (LM)What it is: The default algorithm in curve_fit (if you don't specify boundaries). It acts like a hybrid between two other mathematical methods (Gradient Descent and Gauss-Newton), making it incredibly fast and efficient.The Catch: It is strictly for unconstrained problems. You cannot tell LM that a parameter “must be greater than zero.”When to use it: When your data is clean, the mathematical model is simple (like a basic Exponential or Polynomial curve), and you don’t care if the algorithm explores negative parameter values.2. Trust Region Reflective (TRF)What it is: A robust, large-scale optimizer that solves the problem by defining a “trust region” around its current guess and systematically exploring within that boundary.The Catch: It requires you to set physical bounds for your parameters.When to use it: This is your daily driver for business metrics. If you are forecasting LTV, you know the ceiling ($K$) cannot be infinite, and the starting value ($A$) cannot be negative. TRF allows you to pass a bounds argument to enforce these physical realities, preventing the model from outputting mathematically valid but logically absurd results.3. DogboxWhat it is: Another bounded optimization algorithm. It operates similarly to TRF but uses a slightly different mathematical approach (operating within a “box” of constraints).The Catch: It struggles with very large, complex datasets or highly correlated parameters.When to use it: When you have a small dataset with strict boundaries and TRF is failing to converge or getting stuck in a local minimum. It’s a great fallback option.How to Apply Them in PracticeUsing these in Python is as simple as passing the method argument to your curve_fit function. Here is the mental checklist:Need to restrict your LTV to positive numbers? Create your boundaries and use TRF.Doing a quick, simple physics calculation with no bounds? Let it default to LM.TRF throwing an error on your bounded problem? Swap the method to Dogbox and try again.4. Hands-On: Predicting Cumulative App UsersLet’s put the theory into practice. Imagine you launched a new community app 60 days ago. You have been tracking the cumulative registered users every day. The growth was explosive in month one, but it is starting to slow down. Your investors want to know: “What is the natural ceiling of our user base with this current product, and where will we be at Day 365?”Because cumulative users follow a classic “slow start -> viral spike -> market saturation” lifecycle, this is a textbook use case for an S-shaped curve. We will use the Richards (Generalized Logistic) curve and the TRF optimizer to ensure our forecast stays within logical physical boundaries.The Python Implementationimport numpy as npimport matplotlib.pyplot as pltfrom scipy.optimize import curve_fit# 1. Generate some synthetic "observed" data (First 60 days of launch)np.random.seed(42)days_observed = np.arange(1, 61)# Simulating a viral launch that is starting to slow downtrue_curve = 50000 / (1 + 15 * np.exp(-0.1 * days_observed))**(1/0.5)users_observed = true_curve + np.random.normal(0, 500, len(days_observed))# 2. Define the Richards Curvedef richards_curve(x, A, K, B, Q, v): """ A: Lower asymptote (Starting baseline) K: Upper asymptote (Maximum market saturation) B: Growth rate / Velocity Q: Initial state offset v: Asymmetry parameter """ return A + (K - A) / (1 + Q * np.exp(-B * x))**(1 / v)# 3. Set Initial Guesses (p0) and Physical Bounds# Guessing: Start at 0, Ceiling at 100k, 10% growth rate, offset 10, v=1initial_guesses = [0.0, 100000.0, 0.1, 10.0, 1.0]# Bounds: [Lower bounds for (A, K, B, Q, v)], [Upper bounds]# We know users can't be negative, and market size can't exceed e.g., 1 millionlower_bounds = [0.0, max(users_observed), 0.001, 0.1, 0.01]upper_bounds = [1000.0, 1000000.0, 1.0, 100.0, 5.0]# 4. Fit the curve using Trust Region Reflective (TRF)popt, pcov = curve_fit( richards_curve, days_observed, users_observed, p0=initial_guesses, bounds=(lower_bounds, upper_bounds), method='trf')# Extract the fitted parametersA_fit, K_fit, B_fit, Q_fit, v_fit = poptprint(f"Predicted Market Ceiling (K): {int(K_fit):,} users")# 5. Extrapolate to Day 365days_future = np.arange(1, 366)users_forecast = richards_curve(days_future, *popt)# Plotting the resultsplt.figure(figsize=(10, 6))plt.scatter(days_observed, users_observed, label='Observed Users (Days 1-60)', color='black', s=15)plt.plot(days_future, users_forecast, label='Richards Forecast (Day 365)', color='red', linestyle='--', linewidth=2)plt.axhline(K_fit, color='blue', linestyle=':', label=f'Saturated Ceiling: {int(K_fit):,}')plt.title("Cumulative App Users Forecast")plt.xlabel("Days Since Launch")plt.ylabel("Total Registered Users")plt.legend()plt.grid(True, alpha=0.3)plt.show()5. Key TakeawaysYou now have the theory, the equations, and the Python code to start predicting the future of your product’s metrics. However, as the saying goes: “All models are wrong, but some are useful.” Before you push your first curve-fitting script into production to forecast a multi-million dollar ad budget, keep these battle-tested rules in mind to avoid the most common traps.1. Your Initial Guesses (p0) Matter More Than the AlgorithmOptimisation algorithms are essentially blindfolded hikers trying to find the lowest point in a valley (the point of minimum error). If you drop them in the wrong valley, they will find the bottom of that valley, but entirely miss the deeper valley right next door. This is known as getting stuck in a local minimum.If you are forecasting user LTV, and you know the industry average is around $15, do not leave the initial guess at 0. Set your p0 starting values close to reality. Spend 60 seconds eyeballing a scatter plot of your data before you write any code—it will save you hours of debugging.2. The Math Doesn’t Know Your Business (Always Set Bounds)An unconstrained optimization algorithm will happily tell you that your user base will drop to negative 5,000 next month, or that your app will reach 14 billion users by Tuesday. The math checks out, but the physics do not. Always use the TRF or Dogbox methods and pass explicit lower and upper boundaries to enforce physical and business realities (e.g., revenue cannot be negative, DAU cannot exceed the population of Earth).3. Beware of Parameter Bloat (Overfitting)The Richards curve is a masterpiece, but it requires calculating 5 separate parameters. If you only have 7 days of launch data, feeding it into a 5-parameter model will result in massive overfitting. The curve will twist itself into knots to hit every single noisy data point perfectly, resulting in an extrapolation that looks like a rollercoaster.The Rule of Thumb: If you have very little data, use a simpler model (like a 3-parameter Logistic curve or a basic Power Law). Graduate to the Richards curve only when your data matures.4. Visualize Your ResidualsThe R-squared metric is not enough to tell you if your fit is good. Always plot your residuals (the actual data points minus the curve’s predicted points).Good Fit: The residuals look like random static or white noise scattered around zero.Bad Fit: The residuals follow a clear pattern (like a wave or a smile). If you see a pattern, it means your mathematical model is systematically missing a trend in the data. You chose the wrong curve catalog!5. Extrapolation is a Hypothesis, Not a ProphecyCurve fitting is exceptionally good at interpolation (understanding the data you already have) and making short-to-medium-term forecasts. However, projecting a 30-day trend out to 5 years is incredibly risky. Use these models to make informed, directional business decisions — like when to cut ad spend or when to upgrade servers — but never treat them as absolute gospel.ConclusionCurve fitting is an incredible capability to add to your toolkit. It bridges the gap between raw, messy data and human-readable, actionable business strategy. By moving away from “black box” models and embracing interpretable parameters, you can not only predict where your metrics are going, but explain why they are going there.The Physics of Your Product: Understanding the Mathematical Drivers of User Growth was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.