2
$\begingroup$

I have been running NMaximizeover a list of 100 two dimensional functions, over the variables $\alpha$ ad $\chi$. My ultimate final command is of the form:

Optimzation[α_, χ_, ϕ_, θ_] = 
 NMaximize[{#, 0 <= α <= 2 π, 
  0 <= χ <= π}, {{α, 0, 1}, {χ, 1, 2}}, 
   WorkingPrecision -> MachinePrecision, MaxIterations -> 1000, 
    PrecisionGoal -> 5] & /@ 
     DifferenceProbability2[α, χ, ϕ, θ]

Ignore $\theta$ and $\phi$; they're fixed. Now, I expect the optimized value to be between 0 and 1 for $\alpha$ and 1 and 2 for $\chi$. That's how I have defined the initial range in which to start the search for the globa maxima. The problem is that I have been getting wrong results -- local minima, local maximas -- because the graph dynamically changes as the list proceeds and the global maxima seems to go outside of the initial specified range.

Ideally, I would want to run the optimization as follows: during each step, the command NMaximize should update the range between the which to start searching for the maximia based on the result of the optimal values for the previous optimization. For example, if entry 67 has optimal values 1.1 and 2.3 for $\alpha$ and $\chi$, I'd want the initial range for the optimization for entry 68 to be an interval around 1.1 and 2.3; I'm not sure whether taking a large or small interval would be better. More than that, I don't know how to run such a recursive command. Suggestions?

I can provide the data for the list over which I am optimizing if that'll help answer this questions.


Edit:

