title: How to implement gradient descent algorithms using partial derivatives?
body: <p>For this question, I want to use gradient descent to minimize the function value to zero for the function x^2 + y^2 with the point (1,1) as the initial starting point. However, I get this error when I try to run my code. I'm not sure why I get that error. Here is what I have so far. Can anyone please help me out? Thanks</p>
  <p>Error: xnew = x0-alpha*grad(x0, y0)</p>
  <p>TypeError: 'int' object is not callable</p>
  <pre><code>def f(x,y):
      return x**2 + y**2
  
  def dfdx(x,y):
      return 2*x
  def dfdy(x,y):
      return 2*y
  
  def grad(x,y):
      return [dfdx(x,y), dfdy(x,y)]
  
  x0 = 1
  y0 = 1
  
  def grad2(f, grad, x0, y0, alpha):
      iterations = 0
      maxIterations = 1000
      while iterations &lt; maxIterations:
          xnew = x0-alpha*grad(x0, y0)
          ynew = y0-alpha*grad(x0,y0)
          x0 = xnew
          y0 = ynew
          iterations += 1
      return xnew, ynew
  </code></pre>