# Finding parameters numerically

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.

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
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 )
print(popt)

• worth noting that curve-fit solves a least-squares problem using the Levenberg-Marquardt algorithm (see the other answer) 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.

• I have successfully used for this type of problem the Levenberg-Marquardt method implemented in the MPFIT code by Craig Markwardt, physics.wisc.edu/~craigm/idl/cmpfit.html Dec 10, 2017 at 7:44