{-0.99554 + 
Re[(0.250011 + 4.71349*10^-19 I) Cos[χ/
  2]^4 + (0.245566 - 5.611*10^-8 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.245566 + 5.611*10^-8 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.250011 + 1.36841*10^-18 I) Sin[χ/
  2]^4 + (0.248881 - 0.000383199 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.248881 + 0.000383199 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.248881 + 0.000383143 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.248881 - 0.000383143 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.249989 - 
   5.96311*10^-19 I) Sin[χ]^2], -0.986203 + 
Re[(0.250121 - 1.33665*10^-18 I) Cos[χ/
  2]^4 + (0.236488 - 1.05*10^-6 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.236488 + 1.05*10^-6 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.250126 - 3.43863*10^-19 I) Sin[χ/
  2]^4 + (0.246509 - 0.00224937 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.246509 + 0.00224937 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.246512 + 0.00224827 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.246512 - 0.00224827 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.249876 + 
   7.58942*10^-19 I) Sin[χ]^2], -0.976535 + 
Re[(0.25042 + 2.49366*10^-18 I) Cos[χ/
  2]^4 + (0.227479 - 4.32862*10^-6 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.227479 + 4.32862*10^-6 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.250437 - 3.03577*10^-18 I) Sin[χ/
  2]^4 + (0.244001 - 0.0053767 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.244001 + 0.0053767 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.244009 + 0.00537195 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.244009 - 0.00537195 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.249571 + 
   2.1684*10^-18 I) Sin[χ]^2], -0.96782 + 
Re[(0.25093 - 7.58942*10^-19 I) Cos[χ/
  2]^4 + (0.219845 - 9.69112*10^-6 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.219845 + 9.69112*10^-6 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.250969 - 8.67362*10^-19 I) Sin[χ/
  2]^4 + (0.241678 - 0.00920981 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.241678 + 0.00920981 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.241695 + 0.00919837 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.241695 - 0.00919837 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.249051 + 
   2.38524*10^-18 I) Sin[χ]^2], -0.960089 + 
Re[(0.251648 + 3.50665*10^-18 I) Cos[χ/
  2]^4 + (0.213594 - 0.0000154087 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.213594 + 0.0000154087 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.25172 - 2.20561*10^-18 I) Sin[χ/
  2]^4 + (0.239552 - 0.0134097 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.239552 + 0.0134097 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.239582 + 0.0133894 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.239582 - 0.0133894 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.248316 + 
   1.95156*10^-18 I) Sin[χ]^2], -0.953136 + 
Re[(0.252567 - 3.72039*10^-20 I) Cos[χ/
  2]^4 + (0.208505 - 0.0000188652 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.208505 + 0.0000188652 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.252685 - 2.1312*10^-18 I) Sin[χ/
  2]^4 + (0.237576 - 0.0177966 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.237576 + 0.0177966 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.237621 + 0.0177668 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.237621 - 0.0177668 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.247374 - 
   1.0842*10^-18 I) Sin[χ]^2], -0.946766 + 
Re[(0.253677 - 2.34804*10^-18 I) Cos[χ/
  2]^4 + (0.204367 - 0.0000169664 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.204367 + 0.0000169664 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.253856 + 1.26384*10^-18 I) Sin[χ/
  2]^4 + (0.235701 - 0.0222709 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.235701 + 0.0222709 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.235765 + 0.0222329 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.235765 - 0.0222329 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.246234 + 
   2.81893*10^-18 I) Sin[χ]^2], -0.940826 + 
Re[(0.254969 + 5.99712*10^-18 I) Cos[χ/
  2]^4 + (0.201016 - 6.35988*10^-6 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.201016 + 6.35988*10^-6 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.255228 - 1.2936*10^-17 I) Sin[χ/
  2]^4 + (0.23389 - 0.0267728 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.23389 + 0.0267728 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.233977 + 0.0267299 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.233977 - 0.0267299 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.244901 + 
   4.77049*10^-18 I) Sin[χ]^2], -0.935202 + 
Re[(0.256435 + 4.73329*10^-18 I) Cos[χ/
  2]^4 + (0.19833 + 0.0000164411 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.19833 - 0.0000164411 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.256797 - 4.73329*10^-18 I) Sin[χ/
  2]^4 + (0.232116 - 0.031263 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.232116 + 0.031263 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.23223 + 0.0312206 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.23223 - 0.0312206 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.243384 - 
   5.42101*10^-18 I) Sin[χ]^2], -0.929812 + 
Re[(0.258065 + 3.03577*10^-18 I) Cos[χ/
  2]^4 + (0.196216 + 0.0000549814 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.196216 - 0.0000549814 I) E^(2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.258558 - 1.21431*10^-17 I) Sin[χ/
  2]^4 + (0.230357 - 0.0357137 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.230357 + 0.0357137 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.230503 + 0.0356793 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.230503 - 0.0356793 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.241688 + 
   3.46945*10^-18 I) Sin[χ]^2], -0.924594 + 
 Re[(0.259851 + 5.56344*10^-18 I) Cos[χ/
  2]^4 + (0.194603 + 0.000112814 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.194603 - 0.000112814 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.260507 - 9.46657*10^-18 I) Sin[χ/
  2]^4 + (0.2286 - 0.040104 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.2286 + 0.040104 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.228781 + 0.0400869 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.228781 - 0.0400869 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.239821 + 
   4.33681*10^-19 I) Sin[χ]^2], -0.919501 + 
Re[(0.261782 - 5.20417*10^-18 I) Cos[χ/
  2]^4 + (0.193436 + 0.000193462 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.193436 - 0.000193462 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.26264 + 3.46945*10^-18 I) Sin[χ/
  2]^4 + (0.226833 - 0.0444171 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.226833 + 0.0444171 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.227055 + 0.0444287 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.227055 - 0.0444287 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.237789 - 
   1.73472*10^-18 I) Sin[χ]^2], -0.914499 + 
 Re[(0.263849 + 1.73472*10^-18 I) Cos[χ/
  2]^4 + (0.192671 + 0.000300394 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.192671 - 0.000300394 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.264953 + 6.93889*10^-18 I) Sin[χ/
  2]^4 + (0.225047 - 0.0486391 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.225047 + 0.0486391 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.225317 + 0.0486926 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.225317 - 0.0486926 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.235599 - 
   1.73472*10^-18 I) Sin[χ]^2], -0.909561 + 
Re[(0.266041 - 5.12976*10^-18 I) Cos[χ/
  2]^4 + (0.192269 + 0.000437004 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.192269 - 0.000437004 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.267443 - 9.4177*10^-19 I) Sin[χ/
  2]^4 + (0.223237 - 0.0527581 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.223237 + 0.0527581 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.223561 + 0.0528682 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.223561 - 0.0528682 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.233258 + 
   3.90313*10^-18 I) Sin[χ]^2], -0.904668 + 
Re[(0.268348 - 4.41122*10^-18 I) Cos[χ/
  2]^4 + (0.1922 + 0.000606591 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.1922 - 0.000606591 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.270105 - 1.64055*10^-17 I) Sin[χ/
  2]^4 + (0.221398 - 0.0567637 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.221398 + 0.0567637 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.221783 + 0.0569468 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.221783 - 0.0569468 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.230774 + 
   8.23994*10^-18 I) Sin[χ]^2], -0.899804 + 
Re[(0.270756 + 9.54098*10^-18 I) Cos[χ/
  2]^4 + (0.192437 + 0.000812345 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.192437 - 0.000812345 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.272936 - 2.77556*10^-17 I) Sin[χ/
  2]^4 + (0.219527 - 0.0606468 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.219527 + 0.0606468 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.219982 + 0.0609208 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.219982 - 0.0609208 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.228154 + 
   1.04083*10^-17 I) Sin[χ]^2], -0.894957 + 
Re[(0.273256 - 1.12757*10^-17 I) Cos[χ/
  2]^4 + (0.192957 + 0.00105734 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.192957 - 0.00105734 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.275932 + 2.08167*10^-17 I) Sin[χ/
  2]^4 + (0.217621 - 0.0643991 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.217621 + 0.0643991 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.218154 + 0.0647831 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.218154 - 0.0647831 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.225406 + 
   1.73472*10^-18 I) Sin[χ]^2], -0.890119 + 
Re[(0.275835 + 3.39504*10^-18 I) Cos[χ/
  2]^4 + (0.193737 + 0.00134453 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.193737 - 0.00134453 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.279088 - 5.99712*10^-18 I) Sin[χ/
  2]^4 + (0.21568 - 0.0680136 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.21568 + 0.0680136 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.216301 + 0.0685278 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.216301 - 0.0685278 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.222538 - 
   4.33681*10^-19 I) Sin[χ]^2], -0.885283 + 
Re[(0.27848 - 1.30104*10^-17 I) Cos[χ/
  2]^4 + (0.194759 + 0.00167671 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.194759 - 0.00167671 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.282402 - 2.77556*10^-17 I) Sin[χ/
  2]^4 + (0.213703 - 0.0714836 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.213703 + 0.0714836 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.214422 + 0.0721495 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.214422 - 0.0721495 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.219559 + 
   1.73472*10^-17 I) Sin[χ]^2], -0.880446 + 
Re[(0.281179 - 7.44079*10^-20 I) Cos[χ/
  2]^4 + (0.196004 + 0.00205657 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.196004 - 0.00205657 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.285868 - 2.52768*10^-18 I) Sin[χ/
  2]^4 + (0.211689 - 0.0748035 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.211689 + 0.0748035 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.212517 + 0.0756431 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.212517 - 0.0756431 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.216477 - 
   1.0842*10^-17 I) Sin[χ]^2], -0.875603 + 
Re[(0.283919 + 2.52768*10^-18 I) Cos[χ/
  2]^4 + (0.197455 + 0.00248662 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.197455 - 0.00248662 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.289483 - 2.52768*10^-18 I) Sin[χ/
  2]^4 + (0.209638 - 0.0779682 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.209638 + 0.0779682 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.210588 + 0.0790046 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.210588 - 0.0790046 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.213299 + 
   1.30104*10^-18 I) Sin[χ]^2], -0.870754 + 
Re[(0.286687 + 6.86449*10^-18 I) Cos[χ/
  2]^4 + (0.199097 + 0.00296922 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.199097 - 0.00296922 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.293242 - 2.52768*10^-18 I) Sin[χ/
  2]^4 + (0.207553 - 0.0809734 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.207553 + 0.0809734 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.208635 + 0.0822301 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.208635 - 0.0822301 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.210036 - 
   1.0842*10^-17 I) Sin[χ]^2], -0.865897 + 
 Re[(0.28947 + 4.33681*10^-18 I) Cos[χ/
  2]^4 + (0.200914 + 0.0035066 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.200914 - 0.0035066 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.297141 - 6.93889*10^-18 I) Sin[χ/
  2]^4 + (0.205433 - 0.0838154 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.205433 + 0.0838154 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.20666 + 0.0853162 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.20666 - 0.0853162 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.206694 + 
   3.46945*10^-18 I) Sin[χ]^2], -0.861034 + 
Re[(0.292255 - 1.22919*10^-17 I) Cos[χ/
  2]^4 + (0.202891 + 0.00410081 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.202891 - 0.00410081 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.301177 + 8.82243*10^-18 I) Sin[χ/
  2]^4 + (0.20328 - 0.0864909 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.20328 + 0.0864909 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.204666 + 0.0882602 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.204666 - 0.0882602 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.203284 - 
   8.67362*10^-19 I) Sin[χ]^2], -0.856164 + 
Re[(0.29503 + 1.80913*10^-18 I) Cos[χ/
  2]^4 + (0.205013 + 0.00475374 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.205013 - 0.00475374 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.305344 - 3.21668*10^-17 I) Sin[χ/
  2]^4 + (0.201097 - 0.0889976 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.201097 + 0.0889976 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.202654 + 0.0910597 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.202654 - 0.0910597 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.199813 + 
   1.43115*10^-17 I) Sin[χ]^2], -0.851289 + 
Re[(0.29778 + 1.04827*10^-17 I) Cos[χ/
  2]^4 + (0.207268 + 0.00546712 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.207268 - 0.00546712 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.30964 - 1.8289*10^-17 I) Sin[χ/
  2]^4 + (0.198883 - 0.0913333 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.198883 + 0.0913333 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.200627 + 0.0937128 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.200627 - 0.0937128 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.19629 + 
   7.37257*10^-18 I) Sin[χ]^2], -0.846411 + 
Re[(0.300493 + 7.73185*10^-18 I) Cos[χ/
  2]^4 + (0.209641 + 0.0062425 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.209641 - 0.0062425 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.314058 - 2.52768*10^-18 I) Sin[χ/
  2]^4 + (0.196643 - 0.0934968 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.196643 + 0.0934968 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.198586 + 0.0962178 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.198586 - 0.0962178 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.192724 - 
   7.37257*10^-18 I) Sin[χ]^2], -0.841533 + 
Re[(0.303157 + 1.13501*10^-17 I) Cos[χ/
  2]^4 + (0.212119 + 0.00708128 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.212119 - 0.00708128 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.318596 + 1.64055*10^-17 I) Sin[χ/
  2]^4 + (0.194378 - 0.0954871 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.194378 + 0.0954871 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.196534 + 0.0985738 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.196534 - 0.0985738 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.189124 - 
   1.34441*10^-17 I) Sin[χ]^2], -0.836656 + 
Re[(0.305759 - 1.80913*10^-18 I) Cos[χ/
  2]^4 + (0.214688 + 0.00798467 I) E^(-2 I α)
  Cos[χ/2]^2 Sin[χ/2]^2 + (0.214688 - 0.00798467 I) E^(
 2 I α)
  Cos[χ/2]^2 Sin[χ/
  2]^2 + (0.323249 - 3.02833*10^-17 I) Sin[χ/
  2]^4 + (0.19209 - 0.0973038 I) E^(-I α)
  Cos[χ/2]^2 Sin[χ] + (0.19209 + 0.0973038 I) E^(
 I α)
  Cos[χ/
  2]^2 Sin[χ] + (0.194474 + 0.10078 I) E^(-I α)
  Sin[χ/2]^2 Sin[χ] + (0.194474 - 0.10078 I) E^(
 I α)
  Sin[χ/
  2]^2 Sin[χ] + (0.185496 + 
   1.34441*10^-17 I) Sin[χ]^2]}

