# Find zeros of function in 2 variables

I have two functions $f(r,\phi)$, and $g(r,\phi)$.

What is the best way to find the curve in the plane $(x,y)$ or $(r,\phi)$, over which $f(r,\phi)=g(r,\phi)$?

I know how to plot it, using ContourPlot, but it seems that both Solve and FindRoot aren't suited to solve my problem. Any help?

Edit

My functions are:

Q00=1; a=1; k=0.01;

dQ1[r_, ϕ_] = Q00/2 (BesselK[0, k r]/BesselK[0, k a] + BesselK[1, k r]/BesselK[1, k a] Cos[ϕ]);

f[r_, ϕ_] := -(Q00/2) + dQ1[r, ϕ];
g[r_, ϕ_] = Q00 /2 Sin[ϕ] (a/r);


The range I am interested in is $a<r<L$, with $L=10$, and $0\leq\phi\leq 2\pi$

• Plot[Evaluate[ Interpolation@ Flatten[Cases[ ContourPlot[x^2 - x y == x^2 + y^2 - 1, {x, -1, 3}, {y, 0, 3}] // Normal, Line[x__] :> x, Infinity], 1]][ x], {x, -1, 3}] Nov 19, 2015 at 15:40
• With knowing the exact form of the functions it is easier to helping you. but you can try numberic solving. other form of those functions if be exist and so on. Nov 19, 2015 at 15:45
• I edited the question, maybe you could expand on that, thanks! Nov 19, 2015 at 15:48
• one of the functions is x^2 - x y == x^2 + y^2 - 1 what is another function? @usumdelphini Nov 19, 2015 at 15:53
• That is not my function, my functions are in the question, not in the comments. Nov 19, 2015 at 15:54

Just changing range of $\phi$ from $-\pi$ to $\pi$:

cp = ContourPlot[f[x, y] - g[x, y], {x, 0, 10}, {y, -Pi, Pi},
Contours -> {0}, ContourShading -> None];
fun = Cases[cp, Line[x__] :> x, -1];
pts = cp[[1, 1]];
t = pts[[fun[[1]]]];
{xd, yd} = Transpose[t];
xf = ListInterpolation[xd, {0, 1}]
yf = ListInterpolation[yd, {0, 1}]


You can recover for range 0 to $2 \pi$:

pp = ParametricPlot[Mod[{xf[t], yf[t]}, 2 Pi], {t, 0, 1},
Frame -> True, PlotRange -> {{0, 10}, {0, 2 Pi}},
AspectRatio -> Automatic]
Row[{pp, ContourPlot[f[x, y] - g[x, y], {x, 0, 10}, {y, 0, 2 Pi},
Contours -> {0}, ContourShading -> None,
AspectRatio -> Automatic]}]


Confirming (on $-\pi$ to $\pi$ range for convenience):

h[t_] := {xf[t], yf[t]};
p1 = Plot3D[{f[x, y], g[x, y]}, {x, 0, 10}, {y, -Pi, Pi},
Mesh -> False];
p2 = ParametricPlot3D[{xf[t], yf[t], f @@ h[t]}, {t, 0, 1},
PlotStyle -> {Red, Thickness[0.02]}];
Show[p1, p2]


maybe this give you some Idea :

Plot[Evaluate@
Table[Evaluate[f[x, y] /. {a -> 2, k -> 3}] -
Evaluate[g[x, y] /. {a -> 4}], {y, 1, 10}], {x, 0.01, 10}]


at least we can guess that for 0<x<10 the y answer should be between 0 and 4 for these parameter's value.

I know this is not an answer but I don't know how can I post my comments (I am under 50 reputation)

Looking at ContourPlot, we should be able to get an idea of where the roots are:

ContourPlot[
f[r, ϕ] == g[r, ϕ], {r, 1, 10}, {ϕ, 0, 2 Pi}]


We can then use With and Table to get the roots.

In[16]:= Table[
With[{r = r1},
FindRoot[f[r, ϕ] == g[r, ϕ], {ϕ, 0.5}]], {r1, 1, 4,
0.5}]

Out[16]= {{ϕ -> 0.785398}, {ϕ -> 0.694063}, {ϕ ->
0.575969}, {ϕ -> 0.434701}, {ϕ -> 0.268362}, {ϕ ->
0.0677875}, {ϕ -> -0.196409}}