# What Does “Conditional Expression” Mean When it Appears in the Output?

My grandson and I were playing around with some calculus, using Mathematica to find maxima, minima, & points of inflection for various algebraic functions (e.g., $y = 2 x^3 + 3 x^2 + 5 x + 2$, etc.), We would typically solve $y' = 0$ to find the maxima & minima and then use $y'' = 0$ to see if they were maxima, minima, or POI. This all worked fine! Then, grandson suggests we try it on a trig function such as Sin[x].

Here's our results:

Solve[y'[x]==0,x]


gave us

{{x -> ConditionalExpression[-(π/2) + 2 π C[1],  C[1] ∈ Integers]},
{x -> ConditionalExpression[π/2 + 2 π C[1],  C[1] ∈ Integers]}}


and

Solve[y''[x]==0,x]


gave us

{{x -> ConditionalExpression[2 π C[1], C[1] ∈ Integers]},
{x -> ConditionalExpression[π + 2 π C[1], C[1] ∈ Integers]}}


We have no idea what this is telling us.

Can someone interpret what this means and how we would use this to evaluate maxima, minima, or POI?

Thanks!

• +1 for going on explorations with your grandson. – Henrik Schumacher Apr 27 '18 at 18:57
• See the documentation ConditionalExpression. The ConditionalExpression has a value only when the condition evaluates to True. If the condition evaluates to False then the expression is undefined. – Bob Hanlon Apr 27 '18 at 19:21
• Coolest granddad ever. – ibeatty May 1 '18 at 18:54

This is the way Mathematica handles infinitely many solutions. C[1], C[2] etc. are generic constants that Mathematica uses to express parameterized families of solutions.

x -> ConditionalExpression[-(π/2) + 2 π C[1], C[1] ∈ Integers]


as

$$x \in \left\{ - \frac{\pi}{2} + 2 \, \pi \, n \mid n \in \mathbb{Z} \right\}.$$

So $x$ can be $- \frac{\pi}{2}$ plus a multiple of $2 \pi$.

{
{x -> ConditionalExpression[-(π/2) + 2 π C[1], C[1] ∈ Integers]},
{x -> ConditionalExpression[π/2 + 2 π C[1], C[1] ∈ Integers]}
}


means that

$$x \in \left\{ - \frac{\pi}{2} + 2 \, \pi \, n \mid n \in \mathbb{Z} \right\} \cup \left\{ \frac{\pi}{2} + 2 \, \pi \, n \mid n \in \mathbb{Z} \right\}$$

That makes sense for $y = \sin$ for $y' =\cos$ and this is precisely the zero set of $\cos$.

So, this set contains all candidates for minima and maxima of Sin. In order to figure out what is what, just plug x into Sin and replace by the output of Solve[Sin'[x] == 0, x]:

Simplify[
Sin[x] /. Solve[Sin'[x] == 0, x]
]

 {
ConditionalExpression[-1, C[1] ∈ Integers],
ConditionalExpression[1, C[1] ∈ Integers]
}


This tells you: The elements of the first set are minimizers, the elements of the second sets are all the maximizers.

Restricting to intervals

If you are looking for critical points within a given interval, say $[0, 2\pi]$, then you can tell Solve to look only there by using

sol = Solve[{Sin'[x] == 0, 0 <= x <= 6 π}, x]


{{x -> π/2}, {x -> (3 π)/2}, {x -> (5 π)/2}, {x -> ( 7 π)/2}, {x -> (9 π)/2}, {x -> (11 π)/2}}

Second order optimality conditions

Necessary for a local minimum is also $\sin''(x) \geq 0$. We can check that with

Sin''[x] >= 0 /. sol


{False, True, False, True, False, True}

So, only the second, fourth, sixth solution in sol can be local minimizers.

A sufficient condition for a local minimizer is $\sin'(x) = 0$ and $\sin''(x)>0$. Let's check that:

Sin''[x] > 0 /. sol


{False, True, False, True, False, True}

So our three candidates are definately local minimizers.

Including necessary conditions for boundary points

But beware: Minimizers and maximizers of a function restricted to a closed interval can also be located on the boundary of the intervals! You have to check them seperately.

For finding minimizers on a closed interval, you can also incorporate the check for the boundary points into the system that gets handed over to Solve like this

y = x \[Function] Sin[x] + x/2;
a = -1;
b = 2 Pi;
Plot[y[x], {x, a, b}]
necessaryconditions = (a <= x <= b) && ((y'[x] == 0) || (x == a && y'[x] >= 0) || (x == b && y'[x] <= 0));
sol = Solve[necessaryconditions, x]


{{x -> -1}, {x -> (2 π)/3}, {x -> (4 π)/3}}

In necessaryconditions, you have to read && as "and" and || as "or". So these conditions are: $x \in [a,b]$ and $x$ needs to satisfy at least one of the following conditions:

1.) $y'(x) = 0$

2.) $x$ is the left boundary point of the interval and $y$ is not descending at this point ($y'(x) \geq 0$).

3.) $x$ is the right boundary point of the interval and $y$ is not ascending at this point ($y'(x) \leq 0$).

Final remark

You may also try Reduce which might return more readable results:

Reduce[necessaryconditions, x]


x == -1 || x == (2 π)/3 || x == (4 π)/3

And once again, our example from the beginning:

Reduce[Sin'[x] == 0, x]

C[1] ∈ Integers && (x == -(π/2) + 2 π C[1] || x == π/2 + 2 π C[1])

• So, if I understand you, -1 & +1 are the minima and maxima..., which is the correct solution. But, how do I get it to tell me the values of x for which that is true (over some interval?)? – OilerMan Apr 27 '18 at 20:13
• @OilerMan -Specify a range of interest: sol = Solve[{y'[x] == 0, -6 Pi <= x <= 6 Pi}, x] and evaluate the function and its derivatives with the solution: {x, y[x], y'[x], y''[x]} /. sol – Bob Hanlon Apr 27 '18 at 20:53