# Minimization problem!

Im probably not seeing the obvious question but i want to minimize an expression like:

Func[A_,B_,θ_,θ1_]:= A Cos[θ-θ1] + B Sin[θ]^2

where i do to minimize in order to theta

A=1
B=1
θ1=π
NMinimize[Func[A,B,θ,θ1],{θ}]

which i can get the desired outputs. Now if i want to sweep one of the variables (theta1) i can plot it like

Plot[NMinimize[
Func[A, B, θ, θ1], {θ}][[1]], {θ1, -\
π, π}]

But now i want to find the minimum of this graphic. I cannot do

NMinimize[NMinimize[       Func[A, B, θ, θ1], {θ}][[1]], {θ1}]

one thing i can do it to plot several plots for theta1 values and extract the minimum. But is there anyway to do it automatically?

My end goal is to extract the minimums of the plot of (minimum func in respect of theta) as function of theta1 for several A constants

• NMinimize[Func[A, B, \[Theta], \[Theta]2], {\[Theta], \[Theta]2}] gives {-1., {\[Theta] -> 5.05573*10^-21, \[Theta]2 -> -3.14159}}. – Alx Dec 20 '19 at 12:02
• Alx its is not a same thing! You are optimizing the NMinimize using 2 variables. I just want to fix one and do the optimization – user1111 Dec 20 '19 at 16:17

Is this similar to what you want?

Clear[func, min]
func[a_, b_, theta_, theta1_] := a Cos[theta - theta1] + b Sin[theta]^2

min[a_?NumericQ, b_?NumericQ, theta1_?NumericQ] :=
NArgMin[func[a, b, theta, theta1], {theta}]

Plot[
min[1, 1, theta1], {theta1, -Pi, Pi},
PlotPoints -> 20, MaxRecursion -> 3
]

In the call to min[a, b, theta1] inside Plot, you can substitute different values for $$a$$ and $$b$$ and see how the minimum position varies.

Note that I have also replaced single-letter uppercase variable names with the corresponding lower-case ones, to avoid conflicts with built in symbols.