This is a small part of one such list. Each list I have has 100 such entries and I have 10 or so lists. But I guess that's besides the points; it'd be great if anyone could let me know how to code the aforementioned task.


Second Edit:

Based on the answer given below, I get a whole host of errors when I run:

 OptimizationFunction[αMin_, αMax_, χMin_, \
  χMax_, i_] := 
    NMaximize[{DifferenceProbability2[α, χ, ϕ, \
     θ][[i]], αMin <= α <= αMax, χMin <= \
       χ <= χMax}, {α, χ}, MaxIterations -> 1000, 
         PrecisionGoal -> 5];

 OptimizationFunction2[αMin_, αMax_, χMin_, \
  χMax_, i_] := 
    Module[{α1, χ1}, {α1, χ1} = {α, \
      χ} /. 

         OptimizationFunction[αMin, αMax, χMin, \
           χMax, i];
            αMin = α1 - 0.005;
             αMax = α1 + 0.005;
              χMin = χ1 - 0.005;
               χMax = χ1 + 0.005;
                {α1, χ1}]

  Optimzation1[α_, χ_, ϕ_, θ_] = 
   Map[OptimizationFunction2[αMin, αMax, χMin, \
    χMax, #] &, 
      Range[Length@
       DifferenceProbability2[α, χ, ϕ, θ]]]
$\endgroup$
  • 1
    $\begingroup$ Why the downvote? Let me know how I can improve the question. $\endgroup$ – Junaid Aftab Nov 5 '16 at 19:26
  • $\begingroup$ Supplying the function DifferenceProbability2 will probably get you more help. $\endgroup$ – Jack LaVigne Nov 5 '16 at 23:02
  • $\begingroup$ @JackLaVigne Done. $\endgroup$ – Junaid Aftab Nov 6 '16 at 10:31
  • $\begingroup$ I have to leave on a trip and have run out of time. I think you could think of using FoldList, NestList or maybe Map to accomplish your goal. The first step I took was to define a function that returned the answer given bounds on the inputs and the index of the list DifferenceProbability2. fun[\[Alpha]Min_, \[Alpha]Max_, \[Chi]Min_, \[Chi]Max_, i_] := NMaximize[ {DifferenceProbability2[\[Alpha], \[Chi]][[i]], \[Alpha]Min <= \[Alpha] <= \[Alpha]Max, \[Chi]Min <= \[Chi] <= \[Chi]Max}, {\[Alpha], \[Chi]}, MaxIterations -> 1000, PrecisionGoal -> 5 ][[2]] $\endgroup$ – Jack LaVigne Nov 6 '16 at 15:17
1
$\begingroup$

This is very crude and I am out of time to check it carefully, but....

I set the limits of the constraint globally.

αMin = -1; αMax = 1; χMin = 0.5; χMax = 2.5;

I defined `DifferenceProbability2[α, χ] to be your list from your Edit:

DifferenceProbability2[\[Alpha]_, \[Chi]_] := {-0.99554 + 
   Re[(0.250011 + 4.71349*10^-19 I) Cos[\[Chi]/2]^4 + (0.245566 - 
        5.611*10^-8 I) E^(-2 I \[Alpha]) Cos[\[Chi]/2]^2 Sin[\[Chi]/
         2]^2 + (0.245566 + 
        5.611*10^-8 I) E^(2 I \[Alpha]) Cos[\[Chi]/2]^2 Sin[\[Chi]/
         2]^2 + ...

I define a function which uses the index into DifferenceProbability2[α, χ] and the limits to return the optimized values.

fun[αMin_, αMax_, χMin_, χMax_, i_] := 
 NMaximize[
   {DifferenceProbability2[α, χ][[i]],
    αMin <= α <= αMax,
    χMin <= χ <= χMax},
   {α, χ},
   MaxIterations -> 1000,
   PrecisionGoal -> 5
   ][[2]]

Here it is applied it to the first index.

fun[-1, 1, 0.5, 2.5, 1]
(* {α -> -1.13318*10^-7, χ -> 1.5708} *)

Next a second function is defined that only has the index as an argument. It uses the global values and resets them based upon the answer.

fun2[i_] := Module[
  {
   α1,
   χ1
   },
  {α1, χ1} = {α, χ} /. 
    fun[αMin, αMax, χMin, χMax, i];
  αMin = α1 - 1;
  αMax = α1 + 1;
  χMin = χ1 - 1;
  χMax = χ1 + 1;
  {α1, χ1}
  ]

Here is fun[2] applied to the first index.

fun2[1]
(* {-1.25834*10^-7, 1.5708} *)

Note that now the limits are changed.

{αMin, αMax, χMin, χMax}
(* {-0.980427, 1.01957, 0.593596, 2.5936} *)

Now apply Map to fun2 and use the range of the length of the list.

Reset the global parameters first.

αMin = -1; αMax = 1; χMin = 0.5; χMax = 2.5;

In[58]:= Map[fun2[#] &, 
 Range[Length@DifferenceProbability2[α, β]]]

Out[58]= {{-1.13318*10^-7, 1.5708}, {-2.19924*10^-6, 
  1.5708}, {-9.44376*10^-6, 1.57081}, {-0.0000221393, 
  1.57083}, {-0.0000373407, 1.57087}, {-0.000050144, 
  1.57091}, {-0.0000540941, 1.57096}, {-0.0000420435, 
  1.57103}, {-6.20321*10^-6, 1.57113}, {0.0000617656, 
  1.57125}, {0.000169859, 1.5714}, {0.0003274, 1.57159}, {0.000543367,
   1.57183}, {0.000826578, 1.57212}, {0.00118635, 
  1.57249}, {0.00163268, 1.57293}, {0.00217439, 1.57347}, {0.00282116,
   1.57411}, {0.00358303, 1.57488}, {0.00446896, 
  1.57579}, {0.00548943, 1.57686}, {0.00665262, 1.5781}, {0.00796842, 
  1.57954}, {0.00944677, 1.5812}, {0.0110953, 1.5831}, {0.0129249, 
  1.58526}, {0.0149417, 1.58771}, {0.0171552, 1.59048}, {0.0195735, 
  1.5936}}

This should get you started. I think it could be done much more elegantly.

$\endgroup$
  • $\begingroup$ I get a whole host of errors when I code: OptimizationFunction[\[Alpha]Min_, \[Alpha]Max_, \[Chi]Min_, \ \[Chi]Max_, i_] := NMaximize[{DifferenceProbability2[\[Alpha], \[Chi], \[Phi], \ \[Theta]][[i]], \[Alpha]Min <= \[Alpha] <= \[Alpha]Max, \[Chi]Min <= \ \[Chi] <= \[Chi]Max}, {\[Alpha], \[Chi]}, MaxIterations -> 1000, PrecisionGoal -> 5]; followed by $\endgroup$ – Junaid Aftab Nov 7 '16 at 11:05
  • $\begingroup$ OptimizationFunction2[\[Alpha]Min_, \[Alpha]Max_, \[Chi]Min_, \ \[Chi]Max_, i_] := Module[{\[Alpha]1, \[Chi]1}, {\[Alpha]1, \[Chi]1} = {\[Alpha], \ \[Chi]} /. OptimizationFunction[\[Alpha]Min, \[Alpha]Max, \[Chi]Min, \ \[Chi]Max, i]; \[Alpha]Min = \[Alpha]1 - 0.005; \[Alpha]Max = \[Alpha]1 + 0.005; \[Chi]Min = \[Chi]1 - 0.005; \[Chi]Max = \[Chi]1 + 0.005; {\[Alpha]1, \[Chi]1}] $\endgroup$ – Junaid Aftab Nov 7 '16 at 11:05
  • $\begingroup$ followed by Optimzation1[\[Alpha]_, \[Chi]_, \[Phi]_, \[Theta]_] = Map[OptimizationFunction2[\[Alpha]Min, \[Alpha]Max, \[Chi]Min, \ \[Chi]Max, #] &, Range[Length@ DifferenceProbability2[\[Alpha], \[Chi], \[Phi], \[Theta]]]] $\endgroup$ – Junaid Aftab Nov 7 '16 at 11:05
  • $\begingroup$ See the edit as well. $\endgroup$ – Junaid Aftab Nov 7 '16 at 11:09
  • $\begingroup$ I defined DifferenceProbability2[\[Alpha]_, \[Chi]_]:= the list that you had provided. After that copy fun and fun2. It should run fine. Iterate from there $\endgroup$ – Jack LaVigne Nov 7 '16 at 11:12

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.