SoatDev IT Consulting
SoatDev IT Consulting
  • About us
  • Expertise
  • Services
  • How it works
  • Contact Us
  • News
  • September 29, 2025
  • Rss Fetcher

The previous post needed to fit a double exponential function to data, a function of the form

a exp(b exp(cx))

By taking logs, we have a function of the form

f(x) = a + b exp(cx)

where the a in the latter equation is the log of the a in the former.

In the previous post I used a curve fitting function from SciPy to find he parameters a, b, and c. The solution in the post works, but I didn’t show all the false starts along the way. I ran into problems with overflow and with the solution method not converging before I came up with the right formulation of the problem and a good enough initial guess at the solution.

This post will look at fitting the function more analytically. I’ll still need to solve an equation numerically, but an equation in only one variable, not three.

If you need to do a regression, fitting a function with noisy data to more than three points, you could use the code below with three chosen data points to find a good starting point for a curve-fitting method.

Solution

Suppose we have x1 < x2 < x3 and we want to find a, b, and c such that

begin{align*} y_1 &= a + b exp(c x_1) \ y_2 &= a + b exp(c x_2) \ y_3 &= a + b exp(c x_3) \ end{align*}

where y1 < y2 < y3.

Subtract the equations pairwise to eliminate a:

begin{align*} y_2 - y_1 &= b (exp(c x_2) - exp(c x_1)) \ y_3 - y_1 &= b (exp(c x_3) - exp(c x_1)) \ end{align*}

Divide these to eliminate b:

frac{y_2 - y_1}{y_3 - y_1} = frac{exp(c x_2) - exp(c x_1)}{exp(c x_3) - exp(c x_1)}

Factor out exp(cx1) from the right side:

frac{y_2 - y_1}{y_3 - y_1} = frac{1 - exp(c (x_2 - x_1))}{1 - exp(c (x_3 - x_1))}

Now the task is to solve

L = frac{1 - exp(c d_2)}{1 - exp(c d_3)}

where

begin{align*} L &= frac{y_2 - y_1}{y_3 - y_1} \ d_2 &= x_2 - x_1 \ d_3 &= x_3 - x_1 end{align*}

Note that L, d2, and d3 are all positive.

Once we find c numerically,

b = frac{y_2 - y_1}{exp(c x_2) - exp(c x_1)}

and

a = y_1 - b exp(c x_1)

Python code

Here’s a Python implementation to illustrate and test the derivation above.

from scipy import exp
from scipy.optimize import newton

def fit(x1, x2, x3, y1, y2, y3):
    assert(x1 < x2 < x3)
    assert(y1 < y2 < y3)

    d2 = x2 - x1
    d3 = x3 - x1
    L = (y2 - y1)/(y3 - y1)
    g = lambda x: L - (1 - exp(x*d2))/(1 - exp(x*d3))
    c = newton(g, 0.315)

    b = (y2 - y1)/(exp(c*x2) - exp(c*x1))
    a = y1 - b*exp(c*x1)
    return a, b, c

a, b, c = fit(9, 25, 28, 42, 55, 92)
print([a + b*exp(c*x) for x in [9, 25, 28]])

The post Fitting a double exponential function to three points first appeared on John D. Cook.

Previous Post
Next Post

Recent Posts

  • Brave updates its AI-powered search with a detailed answers feature
  • Diamond Trust Bank Expands Nairobi Footprint
  • Trump’s Energy Department forbids staff from saying ‘climate change’ or ‘green’
  • Final day to apply: Volunteer at TechCrunch Disrupt 2025
  • OpenAI rolls out safety routing system, parental controls on ChatGPT 

Categories

  • Industry News
  • Programming
  • RSS Fetched Articles
  • Uncategorized

Archives

  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023

Tap into the power of Microservices, MVC Architecture, Cloud, Containers, UML, and Scrum methodologies to bolster your project planning, execution, and application development processes.

Solutions

  • IT Consultation
  • Agile Transformation
  • Software Development
  • DevOps & CI/CD

Regions Covered

  • Montreal
  • New York
  • Paris
  • Mauritius
  • Abidjan
  • Dakar

Subscribe to Newsletter

Join our monthly newsletter subscribers to get the latest news and insights.

© Copyright 2023. All Rights Reserved by Soatdev IT Consulting Inc.