These terms look corerct:
I didn't check the integral, but a quick simulation using ideal diodes gives the same average as you calculated.
V(i)>2V, D1 ON, D2 OFF, V(o)=(V(i)+2)/2
V(i)<-4V, D1 OFF, D2 ON, V(o)=-4V
-4V<=V(i)<=2V, D1 OFF, D2 OFF, V(o)=V(i)
I didn't check the integral, but a quick simulation using ideal diodes gives the same average as you calculated.
Last edited: