Implicit differentiation : implicitdiff

### 5.10.3 Implicit differentiation : implicitdiff

implicitdiff is called with one of the following three sets of parameters :

1. expr, constr, depvars, diffvars
2. constr, [depvars], y, diffvars
3. expr, constr, vars, order_size=k, [pt]

Details on parameters :

- expr : differentiable expression f(x1,x2,…,xn,y1,y2,…,ym)
- constr : (list of) equality constraint(s) gi(x1,…,xn,y1,…,ym)=0 or vanishing expression(s) gi , where i=1,2,…,m
- depvars : (list of) dependent variable(s) y1,y2,…,ym , each of which may be entered as a symbol, e.g. yi, or a function of independent variable(s), e.g. yi(x1,x2,..,xn)
- diffvars : sequence of variables xi1,xi2,…,xik with respect to which is expr differentiated
- vars : independent and dependent variables entered as symbols in single list such that dependent variables come last, e.g. [x1,..,xn,y1,..,ym]
- y : (list of) dependent variable(s) yj1,yj2,…,yjl that need to be differentiated

Dependent variables y1,y2,…,ym are implicitly defined with m constraints in constr. By implicit function theorem, the Jacobian matrix of g=(g1,g2,…,gm) has to be full rank.

When calling implicitdiff, first two sets of parameters are used when specific partial derivative is needed. In the first case, expr is differentiated with respect to diffvars.

Input :

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

Output :

(2*x`^`3-5*x`^`2*y+11*y`^`3-8*y)/(5*x`^`2+11*y`^`2-8)

In the second case (elements of) y is differentiated. If y is a list of symbols, a list containing their derivatives will be returned. The following examples compute d y/d x .
Input :

implicitdiff(x`^`2*y+y`^`2=1,y,x)

Output :

-2*x*y/(x`^`2+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)

In the next example, d y/d x and d z/d x are computed.
Input :

implicitdiff([-2x*z+y`^`2=1,x`^`2-exp(x*z)=y],
[y(x),z(x)],[y,z],x)

Output :

[2*x/(y*exp(x*z)+1),
(2*x*y-y*z*exp(x*z)-z)/(x*y*exp(x*z)+x)]

For the third case of input syntax, all partial derivatives of order equal to order_size, i.e. k , are computed. If k=1 they are returned in a single list, which represents the gradient of expr with respect to independent variables. For k=2 the corresponding hessian matrix is returned. When k>2 , a table with keys in form [k1,k2,..,kn], where ∑i=1nki=k , is returned. Such key corresponds to

∂k f
∂ x1k1 ∂ x2k2 ⋯ ∂ xnkn
| .

Input :

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

Output :

[(2*x`^`3*z-5*x`^`2*y*z+11*y`^`3*z-8*y*z)/(5*x`^`2+11*y`^`2-8),
x*y]

Input :

implicitdiff(f,g,order_size=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 point (x=0,y=0,z) .
Input :

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

Output :

-2*z