# Plotting a Piecewise function that returns implicit equations using ContourPlot

I am using ContourPlot to plot implicit equations. Plotting separate implicit equations seems to work fine, however I can't get ContourPlot to plot a piecewise function that returns implicit equations.

ClearAll["Global*"];
a[p1_,p2_]:=(p1-30)^2+(2p2-60)^2==250
b[p1_,p2_]:=(p1-20)^2+(5p2-40)^2==300
pw[p1_,p2_]:=Piecewise[{{a[p1,p2],p1<p2}},b[p1,p2]]
Grid[{{
ContourPlot[Evaluate@a[p1,p2],{p1,0,50},{p2,0,50}],
ContourPlot[Evaluate@b[p1,p2],{p1,0,50},{p2,0,50}],
ContourPlot[Evaluate@pw[p1,p2],{p1,0,50},{p2,0,50}]
}}] I am expecting the third figure to have 2 diagonal cut-off circles, like so: • Use RegionFunction for a workaround: Show[ ContourPlot[Evaluate@a[p1, p2], {p1, 0, 50}, {p2, 0, 50}, RegionFunction -> (#1 < #2 &)], ContourPlot[Evaluate@b[p1, p2], {p1, 0, 50}, {p2, 0, 50}, RegionFunction -> (#1 >= #2 &)]] – Bob Hanlon Jan 6 at 23:37

Try these two changes. First, use Boole instead of Piecewise, maybe like this
pw[p1_, p2_] :=  With[{b = Boole[p1 < p2]},

Second, use pw[p1,p2] (without the underscores) in the ContourPlot` command. 