# Implicit differentiation: implicitdiff

### 5.19.5 Implicit differentiation: implicitdiff

The implicitdiff command can differentiate implicitly defined functions or expressions containing implicitly defined functions. It has three different calling sequences.

To implicitly differentiate dependent variables:

- implicitdiff takes four arguments:
  - constraints, an equation or list of equations which implicitly define the dependent variables as functions of the independent variables; these will be of the form

    gi(x1,…,xn,y1,…,ym)=0

    for i=1,2,…,m, where x1,ldots,xn are the independent variables and y1,…,ym are the dependent variables.
  - depvars, the list of dependent variables, where each dependent variable can optionally be written as a function of the xi or the name written as a function of the independent variables yi(x1,…,xn). If there is only one dependent variable, this can be omitted.
  - y, a dependent variable or a list of dependent variables to be differentiated.
  - diffvars, a sequence of independent variables xi1,…,xik with respect to differentiate.
- implicitdiff(constraints ⟨,depvars ⟩],y,diffvars) returns the derivative (or list of derivatives) of y with respect to diffvars.

#### Examples.

- Input:
  implicitdiff(x^2*y+y^2=1,y,x)
  Output:

  −

  2 x y
  x2+2 y

- Input:
  implicitdiff([x^2+y=z,x+y*z=1],[y(x),z(x)],y,x)
  Output:

  −2 x y−1
  y+z

To find a specified derivative of an expression containing implicitly defined functions:

- implicitdiff takes four arguments:
  - expr, a differentiable expression involving independent variables x1,x2,…,xn and dependent variables y1,y2,…,ym.
  - constraints, an equation or list of equations which implicitly define the dependent variables as functions of the independent variables; these will be of the form

    gi(x1,…,xn,y1,…,ym)=0

    for i=1,2,…,m.
  - depvars, the dependent variable or list of dependent variables, where each dependent variable can either be the variable name yi or the name written as a function of the independent variables yi(x1,…,xn)).
  - diffvars, a sequence of independent variables xi1,…,xik with respect to which expr is differentiated.
- implicitdiff(expr,implicitdef,depvars,diffvars) returns the expression expr differentiated with respect to diffvars.

#### Example.

Input:

implicitdiff(x*y,-2x^3+15x^2*y+11y^3-24y=0,y(x),x)

Output:

2 x3−5 x2 y+11 y3−8 y
5 x2+11 y2−8

To find all kth order derivatives of an expression involving implicitly defined functions:

- implicitdiff takes four mandatory arguments and one optional argument:
  - expr, a differentiable expression involving independent variables x1,x2,…,xn and dependent variables y1,y2,…,ym.
  - constraints, an equation or list of equations which implicitly define the dependent variables as functions of the independent variables; these will be of the form

    gi(x1,…,xn,y1,…,ym)=0

    for i=1,2,…,m.
  - vars, a list [x1,…,xn,y1,…, ym] of the independent and dependent variables entered as symbols in single list such that dependent variables come last.
  - order=k, where k is the order of the derivatives to be taken.
  - Optionally, a, a point where the partial derivatives should be evaluated at.
- implicitdiff(expr,implicitdef,vars,order=k ⟨,a⟩) returns all partial derivatives of order k. If k=1 they are returned in a single list, which represents the gradient of expr with respect to independent variables. If k=2 the corresponding Hessian matrix is returned (see Section 5.21.3). If k>2, a table with keys in form [k1,k2,..,kn], where ∑i=1nki=k, is returned. Such a key corresponds to

  ∂k f
  ∂ var1k1 ∂ var2k2 ⋯ ∂ varnkn

  .

#### Examples.

- Input:

  f:=x*y*z; g:=-2x^3+15x^2*y+11y^3-24y=0;
  implicitdiff(f,g,[x,z,y],order=1)

  Output:

  ⎡
  ⎢
  ⎢
  ⎣

  2 x3 z−5 x2 y z+11 y3 z−8 y z
  5 x2+11 y2−8

  ,x y

  ⎤
  ⎥
  ⎥
  ⎦

- Input:
  implicitdiff(f,g,[x,z,y],order=2,[1,-1,0])
  Output:

  ⎡
  ⎢
  ⎢
  ⎢
  ⎢
  ⎢
  ⎢
  ⎢
  ⎣

  64
  9

  −

  2
  3

  −

  2
  3

  0

  ⎤
  ⎥
  ⎥
  ⎥
  ⎥
  ⎥
  ⎥
  ⎥
  ⎦

- In the next example, the value of ∂4 f/∂ x4 is computed at the point (x=0,y=0,z).
  Input:

  pd:=implicitdiff(f,g,[x,z,y],order=4,[0,z,0]);
  pd[4,0]

  Output:

  −2 z