# How to get the partial derivative of the inverse functions?

Suppose I have the following relations: $$z = \cosh\mu\cos\theta,\quad x=\sinh\mu\sin\theta$$ It is easy to get $\frac{\partial z}{\partial\mu}=\sinh\mu\cos\theta$ either seen by eye or by using D[z[μ, θ], μ] command in Mathematica.

However, if I want to get $\frac{\partial\mu}{\partial z}$, it takes a bit work analytically, and I don't know if there is some convenient way using Mathematica. By the way, the result that I have calculated is: $$\frac{\partial\mu}{\partial z}=\frac{\cos\theta\,\mathrm{sech}\,\mu}{\cos^2\theta\tanh\mu+\sin^2\theta\coth\mu}$$

How can I verify this in Mathematica?

Here is one method of obtaining an expression equivalent to the one you derive by hand. We start by defining two functions, $f$ and $g$, which we consider to be functions of $(x,z)$. That is, we consider $\mu$ and $\theta$ to be functions of $(x,z)$. When we take the partial derivatives with regard to $z$ we tell Mathematica that $\mu$ and $\theta$ are functions of $(x,z)$.

f = Cosh[μ] Cos[θ];
g = Sinh[μ] Sin[θ];
df = D[f, z, NonConstants -> {μ, θ}]
dg = D[g, z, NonConstants -> {μ, θ}]

(*  -Cosh[μ] D[θ, z, NonConstants -> {θ, μ}] Sin[θ] +
Cos[θ] D[μ, z, NonConstants -> {θ, μ}] Sinh[μ]

Cosh[μ] D[μ, z, NonConstants -> {θ, μ}] Sin[θ] +
Cos[θ] D[θ, z, NonConstants -> {θ, μ}] Sinh[μ]  *)


We recognize that $df$ is the change in $z$ with regard to $z$ holding $x$ constant and $dg$ is the change in $x$ with regard to $z$ holding $x$ constant. In other words, we can set $df = 1$ and $dg = 0$ and solve for the derivatives $\partial\mu/\partial z$ and $\partial\theta/\partial z$. We can use Solve[] for this, but we must make a substitution first. We evaluate

rules =
{D[μ, z, NonConstants -> {θ, μ}] -> dμdz, D[θ, z, NonConstants -> {θ, μ}] -> dθdz};
eqns = {df == 1, dg == 0} /. rules;
soln = Solve[eqns, {dμdz, dθdz}] // First

(* {dμdz -> (Cos[θ] Sinh[μ])/(Cosh[μ]^2 Sin[θ]^2 + Cos[θ]^2 Sinh[μ]^2),
dθdz -> -((Cosh[μ] Sin[θ])/(Cosh[μ]^2 Sin[θ]^2 + Cos[θ]^2 Sinh[μ]^2))} *)


Finally, we want to show that the above expression gives us the same as by a hand calculation:

hand = Cos[θ] Sech[μ]/(Cos[θ]^2 Tanh[μ] + Sin[θ]^2 Coth[μ]);
(dμdz /. soln) == hand // Simplify

(* True *)


Define a rule for z

rulez = ToRules[z == Cosh[μ] Cos[θ]]

(*    {z -> Cos[θ] Cosh[μ]}   *)


Solve the equation for mu and differentiate

sol = Solve[Reduce[z == (z /. rulez) && Cos[θ] != 0, μ], μ]

(* {{μ ->
ConditionalExpression[-ArcCosh[z Sec[θ]] + 2 I π C[1], C[1] ∈ Integers]},
{μ ->
ConditionalExpression[ArcCosh[z Sec[θ]] + 2 I π C[1], C[1] ∈ Integers]}} *)

(* D[μ,z]  *)

s1 = Simplify[D[μ /. sol[[1]], z] /. rulez, C[1] ∈ Integers]

(*  -(Sec[θ]/(Sqrt[-1 + Cosh[μ]] Sqrt[1 + Cosh[μ]]))  *)


And the same with sol[[2]].

That's a bit different from your result.

Another approach:

sol = First @ Solve[
{Dt[z == Cosh[μ] Cos[θ]], Dt[x == Sinh[μ] Sin[θ]]},
{Dt[μ], Dt[θ]}
];

dμdz = Dt[μ] /. sol /. {Dt[x]->0, Dt[z]->1} //TeXForm


$\frac{\cos (\theta ) \sinh (\mu )}{\cos ^2(\theta ) \sinh ^2(\mu )+\sin ^2(\theta ) \cosh ^2(\mu )}$