Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem creating MeanPredictionBands for my function which I fitted using NonlinearModelFit. I have a complex-valued function and I am fitting the real part of the function. Mathematica 8 gives me back a fitted function and with it the BestFitParameters. But as soon as I try to feed it the "MeanPredictionBands" command, it gives me back the following line:

Experimental`NumericalFunction::nnum: The function [...] is not a number at {fitparameters}.

I have also tried using the ComplexExpand function on the real part of my function, which still doesn't help with my situation. Has anybody encountered this particular problem before? All my variables are real, as are the fit parameters.

Thank you all for your help!

From the file linked in comment a reduced code sample that exhibits the same problem:

msymm2fit =  Re[0.145` mV^6 Log[-(0.5929`/mV^2)] + 12 b0V \[Nu]^2 + 8 bDV \[Nu]^2]

MyData2 = {{0.332, 0.807^2}, {0.386, 0.821^2}, {0.447, 0.855^2}};
MyError2 = {0.027, 0.011, 0.029};
MyFit2 = NonlinearModelFit[MyData2, msymm2fit, {mV, b0V, bDV}, \[Nu], 
  VarianceEstimatorFunction -> (1 &), Weights -> 1/(MyError2)^2, 
  Method -> {NMinimize, Method -> "DifferentialEvolution"}]


The inability to create the Bands apparently comes simply from taking the Real part of the function. I tried this out on another, really easy function. If you take


of a real valued function, this problem with creating the error bands goes away.

In my case, taking the Real part analytically (i.e. by hand) is not that easy, since it is created while i am fitting the data.

TL;DR Simply taking the Real part of any function will hinder Mathematica 8 from creating error bands from the fitted function.

share|improve this question
Helping you would be difficult if you won't mention either the function or the data... – J. M. Nov 21 '12 at 14:44
I have prepared a download-link for a very simplified version of the worksheet: Example.nb – Ludwig Nov 21 '12 at 15:11
@Ludwig It would be better if you could just paste the code in your question. – VLC Nov 21 '12 at 15:25
How does your comment about ComplexExpand cast light on your problem. Seems irrelevant to me. – m_goldberg Nov 21 '12 at 15:42
I added a reduced code sample from the file you linked. – Sjoerd C. de Vries Nov 21 '12 at 17:06

Please report this issue to Meanwhile observe that changing mysymm2fit to get rid of Re makes the issue go away:

msymm2fit = 
 0.145` mV^6 Log[(0.5929`/mV^2)] + 12 b0V \[Nu]^2 + 8 bDV \[Nu]^2

enter image description here

share|improve this answer
I removed about five lines of code from the OP's original function definition to get a usable, small example. I assume, but haven't checked this, that the Re is necessary in the original version and cannot be so easily removed there. BTW: did you just throw away a minus sign in the Log, or did I miss something? – Sjoerd C. de Vries Nov 21 '12 at 17:40
Yes, I just removed the minus sign using $\Re\left(\log(z)\right) = \log\left(|z|\right)$. – Sasha Nov 21 '12 at 17:47
This still does not solve my problem, because I cannot take the Real part by hand. So far, nothing I tried works, but I sent an email to Wolframs support, let's see what they come up with. – Ludwig Nov 22 '12 at 9:15

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.