gradient

Contents

gradient#

class pinnx.grad.gradient(fn, xs, y=None, *xi, order=1)[source]#

Compute the gradient dy/dx of a function y = f(x) with respect to x.

If order is 1, it computes the first derivative dy/dx.

Parameters:
  • fn (Callable) – Function to compute the gradient.

  • xs (Dict) – Inputs of the function.

  • y (Union[str, Sequence[str], None]) – The variable to differentiate.

  • xi (Union[str, Sequence[str], None]) – The variable to differentiate with respect to.

  • order (int) – The order of the gradient. Default is 1.

Returns:

dy/dx.