#Theoretical values
a = 5;
b = 4;
c = 3;

#Start values for refinement
m = 1;
n = 1;
o = 1;

#Lower and upper bounds
lb = [0;  0;  0];
ub = [10; 10; 10];

#Noice Level
s = 0.0;

#Load optim package
pkg load optim;

#Load optim package
pkg load parallel;

x=-100:100;
for i = 1:length(x)
  yTemp = a*x(i)^3 + b*x(i)^2 + c*x(i);
  y(i) = s*randn(1)*yTemp+yTemp;
endfor

x = x;
y = y;

options.parallel_local = true;

fun = @ (p, x) p(1)*x.^3 + p(2)*x.^2 + p(3)*x;
paramn = [m; n; o];
[param, f, cvg, outp] = nonlin_curvefit(fun, paramn, x, y, options);

a      = a
b      = b
c      = c
aRes   = param(1)
bRes   = param(2)
cRes   = param(3)

for i = 1:length(x)
  yRes(i) = aRes*x(i)^3 + bRes*x(i)^2 + cRes*x(i);
endfor

plot(x, y, ".k;Data points;", "markersize", 10, x, yRes, "r;Result;", "LineWidth", 3);