Converting ConditionalExpression to Piecewise

That conversion is straightforward, in this case. It is a one-liner

Piecewise[List @@@ Flatten[N@ftz][[All, 2]] ]

Now let me explain. As you have noticed, Solve returns solutions of the form:

{ {_ -> _}, {_ -> _}, ...}

which is what Flatten reduces to

{_ -> _, _ -> _, ...}

Then, I take only the right hand side of each Rule via Flatten[...][[All,2]] leaving us with something of the form

{ConditionalExpression[...], ...}

So, we need to replace ConditionalExpression with List to make it palatable to Piecewise, and the it is done using the shorthand form of Apply at level 1, @@@. Finally, we feed the result into Piecewise and get what you want.


As pointed out in the comments, the simpler form

Piecewise[List @@@ Last @@@ N@ftz]

works just as well.


It may not always be appropriate to convert a ConditionalExpression into Piecewise, because the two are not equivalent, and you may be changing the meaning. This is because Piecewise IMPOSES a default value of 0 if the conditions are not satisfied, whereas ConditionalExpression leaves the expression as undefined.

For example, given:

In[1]:=  expr = ConditionalExpression[1, x > 3]

In[2]:=  Simplify[expr, x < -2]
Out[2]=  Undefined

whereas:

In[3]:=  Simplify[Piecewise[{{1, x > 3}}],  x < -2]
Out[3]=  0

But, if you do want to impose the swap, say given:

In[4]:=  sol = Integrate[x^n, {x, 0, 1}]
Out[4]=  ConditionalExpression[1/(1 + n), Re[n] > -1]

... then an easy way to do it is:

In[5]:=  sol /. ConditionalExpression[xx_, yy_] :> Piecewise[{{xx, yy}}]

enter image description here