I have a function that I am unable to recover a solution for. Here, 0.533... and 0.428... are the exact solutions for Rs[399]
and Rp[399]
, given a known nn1
and k
. I am using NMinimize
to recover the solution nn1
and k
originally used to calculate those exact values by minimizing the difference between the solution and the function itself (I have tested some direct solving methods, but none have worked as well). If the variables in NMinimize
are constrained close enough to the known solutions, it can find the global minimum. However, I am aiming to apply this solving method to problems where it would be unrealistic to constrain quite that closely (more realistic constraints are shown in the code below). Is there any way to further increase the likelihood that NMinimize
picks the global minimum? I have tried several different methods, but none I have tested have fixed the issue thus far.
Subscript[n, 1] = nn1 + (I*k)
NMinimize[{Abs[0.533600799853412 - Rs[399]],
0. == Abs[0.4285443166333881 - Rp[399]] && nn1 > 0.01 &&
k > 0.01 && nn1 < 50 && k < 50}, {nn1, k},
Method -> {"SimulatedAnnealing", "PerturbationScale" -> 20},
AccuracyGoal -> 20, PrecisionGoal -> 20]
The correct solution would be nn1 = 3.392905674418965
and k = 2.411816858393506
. Functions are shown below.
rs[\[Lambda]_] :=
(E^((4*I*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda])*
(Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] +
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*(Sqrt[(-Sin[\[Theta]]^2)*
Subscript[n, 0]^2 + Subscript[n, 1]^2] -
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 2]^2]) +
(Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] -
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*(Sqrt[(-Sin[\[Theta]]^2)*
Subscript[n, 0]^2 + Subscript[n, 1]^2] +
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 2]^2]))/
(E^((4*I*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda])*
(Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] -
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*(Sqrt[(-Sin[\[Theta]]^2)*
Subscript[n, 0]^2 + Subscript[n, 1]^2] -
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 2]^2]) +
(Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] +
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*(Sqrt[(-Sin[\[Theta]]^2)*
Subscript[n, 0]^2 + Subscript[n, 1]^2] +
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 + Subscript[n, 2]^2]))
Rs[\[Lambda]_] := rs[\[Lambda]]*Conjugate[rs[\[Lambda]]]
rp[\[Lambda]_] :=
((Cos[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda]] +
(I*Sec[\[Theta]]^2*
Sin[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda]]*
Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/Subscript[n, 1]^2)*
Subscript[n, 2]^2 +
((-Cos[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/
\[Lambda]])*Sec[\[Theta]]^2*
Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] -
(I*
Sin[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/
\[Lambda]]*Subscript[n, 1]^2)/
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 + Subscript[n, 2]^2])/
((Cos[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda]] -
(I*Sec[\[Theta]]^2*
Sin[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda]]*
Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/Subscript[n, 1]^2)*
Subscript[n, 2]^2 +
(Cos[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/\[Lambda]]*
Sec[\[Theta]]^2*
Sqrt[Cos[\[Theta]]^2*Subscript[n, 0]^2] -
(I*
Sin[(2*Pi*Subscript[d, 1]*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])/
\[Lambda]]*Subscript[n, 1]^2)/
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 +
Subscript[n, 1]^2])*
Sqrt[(-Sin[\[Theta]]^2)*Subscript[n, 0]^2 + Subscript[n, 2]^2])
Rp[\[Lambda]_] := rp[\[Lambda]]*Conjugate[rp[\[Lambda]]]
Variables are defined thus:
Subscript[n, 0] = 1;
Subscript[n, 2] = 1;
Subscript[d, 1] = 40;
\[Theta] = Pi/6;
Any input/suggestions are more than welcome! Thank you!
InputForm
prior to copy and paste into MSE. $\endgroup$nn1
andk
you need to assign values to the other parameters{d1, n0, n2, θ}
. $\endgroup$