I want to perform a nonlinear least square fit of data points upto 3000. Because the model I provide is huge polynomials with 300 to 400 fitting parameters to be estimated, my mac i7 computer proceeds slowly or not at all proceeding. I just like to know if I can run this fitting calculation in multiple processors. My pc has 4 kernels as shown by mathematica. I want to make use of all of them to perform the fitting procedure. But I donot know how to do this. Is there any specific simple mathematica script I can run so that mathematica runs in all of them in reasonable time limit with least memory. I tried to parallelize the NonlinearModelFit command along with its syntax. It says it can not be parallelized and proceeds in sequencential condition. I tried to use ParallelSubmit with NonlinearModelFit and it optimizes only few fitting parameters leaving the other parameters equal to 1. Can any one tell me how to tackle this problem? I use mathematica 12 version. What about cloud computing. Will this solve the problem. If so, please give me the relevent details.


  • $\begingroup$ As with any iterative procedure, having good starting values are worth their weight in gold. It sounds like you're just using the default starting value of 1 for all parameters. Also, standardizing the predictor variables might help (subtracting the mean and then dividing by the standard deviation is one approach). $\endgroup$ – JimB Oct 11 '20 at 22:04
  • $\begingroup$ Depending on the structure of your polynomials using HornerForm might reduce numerical instabilities. $\endgroup$ – JimB Oct 11 '20 at 22:13
  • $\begingroup$ If you are really just using big polynomials and nothing else, then LinearModelFit will work. And way faster with a guaranteed minimum too. $\endgroup$ – Julien Kluge Oct 11 '20 at 22:40
  • $\begingroup$ Okay, I take that back. LinearModelFit is way slower for such big polynomials. Sorry for that. $\endgroup$ – Julien Kluge Oct 11 '20 at 22:55
  • $\begingroup$ Some of the variiables are nonlinear. Its actually embedded polynomials of three running variables {u,v,w,E}, meaning that the each polynomial expansion terms itself have sum of few sech functions. My problem is that how to run in many processor simultaneoulsy to reduce computation time like in Fortran or other lannguages. Is there any script to do this? The problem is not with the starting values. $\endgroup$ – george Oct 11 '20 at 23:11