0
$\begingroup$

I'm trying to solve a simultaneous equations for $n$ and $k$. These 2 are functions of $w$. Then, I'd like to plot these functions dependent of $w$, but the plot shows nothing. Here is my code:

w0 = 10^16;
l = 10^14;
e0 = 1;
m = 0.02;
N1 = 10^28;
B = (w0^2 - w^2)^2 - l^2 w^2;
A = (N1 E^2)/ m e0;
sol = Solve[{n^2 - k^2 == 1 + A (w0^2 - w^2)/B, 2 n k == A l w/B}, {n,
 k}];
Plot[Evaluate[n[w] /. sol], {w, 10^15, 10^17}, PlotRange -> All]

Also after I evaluate sol I get the error below:

"Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result."

I'm really stuck, would appreciate your help.

$\endgroup$
1
$\begingroup$

I'm not sure why you feel you need to incorporate n[w] in Plot. The solutions given for n are already expressed in terms of w.

If you simply evaluate Plot[Evaluate[n /. sol], {w, 10^15, 10^17}, PlotRange -> All] it produces

Blockquote

Also, evaluating Plot[k /. sol // Evaluate, {w, 10^15, 10^17}, PlotRange -> All] produces

Blockquote

As far as the Solve::ratnz message is concerned, it is not an error; please see this

$\endgroup$
  • $\begingroup$ thank you for your help! my mistake was exactly that! and I fixed the error! $\endgroup$ – saeedeh Mar 21 '18 at 11:19
1
$\begingroup$

Yo have two parameters to plot $n$ and $k$ as functions of $w$:

Plot[Evaluate[{n, k} /. sol], {w, 9.949 10^15, 9.951 10^15}, 
PlotRange -> All, Exclusions -> None, ExclusionsStyle -> Dashed, 
PlotPoints -> 40]

However, I suggest you rescale the frequency $w$ to avoid numerical problems when plotting.

enter image description here

$\endgroup$
  • $\begingroup$ thank you very much! $\endgroup$ – saeedeh Mar 21 '18 at 11:18

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.