2
$\begingroup$

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$

$\endgroup$
14
  • $\begingroup$ 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}] $\endgroup$ Nov 19, 2015 at 15:40
  • $\begingroup$ 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. $\endgroup$
    – jack cilba
    Nov 19, 2015 at 15:45
  • $\begingroup$ I edited the question, maybe you could expand on that, thanks! $\endgroup$ Nov 19, 2015 at 15:48
  • $\begingroup$ one of the functions is x^2 - x y == x^2 + y^2 - 1 what is another function? @usumdelphini $\endgroup$
    – jack cilba
    Nov 19, 2015 at 15:53
  • $\begingroup$ That is not my function, my functions are in the question, not in the comments. $\endgroup$ Nov 19, 2015 at 15:54

3 Answers 3

3
$\begingroup$

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]}]

enter image description here

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]

enter image description here

$\endgroup$
2
$\begingroup$

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.

enter image description here

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

$\endgroup$
1
$\begingroup$

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}]

enter image description here

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}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.