# exo2 met tussenstap : schema: answer$n=tussenstap,x1,x2
# tussenstap: iets als x^2-4x-5=0
n=$counter
!if $rounding=-1
    rounding=0
    !readproc $remarkdir/rounding.$taal
!endif
!if $usage=2
    image=0
!endif
mathviewpanel=$module_title:x_1=:x_2=:and:<=>
cols=25
math=1
rows=6
XSIZE=700
impossible=0
checkfile=exos/checkfile2.proc
varlist=x
var1=5
# maximale aantal pijlen =>
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 2 of $kleuren
punten=$empty
exotext=$empty
question$n=!record 25 of lang/remarks.$taal
textanswer$n=!record 5 of lang/remarks.$taal
helptext=!record 26 of lang/remarks.$taal
sometext=!record 24 of lang/remarks.$taal
helptext=<a onmouseover="return escape('$helptext')">$sometext</a>
!if $level=0
    R=$counter
!else
    R=$level
!endif        

!if $R=1
    #ax^2+bx+c = c
    a=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    b=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    c=!randitem -5,-4,-3,-2,-1,2,3,4,5
    vragen=!exec pari printtex($a*x^2 + ($b)*x + ($c)) \
    -1*($b)/($a)\
    printtex(-1*($b)/($a))\
    A=($a*x^2+($b)*x)\
    printtex(A)
    formula$n=!line 1 of $vragen
    formula$n=$(formula$n) \,\,=\,\, $c
    x1=0
    x2=!line 2 of $vragen
    tex_x2=!line 3 of $vragen
    y1=$c
    y2=$c
    XRANGE=-10,10
    YRANGE=-100,100
    tussen=!line 5 of $vragen
    texanswer$n=\rightarrow \left[ \begin{array}{l} $tussen = 0\\ x_1 = $x1\\ x_2 = $tex_x2  \end{array}\right.
    answer$n=$x1,$x2
    !if $image=1 or $teaching=1
	curve1=curve $color1,$a*x^2+$b*x+$c
	curve2=hline 0,$c,$color2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

!if $R=2
    #ax^2+bx+c = dx+c
    a=!randitem -7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7
    b=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    c=!randitem -5,-4,-3,-2,-1,2,3,4,5
    d=!randitem 1/2,1/4,3/4,-1/2,-1/4,-3/4,2,-2,3,-3,4,-4,5,-5 
    !if $b=$d
	d=$[$d+1]
    !endif 
    vragen=!exec pari printtex($a*x^2 + ($b)*x + ($c)) \
    printtex($d*x+($c))\
    (($d)-($b))/($a)\
    printtex(($d-$b)/$a)\
    A=($a*x^2 + ($b)*x -($d)*x)\
    printtex(A)
    
    vraag1=!line 1 of $vragen
    vraag2=!line 2 of $vragen
    formula$n=$vraag1 \,=\, $vraag2
    x1=0
    x2=!line 3 of $vragen
    tex_x2=!line 4 of $vragen
    y1=$c
    y2=$[$d*$x2+$c]
    XRANGE=-10,10
    YRANGE=-100,100
    tussen=!line 6 of $vragen
    texanswer$n=\rightarrow \left[ \begin{array}{l} $tussen = 0\\ x_1 = $x1\\ x_2 = $tex_x2  \end{array}\right.
    answer$n=$x1,$x2
    !if $image=1 or $teaching=1
	curve1=curve $color1,$a*x^2+$b*x+$c
	curve2=curve $color2,$d*x+$c
	!readproc exos/image1.proc
    !endif
  !exit
!endif

!if $R>2
    keuze=!randitem 1,2
    #(x+b)^2 + a = cx+(b^2+a)
    a=!randitem -8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8
    b=!randitem -8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8
    c=!randitem 1/2,1/4,-1/2,-1/4,2,-2,3,-3,4,-4,5,-5,6,-6 
    !if $c=$[2*$b]
	c=$[$c+1]	
    !endif
    Ctex=!texmath $c
    !if $b > 0
	B=$b
	pm=+
    !else
	B=$[-1*$b]
	pm=-
    !endif
    !if $a > 0
	A=$a
    	mp=+
    !else
	A=$[-1*$a]
	mp=-
    !endif
    
    !if $keuze=1
	d=$[$b*$b+$a]
	!if $d > 0
	    D=$d
	    mm=+
	!else
	    D=$[-1*$d]
	    mm=-
	!endif
	!if $d=0
	    D=$empty
	    mm=$empty
	!endif			
	formula$n=\left(x $pm $B\right)^{2} $mp $A = $Ctex\cdot x $mm $D
	curve1=curve $color1,(x+$b)^2 + $a
	XX=!exec pari $c-2*($b)\
	printtex($c-2*($b))\
	A=((x $pm ($B))^2 $mp ($A))\
	printtex(A)\
	printtex($c*x $mm ($D))\
	printtex((x $pm ($B))^2 $mp ($A) - (($c)*x $mm ($D)))
    
    !else
	d=$[-1*$b*$b+$a]
	!if $d > 0
	    D=$d
	    mm=+
	!else
	    D=$[-1*$d]
	    mm=-
	!endif
	!if $d=0
	    D=$empty
	    mm=$empty
	!endif			
	formula$n= -\left(x $pm $B\right)^{2} $mp $A = $Ctex\cdot x $mm $D
    	curve1=curve $color1,-1*(x+$b)^2 + $a
	XX=!exec pari -2*($b) - $c\
	printtex(-2*$b - $c)\
	A=(-1*(x $pm ($B))^2 $mp ($A))\
	printtex(A)\
	printtex(($c)*x $mm ($D))\
	printtex(-1*(x $pm ($B))^2 $mp ($A) - (($c)*x $mm ($D)))
	
    !endif
    x2=!line 1 of $XX
    tex_x2=!line 2 of $XX 
    y1=$d
    y2=$[$c*$x2+$d] 
    
    x1=0
    XRANGE=-20,20
    YRANGE=-100,100
    tussen1=!line 4 of $XX
    tussen2=!line 5 of $XX
    tussen3=!line 6 of $XX
    texanswer$n=\left[ \begin{array}{l} $tussen1=$tussen2 \rightarrow $tussen3 = 0 \\ x_1 = $x1\\ x_2 = $tex_x2  \end{array}\right.
    answer$n=$x1,$x2
    !if $image=1 or $teaching=1
	curve2=curve $color2,$c*x+$d
	!readproc exos/image1.proc
    !endif
  !exit
!endif

