Error while running numderivative when passing y as some output constant
Reported by harpreet singh
Originally assigned to Paul BIGNIER
BUG DESCRIPTION:
----------------
numderivative stores 'y' as an output in numderivative_evalf now when the function again calls 'fun' the value of 'y' is changed. I think its because at line 8 in numderivative_evalf will update 'y' and all the variables are global so next time when it calls 'fun' it will give some error.
ERROR LOG:
----------
Inconsistent multiplication.
at line 24 of function numderivative_deriv1 called by :
at line 137 of function numderivative called by :
z = numderivative(fun,x)
at line 9 of exec file called by :
exec('/home/harpreet/numderivative_bug.sci', -1)
HOW TO REPRODUCE THE BUG:
-------------------------
t = linspace(-4,4);
y = 1/sqrt(2*%pi)*exp(-t.^2/2);
function out = fun (x)
out = x(1)*exp(-t).*exp(-exp(-(t-x(2)))) - y
endfunction
for i = 1:10
x = 5*rand(1,2)
z = numderivative(fun,x)
end
OTHER INFORMATION:
------------------