0
$\begingroup$

I am trying to fit a collection of data with a fairly complicated function, and have been running into some errors. I am very new mathematica user, and am not really sure where I am going.

This is my code:

model = E^{{{p1 + {p2*log[x/p9]} + {p3*log[x/p9]*
            log[x/p9]}}^{p8} + {{p5 + {p6*log[x/p10]} + 
           p7*log[x/p10]*log[x/p10]}^{p8}}}^{1/p8}};

con1 = {p1 + {p2*log[x/p9]} + {p3*log[x/p9]*log[x/p9]}};

con2 = {p5 + {p6*log[x/p10]} + p7*log[x/p10]*log[x/p10]};

con3 = {{p1 + {p2*log[x/p9]} + {p3*log[x/p9]*
         log[x/p9]}}^{p8} + {{p5 + {p6*log[x/p10]} + 
        p7*log[x/p10]*log[x/p10]}^{p8}}};

fit = NonlinearModelFit[
  list02, {model}, {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10}, x]

And here are the errors:

NonlinearModelFit::nrlnum: The function value {-173929.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-183294.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-168182.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),<<45>>,-151868.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-97479.4+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),<<17>>} is not a list of real numbers with dimensions {67} at {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}.

NonlinearModelFit::nrlnum: The function value {-173929.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-183294.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-168182.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),<<45>>,-151868.+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),-97479.4+2.71828^(2. (1. +1. log[<<1>>]+1. Power[<<2>>])^1.),<<17>>} is not a list of real numbers with dimensions {67} at {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}.

When I include my constraints (con1, con2, con3) to try to prevent imaginary numbers, I get these errors:

Dot::dotsh: Tensors {{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<27>>,{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<17>>} and {{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<27>>,{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<17>>} have incompatible shapes.

NonlinearModelFit::nrlnum: The function value {{{{{2 Plus[<<3>>]^1.}}}},{{1. +1. log[1. x]+1. log[Times[<<2>>]]^2}},{{1. +1. log[1. x]+1. log[Times[<<2>>]]^2}}} is not a list of real numbers with dimensions {3} at {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}.

Dot::dotsh: Tensors {{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<27>>,{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<17>>} and {{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<27>>,{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},{{{{{{Plus[<<2>>]}}}}}},<<17>>} have incompatible shapes.

NonlinearModelFit::nrlnum: The function value {{{{{2 Plus[<<3>>]^1.}}}},{{1. +1. log[1. x]+1. log[Times[<<2>>]]^2}},{{1. +1. log[1. x]+1. log[Times[<<2>>]]^2}}} is not a list of real numbers with dimensions {3} at {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}.

What's going on, and how can I fix it?

$\endgroup$
1
  • 1
    $\begingroup$ What is log? Did you mean Log? All function in Mathematica start with a capital letter. Also, Log by default is natural log. $\endgroup$
    – Moo
    Jul 1 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.