# Choose all the Reduce function solutions

I have a simple question that is related to the way to extact and use the values i obtain to plot!

I have a variable A and depending the value the following reduce operation returns 1 or 2 values.

A = 0.5;
Reduce[
{D[-A Cos[θ] + 0.5 Sin[θ]^2 - 0.01 Cos[θ], {θ, 1}] == 0,
D[- A Cos[θ] + 0.5 Sin[θ]^2 - 0.01 Cos[θ], {θ, 2}] > 0,
2 Pi >= θ > 0},
θ, Reals]

A = 2;
Reduce[
{D[-A Cos[θ] + 0.5 Sin[θ]^2 - 0.01 Cos[θ], {θ, 1}] == 0,
D[- A Cos[θ] + 0.5 Sin[θ]^2 -0.01 Cos[θ], {θ, 2}] > 0,
2 Pi >= θ > 0},
θ, Reals]


RETURNS:

θ == 3.14159 || θ == 6.28319
θ == 6.28319


If i want to plot the result of the reduce operation as function of A, how can i extract the values?

Plot[
Reduce[
{D[-A Cos[θ] + 0.5 Sin[θ]^2 - 0.01 Cos[θ], {θ, 1}] == 0,
D[- A Cos[θ] + 0.5 Sin[θ]^2 - 0.01 Cos[θ], {θ, 2}] > 0,
2 Pi >= θ > 0},
θ, Reals][],
{A,-20,20}]


If i use the [] it only will plot the values obtained when there is only one solution. How can I plot all the solutions? 1 when there is only 1 and 2 when there are 2 solutions?

## 1 Answer

Clear["Global*"]

eqn = {D[-A Cos[θ] + 1/2 Sin[θ]^2 -
1/100 Cos[θ], {θ, 1}] == 0,
D[-A Cos[θ] + 1/2 Sin[θ]^2 - 1/100 Cos[θ], {θ,
2}] > 0, 2 Pi >= θ > 0};

sol = Reduce[eqn, θ, Reals]

(* (A < 99/100 && θ == π) || (A > -(101/100) && θ == 2 π) *)

funcs = ConditionalExpression[#[[-1, -1]], #[]] & /@
(sol /. Or :> List)

(* {ConditionalExpression[π, A < 99/100],
ConditionalExpression[2 π, A > -(101/100)]} *)

Plot[funcs, {A, -20, 20}, PlotRange -> {0, 7}] It is much more straightforward if you use Solve with Method->Reduce

sol2 = Solve[eqn, θ, Reals, Method -> Reduce]

(* {{θ -> ConditionalExpression[π, A < 99/100]}, {θ ->
ConditionalExpression[2 π, A > -(101/100)]}} *)

Plot[Evaluate[θ /. sol2], {A, -20, 20},
PlotRange -> {0, 7}]
(* same picture *)
`