# Problem with ForardDiff

**URL:** <https://discourse.julialang.org/t/problem-with-forarddiff/82412>\
**Category:** New to Julia\
**Tags:** package, forwarddiff\
**Created:** [June 8, 2022, 8:39am UTC](https://discourse.julialang.org/t/problem-with-forarddiff/82412 "2022-06-08T08:39:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikos\_Mourdoukoutas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nikos_mourdoukoutas/32/37006_2.png) [@Nikos\_Mourdoukoutas](https://discourse.julialang.org/u/Nikos_Mourdoukoutas)\
**Post date:** [June 8, 2022, 8:39am UTC](https://discourse.julialang.org/t/problem-with-forarddiff/82412/1 "2022-06-08T08:39:35Z")

</div>

I am trying to use ForwardDIff to compute the gradient of a function. My code is very simple:

```julia
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[1]*(K[1]*x[1]/(1+alpha[1]*K[1]*x[1]+alpha[2]*K[2]*x[2])) 
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?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 8, 2022, 8:42am UTC](https://discourse.julialang.org/t/problem-with-forarddiff/82412/2 "2022-06-08T08:42:00Z")

</div>

You need `gradient(f, x)`, not `f(x)`.
