1

I have solved two equations with two unknowns and confined my answer in just ten answers. The unknowns are n and k, and I want to make histogram for them separately, but don't know how to separate the n and k? My code is like this:

d = 2/100;
lambda = (1.67)*10^(-4);
alpha = Exp[-2*Pi*k*d/lambda];
delta = 4*Pi*n*d/lambda;
R = ((n - 1)^2 + k^2)/((n + 1)^2 + k^2);
Rp = 0.133;
Tp = 0.601;
pts = Table[
  FindRoot[{R (1 + (alpha)^4 - 2*(alpha)^2*Cos[delta])/(1 - 
         2*(alpha)^2*R*Cos[delta] + (alpha)^4*R^2) == 
     Rp, ((alpha)^2*(1 - R)^2)/(1 - 
        2*(alpha)^2*R*Cos[delta] + (alpha)^4*R^2) == Tp}, {n, 
    RandomReal[{1.5, 1.7}]}, {k, RandomReal[{0, 0.02}]}], {10}]
Grid[pts]

and what I got is

{n -> 1.664, k -> 0.0002223}, {n -> 1.609, 
  k -> 0.0002249}, {n -> 1.669, k -> 0.0002221}, {n -> 1.597, 
  k -> 0.0002255}, {n -> 1.568, k -> 0.0002268}, {n -> 1.592, 
  k -> 0.0002257}, {n -> 1.646, k -> 0.0002232}, {n -> 1.664, 
  k -> 0.0002223}, {n -> 1.568, k -> 0.0002268}, {n -> 1.663, 
  k -> 0.0002224}}  
bbgodfrey
  • 61,439
  • 17
  • 89
  • 156
Ela
  • 13
  • 4

1 Answers1

2

Have a look at ReplaceAll (/.) and Applying Transformation Rules

Your first output and the Suggesti0ns Bar giving you more options

enter image description here

apply rules to variables is giving you {k, n} /. pts, i.e. ReplaceAll, smart!

{{0.000221347, 1.68536}, {0.000225873, 1.58824}, {0.000223318, 1.64348}, {0.000224683, 1.61414}, {0.000226803, 1.56781}, {0.000225303, 1.60069}, {0.00022273, 1.65605}, {0.000214519, 1.82759}, {0.00022371, 1.6351}, {0.000223122, 1.64767}}

Use this list for further evaluations

{k, n} /. pts

ListPlot[%]

enter image description here

Histogram[n /. pts]

enter image description here