0
$\begingroup$

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:

  1. 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.
  2. 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.
  3. Can you recommend the local method which may work in this situation?

Thanks for reading.

$\endgroup$
4
  • $\begingroup$ The code for 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$
    – JimB
    Commented Apr 7, 2023 at 5:05
  • $\begingroup$ Thanks, I corrected the code, it was in LaTeX but the system was not accepting it. Regarding equal variances, two sets of data are real and imaginary parts of the function. I guess it is a reasonable assumption. $\endgroup$
    – VladM
    Commented Apr 7, 2023 at 8:22
  • $\begingroup$ Ok, I found the source of the trouble. Using 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. $\endgroup$
    – VladM
    Commented Apr 8, 2023 at 0:58
  • $\begingroup$ Ok, I found the source of the trouble. Using 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 function Modelnum[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$
    – VladM
    Commented Apr 8, 2023 at 1:03

0

Your Answer

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

Browse other questions tagged or ask your own question.