type1=11
type2=12,13
type3=21,23
type4=22

type=!randitem $(type$level)

pari_precision=8
axis=!random -1.5,1.5
ecart=0.2
!read fn/$type

!if $out=plus
 good=!replace word out by out1 in $good
!else
 good=!replace word out by out2 in $good
!endif

drawsrc1=xrange -2,2\
yrange -2,2\
line -2,-2,2,2,red\
arrow -2,$axis,2,$axis,10,lightgrey\
arrow $axis,-2,$axis,2,10,lightgrey\
dline $u1,-2,$u1,2,orange\
plot black,$f\
text orange,$u1+0.02,$axis-0.06,tiny,u1\
text red,1.65,1.98,tiny,y=x\
text lightgrey,1.85,$axis+0.22,small,x\
text lightgrey,$axis+0.1,1.95,small,y

ulist=$u1
u=$u1
!if $good!=$empty and $good notwordof osci out out1 out2
 isgood=yes
!endif
!for i=1 to 8
 v=!evalsubst x=($u) in $f
 !if $v>2 or $v<-2 or NaN isin $v
  !break
 !endif
 ulist=$ulist,$v
 u=$v
 !if $isgood=yes and abs($good-$v)<0.04
  !break
 !endif
!next i

status=waiting
!advance cnt

