I suspect that a function $f(x,y)$ is of the form $f(x,y)=a(bx+c)^{dy+e}$. I have access to several values of $f(x,y)$. How do I proceed numerically to find the parameters $\{a,b,c,d,e\}$?

By plotting $\log f$ versus $\log y$ for a fixed $x$, I would get a linear curve and this would give me hope to find $\{d,e\}$. But getting $\{b,c\}$ is beyond me right now.


2 Answers 2


If it is it OK to recommend a solution that uses Python and SciPy, you can use the curve-fit function from scipy to do the job.

import scipy.optimize as op
import numpy as np

def func(xydata,a,b,c,d,e):
    x = xydata[:,0]
    y = xydata[:,1]
    return a*(b*x + c)**(d*y + e)

# Assuming you have your f(x,y) data in a file with
# three columns separated by comma e.g. x1,y1,f1
data = np.loadtxt('data.txt',delimiter=',')
xydata = data[:,0:2] # the first two columns
fdata = data[:,2] # the last column

# Use scipy to calculate the optimum parameter values
p_opt, p_conv = op.curve_fit( func, xydata, fdata )
  • 1
    $\begingroup$ worth noting that curve-fit solves a least-squares problem using the Levenberg-Marquardt algorithm (see the other answer) $\endgroup$
    – GoHokies
    Commented Dec 6, 2017 at 21:29

In general, you can formulate this as a nonlinear least squares problem. If your values are known at points $(x_{i},y_{i})$, and the known values are $f_{i}$, then you can minimize

$\min_{a,b,c,d,e} \sum_{i=1}^{n} \left( f_{i} - a(bx_{i}+c)^{dy_{i}+e} \right)^{2}$

The Levenberg-Marquardt method is commonly used to solve nonlinear least squares problems like this. You can find implementations in many software packages.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.