解:?$(1)$?當(dāng)?$x=\frac 12$?時(shí),?$y=x^2=\frac 14$?
?$(2)$?當(dāng)?$x<-1$?時(shí),?$y=x+2=-4,$?解得?$x=-6;$?
當(dāng)?$-1≤x≤1$?時(shí),?$y=x^2=-4,$?無解;
當(dāng)?$x>4$?時(shí),?$y=-x+2=-4,$?解得?$x=6$?
綜上,輸入的?$x$?的值是?$-6$?或?$6$?時(shí),輸出的結(jié)果?$y$?是?$-4$?