Multivariable calculus

Partial Derivatives of ln(1 + e^(xy))

For f(x, y) = ln(1 + e^(xy)), the partial with respect to x is y e^(xy)/(1 + e^(xy)) and the partial with respect to y is x e^(xy)/(1 + e^(xy)). The chain rule runs twice, once for the logarithm and once for the exponent xy.

ln ⁣(1+exy)\ln\!\left(1+e^{xy}\right)
yexy1+exy\frac{y\,e^{xy}}{1+e^{xy}}
xexy1+exy\frac{x\,e^{xy}}{1+e^{xy}}

Peel the layers from the outside in

There are three layers: a logarithm, then 1+exy1 + e^{xy}, then the exponent xyxy. Work outward to inward. With u=1+exyu = 1+e^{xy}, the logarithm gives uxu\frac{u_x}{u}, and uxu_x needs the chain rule once more, on exye^{xy} with yy held fixed.

ux=exyx(xy)=yexy\frac{\partial u}{\partial x} = e^{xy}\cdot\frac{\partial}{\partial x}(xy) = y\,e^{xy}
fx=yexy1+exy,fy=xexy1+exy\frac{\partial f}{\partial x} = \frac{y\,e^{xy}}{1+e^{xy}}, \qquad \frac{\partial f}{\partial y} = \frac{x\,e^{xy}}{1+e^{xy}}

At (0,2)(0,2) the exponent is 00, so exy=1e^{xy} = 1 and the xx partial is 22=1\frac{2}{2} = 1 while the yy partial is 02=0\frac{0}{2} = 0. At (1,2)(1,2) the xx partial is 2e21+e21.762\frac{2e^{2}}{1+e^{2}} \approx 1.762.

The mistake: stopping after one chain rule

  • Writing y1+exy\frac{y}{1+e^{xy}} keeps the inside derivative of the exponent but forgets that exye^{xy} itself belongs in the numerator, since x(1+exy)=yexy\frac{\partial}{\partial x}\left(1+e^{xy}\right) = y\,e^{xy}.
  • Writing exy1+exy\frac{e^{xy}}{1+e^{xy}} stops one layer too early and never differentiates the exponent xyxy, so the factor yy is missing.
  • Writing 11+exy\frac{1}{1+e^{xy}} applies only the logarithm rule and skips both inner steps.

Pick a point where the wrong versions separate from the right one. At (1,2)(1,2) the correct xx partial is about 1.7621.762, while the version that skips the exponent gives about 0.8810.881, exactly half. A single well-chosen test point catches this.

The softplus and its logistic slope

Write t=xyt = xy. Then f=ln(1+et)f = \ln(1+e^{t}), the softplus function, and its one-variable derivative is the logistic function, because dividing the numerator and denominator by ete^{t} turns et1+et\frac{e^{t}}{1+e^{t}} into 11+et\frac{1}{1+e^{-t}}.

fx=yσ(xy),σ(t)=11+et\frac{\partial f}{\partial x} = y\,\sigma(xy), \qquad \sigma(t) = \frac{1}{1+e^{-t}}

That factor is always between 00 and 11, so the size of each partial is controlled by the frozen variable out front. The gradient vanishes only at the origin, where both xx and yy are zero, and the argument 1+exy1+e^{xy} is always greater than 11, so nothing here is ever undefined.

Frequently asked questions

Is ln(1 + e^(xy)) ever undefined?

No. The term e^(xy) is positive, so the argument 1 + e^(xy) is always greater than 1 and the logarithm is defined at every point, along with both partial derivatives.

Why does the logistic function appear in the answer?

Because the factor e^(xy)/(1 + e^(xy)) equals 1/(1 + e^(-xy)), which is the logistic sigmoid. It is the derivative of the softplus function ln(1 + e^t) evaluated at t = xy.