I need to fit a complex function $f(z)$ of the form
f[z]=(p1[z]+p2[z]^(1/3)+p3[z]^(2/3))/(1+p5[z]^(5/6)+p6[z]^(19/6))
where all $p_i(z)$ are polynomials of degree up to $8$ in $z$ with real coefficients. So, there are about 20-30 real parameters. The data are provided in the form of $400$ complex pairs $(z,f(z))$, $|z|<0.2$ (or a subset of $100, 200$ points). The accuracy of the data is $10^{-10}$. The coefficients of all polynomials decrease fast. The fit is done using MulitNonlinearModelFit,
fit=MultiNonlinearModelFit[{dataRe[LIST], dataIm[LIST]},ComplexExpand[ReIm[Model]],InitialValues,{x, y}]
where LIST
is the array of points of the form $\{z_i,f(z_i)\}$ and Model=f[x+I*y]
. It works reasonably well when I restrict degrees of polynomials to $4,5$. I get the error of the fit roughly $10^{-6}$. So, I know the location of the minimum and need to increase accuracy to $10^{-10}$ by increasing degrees of polynomials to $8$.
First, I managed to increase accuracy to $10^{-8}$ with the degrees $5,6$, Method to Automatic
in the fit, it took about 30 mins. When I increased degrees to $8$, Mathematica got stuck. I ran it first on PC and then on the Unix cluster for 10 hours and it consumed 90% of the cluster memory, 180 Gb, before I stopped it. Apparently, it lost the local minimum which was known from previous runs. I decided to try some local methods like Newton
, ConjugateGradient
and others. They worked but didn't increase the accuracy of the initial guess at all. I have a few questions:
- Is it possible to output the method used by MulitNonlinearModelFit, when it is set to
Automatic
? I am curious about what method it is using to increase the accuracy of the initial guess. - How to monitor the progress of the MultiNonlinearModelFit? I tried adding the last argument after {x,y} as
EvaluationMonitor:>Print["test"]
(or StepMonitor) and there is no output. - Can you recommend the local method which may work in this situation?
Thanks for reading.
f[z]
is a bit off. Underscores aren't a valid option in variable names and you have what probably should be a pair of parentheses that starts with a(
and ends with a}
. Also,MultiNonlinearModelFit
assumes equal variances for the two sets of data. Is that a reasonable assumption? $\endgroup$ComplexExpand[ReIm[Model]]
is a really bad idea. This function is trying to separate your Model into real and imaginary parts analytically. The result is a horrible expression of 1000's terms long when your Model is complicated enough. You need to define instead a numerical functionModelnum[c1_,c2_,...,x_,y_]:={Re[Model],Im[Model]}
where c1,c2 ... are parameters of your function and z=x+Iy. Then it evaluates the Model function numerically and converges instantly.ComplexExpand
can be only used when your model is really simple. $\endgroup$