I often do this sort of thing with Dt
. It works on equations, too. It basically gives you the multivariate differential
$$ {\partial f \over \partial x} \;dx + {\partial f \over \partial y} \;dy + \cdots = 0$$
To get $dy/dx$, set $dx = 1$ and any other differential other than $dy$ equal to zero. Then solve for $dy$ to get $dy = - ({\partial f /\partial x})/({\partial f / \partial y})$, which equals $dy/dx$, since we set $dx = 1$.
In Mathematica on the OP's example we get first:
Dt[Sin[y] + y == Sin[1/x] + x z]
(* Dt[y] + Cos[y] Dt[y] == z Dt[x] - (Cos[1/x] Dt[x])/x^2 + x Dt[z] *)
Now set the differentials to their appropriate values:
Dt[Sin[y] + y == Sin[1/x] + x z] /. {Dt[x] -> 1, Dt[z] -> 0}
(* Dt[y] + Cos[y] Dt[y] == z - Cos[1/x]/x^2 *)
Then solve for Dt[y]
:
dy = Dt[y] /. First@Solve[
Dt[Sin[y] + y == Sin[1/x] + x z] /. {Dt[x] -> 1, Dt[z] -> 0},
Dt[y]
]
(* (x^3 + x^2 z - Cos[1/x])/(x^2 (1 + Cos[y])) *)
To evaluate numerically, replace the variables with their values:
dy /. {x -> 0.3, y -> 0.2, z -> 0.5}
(* 5.91267 *)
Here's a function to carry out the procedure above for the derivative of an arbitrary variable y
with respect to a variable x
from an implicit function defined by an equation eqn
:
d[eqn_Equal, y_Symbol, x_Symbol] := Dt[y] /. First@Solve[
Dt[eqn] /. {Dt[x] -> 1, HoldPattern@Dt[Except[y]] -> 0},
Dt[y]
]
Examples:
d[Sin[y] + y == Sin[1/x] + x z, y, x]
(* (x^2 z - Cos[1/x])/(x^2 (1 + Cos[y])) *)
d[Sin[y] + y == Sin[1/x] + x z, y, x] /. {x -> 0.3, y -> 0.2, z -> 0.5}
(* 5.76116 *)
d[2 x + 3 y + 5 z + 7 w == 0, x, w]
(* -(7/2) *)
Sin[y]
, notsin[y]
and so forth. $\endgroup$