2
$\begingroup$

Suppose we have this equation:

$$ 2 - x g(z) f \left(x, \frac{\partial y}{\partial x}\right) = 3y $$

using initial condition $y = 2$ where $g = \left| \frac{3}{2-iz} \right|$ and $f = \frac{2x}{1-3\frac{\partial y}{\partial x}} $

I want to plot the contours of $ \frac{\partial y}{\partial x}$ within axes $x$ and $z$. How do I go about doing it?

I tried using $NDSolve$ but it doesn't quite work.

g := Abs[3 / (2 - iz)]
f := 2x / ( 1 - 3D[y[x,z],x] )
NDSolve [ {2-x*g*f == 3y[x,z] ,y[x,z]==2}, D[y[x,z],x], {x,0,1}, {z,0,1}  ]

Too long for a comment - Your answer works, but I improvised this to my current problem and it doesn't seem to work.. I want to find the contours of $ \frac{\partial T_e}{\partial P_{local}} $ in axes $P_{probe}$ against $w$ in the limit $P_{local} \rightarrow 0, T_e \rightarrow 0.2 $.

Clear["Global`*"]
C1 = 10^(-10);
C2 = 0.1*C1;
R = 50;
Tb = 0.1;
Geb = 5*10^-15;
Z0 = 50;
L[Te_] := 10^-9 + 10^-9*(Te - 0.1);
Zlcr[Te_, w_] := (1/R + 1/(I*L[Te]*w) + I*C1*w)^-1;
Zload[Te_, w_] := -I*w*C2 + Zlcr[Te, w];
\[CapitalGamma][Te_, w_] := (Zload[Te, w] - Z0)/(Zload[Te, w] + Z0);
x[Te_, w_] := Abs[\[CapitalGamma][Te, w]];
y[Te_, w_] := (Abs[\[CapitalGamma][Te, w]])^2;


eqn1 [Te_, Pprobe_, w_, Plocal_] := 1 - 2 Pprobe*D[x[Te, w], Plocal] ==  Geb*D[Te, Plocal]
sol = First@NDSolve [{eqn1[0.2, Pprobe, w, 0]},{D[Te, Plocal]},{Pprobe,0,10^(-15)}, {w,0,10^9}]

Plot3D[Evaluate@D[Te, Plocal] /.  sol, {Pprobe,0,10^(-15)}, {w,0,10^9} ]
$\endgroup$
4
$\begingroup$

Too small to post as comment, as I am not sure about your equations.

First, You have few syntax errors. 1) it is I not i, 2) Need space, as in I z and not iz 3) You are solving for y[x,z] and not D[y[x,z],x 4) You are using y[x, z] == 2 but y[x,z] 5) do not know what y=2 is initial conditions mean. You mean y[0,z]=2 or y[x,0]=2? Also, why write g as you did, is this the same as g=3/Sqrt[4+z^2] ?

If I understand what you have, here is an attempt:

Clear[y, x, z]
f = 2 x/(1 - 3 D[y[x, z], x]);
g = 3/Sqrt[4 + z^2];
eq = 2 - x g f == 3 y[x, z];
sol = First@NDSolve[{eq, y[0, z] == 2}, {y[x, z]}, {x, 0, 1}, {z, 0, 1}]
Plot3D[Evaluate@y[x, z] /. sol, {x, 0, 1}, {z, 0, 1}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Actually I realised it's simpler than it looks. What I meant was $y=2$ for all x and z. So The task would simply be to rearrange, and plot $\frac{\partial y}{\partial x}$ as a contour using x-z axes. $\endgroup$ – user44840 Jul 11 '14 at 9:46
  • $\begingroup$ What I meant was y=2 for all x and z how could this be? y[x,z] is the solution we are after? If you know that y[x,z]=2 for all x,y, then what are we solving for? You already have the solution? I must be missing something here. $\endgroup$ – Nasser Jul 11 '14 at 9:51
  • $\begingroup$ Ok this equation was derived earlier by differentiating implicitly with respect to x earlier. I want to find the contours of dy/dx given y =2 $\endgroup$ – user44840 Jul 11 '14 at 9:58
3
$\begingroup$

Try:

NDSolveValue[{2 - x*Abs[3/(2 - I z)]*2 x/(1 - 3 D[y[x, z], x]) == 
   3 y[x, z], y[0, z] == 2}, D[y[x, z], x], {x, 0, 1}, {z, 0, 1}]

Initial conditions need to be set at a specific point, the complex is I not i.

Then plot the derivative:

Plot3D[%, {x, 0, 1}, {z, 0, 1}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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