Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a complicated parametric PDE that can be fitted to some data with NonlinearModelFit, but takes several hours to estimate the best values of the four free parameters. Currently, the code constrains these parameters ($kme,kmn,j$ and $eo$) to a realistic range as shown below;

NonlinearModelFit[Table[{i 10^-6, fp[[i]]}, {i, Length@fp}], {(Eb1 /. First[x])[kme, kmn, j, eo][r, 14400], 0.1 <= kme <= 30, 0 <= kmn <= 30, 0 <= j <= 1, 1 <= eo <= 100},  {kme, kmn, j, eo}, r]

I'm looking to reduce the time taken to evaluate this; I'm happy with 2 decimal places of accuracy, so I was wondering if either of the two following ideas would work;

  1. Reduce working precision - would reducing the working precision markedly speed up calculation? It seems to be the case; adding WorkingPrecision -> 3 returned a plausible looking answer in moments but warned me bout being below MinPrecision. I've now increased this to 5 and it's been running over 40 minutes with no output yet so I'm not convinced this is a good solution.

  2. Discretely specify parameter range; This option appeals most to me if it's possible: Instead of specifying the range of parameters, if is possible to list the values that Mathematica should try? I've attempted something along those lines where I've given the values in lists, like

     NonlinearModelFit[Table[{i 10^-6, fp[[i]]}, {i, Length@fp}], {(Eb1 /. First[x])[kme, kmn, j, eo][r, 14400], {kme, 0.1,30,0.1}, {kmn,0,30,0.1}, {j,0,1,0.01}, {eo,1,100,1},  {kme, kmn, j, eo}, r]
    

But this syntax generates errors. Is there a way to pass these options in NonlinearModelFit or better option for reducing the computational time? I'm open to any suggestion and happy to improve on my somewhat sparse Mathematica knowledge!

share|improve this question
    
It may help to refer viewers to the original question. I'm not sure if others will agree, but since your problem is multifaceted, it makes sense to break it up into multiple questions. –  bobthechemist Mar 17 at 14:31
    
A fair point! The original messy equation was here - mathematica.stackexchange.com/questions/43587/… ; thanks to help of @bobthechemist and Michael E2 I've got it working and reduced it to 4 parameters for now; while it works well, I'm open to suggestion on tricks for speeding up such calcs! –  DRG Mar 17 at 14:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.