I am working to use the artificial potential field method for path planning of mobile robot; actually I found in one of references the following description about this method: the artificial potential field method uses a scalar function called the potential function. This function has two values, a minimum value, when the mobile robot is at the goal point and a high value on obstacles. The function slopes down towards the target point, so that the mobile robot can reach the target by following the negative gradient of the potential field. The potential force has two components: the first one is attractive force and second one is repulsive force. The goal position generates an attractive force which makes the mobile robot move towards it while obstacles produce a repulsive force, the combination of the attractive force to the destination and the repulsive forces away from the obstacles drive the mobile robot in a safe path to the target point The attractive potential takes the form: Uatt (q)=1/2 * ζ * d2 (q,qgoal) … (1) Where ζ is proportional coefficient , d(q,qgoal) is the Euclidean distance between the mobile robot q and the position of the goal point qgoal. The attractive force on robot is determined as the negative gradient of attractive potential field and takes the following form Fatt (q)=-∇Uatt (q) =- ζ (q - qgoal) …(2) Fatt(q) is a vector directed toward qgoal with magnitude linearly related to the distance from q to qgoal. The repulsive function is defined as : Urep (q) = 1/2 * ƞ * [1/d(q,qobs) - 1/d0 ]2 ........... if d(q,qobs )≤ d0 ... (3) Where q is the robot position and qobs is the obstacle position. d0 is the positive constant denoting the distance of influence of the obstacle. d(q,qobs) The distance between the mobile robot and obstacle. ƞ is the proportional coefficient. The repulsive force is the negative gradient of this repulsive potential fields function. Frep (q)=-∇Urep (q) = ƞ * [(1/d(q,qobs ) - 1/d0] * [(q-qobs)/ d3(q,qobs)] ......... if d(q,qobs )≤ d0 ... (4) My question is about equations 2 and 4 which they represent the negative gradient of equations 1 and 3 respectively, as you know that negative gradient of function is the derivative of the function, but when I am trying to derivative equations 1 and 3 that didn't give the same result in the equations 2 and 4 , so could anyone help me in the problem?