Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am struggling with using Fit to fit a (linear combination of a) list of functions, that are calculated using matrices. It seems Mathematica internally uses parallel evaluation, which messes up the function's matrix dimensions (as they're both represented by the same underlying type: a List).

f[x_]:={(1,4) vector}.{(4,4) matrix}.{(4,1) vector}

Plugging this into Fit results in Tensors of incompatible form in the function Dot (ie the vector/matrix dot product). Or the design matrix is not rectangular.

share|improve this question
Do you have to use delayed evaluation of the matrices? Could you not just use f[x_]=... –  Mikael Öhman Nov 9 '11 at 14:34
Mikael: does the function still work as a function then? The variables change color, and I'm worried what other implications could arise... –  rubenvb Nov 9 '11 at 14:38
It still works as a function, only all its content is evaluated as you declare the function (i.e. all the dot products will be performed right away) –  Mikael Öhman Nov 9 '11 at 14:39
Mikael: well, it doesn't remove the problem unfortunately :( Maybe something else is wrong. I'll see to providing a simple reduction of what I have so people can see if they can find what's wrong. –  rubenvb Nov 9 '11 at 15:34
It is difficult to guess what is happening without seeing a more complete code sample. Without it I can only suggest that you try using f[x_?NumericQ] := –  Mr.Wizard Nov 14 '11 at 6:00

Your Answer


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

Browse other questions tagged or ask your own question.