How do I subtract two contours?

Suppose I have this contour described by the equation the root $z$ of this equation $$\frac{1}{x^2 + y^2} + \frac{1}{xz} = 2y$$

Now suppose the equation is tweaked slightly, with an addition of $w$, where $w$ is a number: $$w + \frac{1}{x^2 + y^2} + \frac{1}{xz} = 2y$$

eq1[x_, y_, z_]  :=  1/(x + y^2) + 1/(x*z) == 2 y
ContourPlot[
z /. FindRoot[eq1[x, y, z], {z, 1}], {x, -5, 5}, {y, -5, 5}]

eq2[x_, y_, z_]  :=  2 + 1/(x + y^2) + 1/(x*z) == 2 y
ContourPlot[
z /. FindRoot[eq2[x, y, z], {z, 1}], {x, -5, 5}, {y, -5, 5}]

eq3[x_, y_, z_]  :=  4 + 1/(x + y^2) + 1/(x*z) == 2 y
ContourPlot[
z /. FindRoot[eq3[x, y, z], {z, 1}], {x, -5, 5}, {y, -5, 5}]


By visual inspection we see that the curves shift upwards as $w$ increases.

However, I need a better way to describe it. Is there a way to "differentiate the contour" to find the contour $\frac{\partial z}{\partial w}$?

Now suppose the equation is tweaked slightly, with an addition of $w$, where $w$ is a number.

Is there a way to "differentiate the contour" to find the contour $\frac{\partial z}{\partial w}$?

I tried "subtracting" the roots then plotting the contour, but mathematica can't seem to execute this:

eq1[x_, y_, z_] := 1/(x + y^2) + 1/(x*z) == 2 y
ContourPlot[
z /. FindRoot[eq1[x, y, z], {z, 1}], {x, -5, 5}, {y, -5, 5}]

eq2[x_, y_, z_] := 2 + 1/(x + y^2) + 1/(x*z) == 2 y
ContourPlot[
z /. FindRoot[eq2[x, y, z], {z, 1}], {x, -5, 5}, {y, -5, 5}]

sol[x_,y_] := FindRoot[eq2[x, y, z], {z, 1}] - FindRoot[eq1[x, y, z], {z, 1}]

ContourPlot[ sol[x,y], {x, -5, 5}, {y, -5, 5}]

• Dou you get what you need when you change the definition of sol[..] to sol[x_, y_] := (z /. FindRoot[eq2[x, y, z], {z, 1}]) - (z /. FindRoot[eq1[x, y, z], {z, 1}])?
– kglr
Aug 15, 2014 at 19:53

Are you wanting to do this numerically or is symbolically fine for you? If so how about implicit differentiation:

Solve[D[w + 1/(x^2 + y^2) + 1/(x z[w]) == 2y, w], z'[w]]

(* {{z'[w] -> x z[w]^2}} *)

• Also, I want to make the assumption that $\frac{\partial x}{\partial w} = \frac{\partial y}{\partial w} = 0$. Also, z'[w] is a function of x,y,z. Don't we have to specify a value of z in order to plot the contours in axes x,y? Jul 16, 2014 at 7:45