I am trying to use ForwardDIff to compute the gradient of a function. My code is very simple:
buffer1 = 1. buffer2 = 1.0-buffer1 buffers = [buffer1; buffer2]; K0 = [[100., 200.] [0.01, 0.001]]; q_sat = [100, 150]; K = exp.(log.(K0) * buffers); f(x::Vector) = q_sat*(K*x/(1+alpha*K*x+alpha*K*x)) x = [0.5; 0.5] g = ForwardDiff.gradient(f(x), x)
The first lines are about defining some constants and then I define the function that takes in a vector and returns a real number. When trying to comput the gradient of f I get the error:
MethodError: objects of type Float64 are not callable
What could the problem be?