0
$\begingroup$

I would like to solve

nf = 1.9;
ns = 1.89;
c = 3*^8;
H = 1.250*^-6;
B = Table[Sqrt[ (A/c)^2 nf^2 - (FindRoot[Tan[k*H/2]==Sqrt[(A/c)^2 (nf^2 -ns^2) - k^2]/k, {k,20}][[1, 2]])^2], {A, 0, 3*^15}]
ListPlot[B]

Am I missing something really obvious??

$\endgroup$
  • $\begingroup$ Do you also get a SystemException["MemoryAllocationFailure"]? My first step would be to look at the equation inside FindRoot. This function looks very weird and doesn't seem to have a root at all. $\endgroup$ – halirutan Jun 26 '18 at 21:25
  • 2
    $\begingroup$ Note that Table[..., {A, 0, 3*^15}] implies evaluation of all values of $A$ between 0 and $3\times 10^{15}$ with a step of $1$. That seems unreasonable. If each evaluation took only 1 ms, the whole exercise would take on the order of 100,000 years, not to mention immense amounts of memory. Start by setting a reasonable step size, e.g. {A, 0, 3*^15, 1*^14}. You will at least get some results then. $\endgroup$ – MarcoB Jun 26 '18 at 21:45
1
$\begingroup$

You have many many syntactic errors:

c = 3*^8 makes no sense. Presumably you mean c = 3 10^8

H = 1.250*^-6 is wrong in several ways. Presumably you mean H = 1.250 10^(-6)

You must assign f.

You should use a large step size (as @MarcoB writes). And so on.

You should simplify by substituting values whenever possible.

You should avoid using upper-case letters to label a variable ALWAYS.

You need semicolon at the end of each functional line.

A start:

f = 7;
c = 3 10^8;
h = 1.250 10^(-6);
b = Table[
  Sqrt[(a/c)^2 1.9 f^2 - (FindRoot[
        Tan[k h/2] == Sqrt[(a/c)^2 (1.9^2 - 1.89^2) - k^2]/k, 
        {k, 20}][[1, 2]])^2], 
        {a, 0, 3 10^(15), 10^(14)}];
ListPlot[b]
$\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.