# exo3 met tussenstappen
n=$counter
!if $rounding=-1
    rounding=0
    !readproc $remarkdir/rounding.$taal
!endif
mathviewpanel=$module_title:x_1=:x_2=:and:<=>
math=1
impossible=0
questiontype=0
checkfile=exos/checkfile2.proc
varlist=x
var1=5
# maximal number of arrows =>
cols=25
rows=6
XSIZE=700
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 2 of $kleuren
exotext=$empty
question$n=!record 25 of lang/remarks.$taal
sometext=!record 6 of lang/remarks.$taal
helptext=!record 26 of lang/remarks.$taal
stext=!record 24 of lang/remarks.$taal
helptext=<a onmouseover="return escape('$helptext')">$stext</a>
raaklijn=!item 1 of $sometext
raken=!item 2 of $sometext
!if $usage=2
    image=0
!endif

!if $level=0
    R=$counter
!else
    R=$level
!endif        

!if $R=1
    #(x+a)(x+b)=x^2+(a+b)x +ab=0
    #x^2+ex+f = cx+ d
    # x^2+x(e-c)+ (f-d)=0
    #keuze=1 dan d=0, keuze=2 c=0
    keuze=!randitem 1,2
    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
    d=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    !if $keuze=1
	e=$[($a) + ($b) + ($c)]
	!if $e=0
	    a=-2
	    b=4
	    c=3
	    e=5
	!endif
	f=$[($a)*($b)]
	d=0
    !else
	e=$[($a) + ($b)]
	!if $e=0
	    a=-2
	    b=4
	    e=2
	!endif
	f=$[($a)*($b)+($d)]
	c=0
    !endif
    curve1=x^2+($e)*x+($f)
    curve2=($c)*x+($d)
    tot=!exec pari printtex($curve1)\
    printtex($curve2)\
    printtex(($curve1)-($curve2))\
    ($curve1)-($curve2)
    
    form1=!line 1 of $tot
    form2=!line 2 of $tot
    form3=!line 3 of $tot
    tussen=!line 4 of $tot
    formula$n= $form1 \,=\, $form2
    x1=$[-1*$a]  
    x2=$[-1*$b]
    tex_x1=$x1
    tex_x2=$x2    
    y1=$[$c*$x1+($d)]
    y2=$[$c*$x2+($d)]
    !if $a=$b
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x2\\ $raaklijn \end{array}\right.
	answer$n=$x1
    !else
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	XRANGE=-15,15
	YRANGE=-80,80
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

!if $R=2
    #(x+a)(x+b)=x^2+(a+b)x +ab=0
    #x^2+ex+f = cx+ d
    # x^2+x(e-c)+ (f-d)=0
    keuze=!randitem 1,2
    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
    d=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    e=$[($a) + ($b) + ($c)]
    !if $e=0
	a=-2
	b=4
	c=3
	e=5
    !endif
    f=$[($a)*($b)+($d)]
    curve1=x^2+($e)*x+($f)
    curve2=($c)*x+($d)
    tot=!exec pari printtex( $curve1 )\
    printtex($curve2)\
    printtex( $curve1 - ($curve2))\
    ($curve1)-($curve2)
    
    
    form1=!line 1 of $tot
    form2=!line 2 of $tot
    form3=!line 3 of $tot
    tussen=!line 4 of $tot
    formula$n= $form1 \,=\, $form2
    x1=$[-1*$a]  
    x2=$[-1*$b]
    tex_x1=$x1
    tex_x2=$x2    
    !if $a=$b
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x2\\ $raaklijn   \end{array}\right.
	answer$n=$x1
    !else
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	XRANGE=-15,15
	YRANGE=-80,80
	y1=$[$c*$x1+($d)]
	y2=$[$c*$x2+($d)]
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

!if $R>2
    #(x+a)(x+b)=x^2+(a+b)x +ab=0
    #x^2+ex+f = cx+ d
    # x^2+x(e-c)+ (f-d)=0
    keuze=!randitem 1,2
    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
    h=!randitem -4,-3,-2,-1,1,2,3,4
    k=!randitem -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10
    e=$[($a) + ($b) + ($c)]
    !if $e=0
	a=-2
	b=4
	c=3
	e=5
    !endif
    !if $keuze=1
	g=$c
	d=$[$g*$h]
	func2=!texmath ($g)*(x + ($h))	
    !else
	g=$[-1*$c]
	d=$[$k-$g*$h]
	func2=!texmath $k - ($g)*(x + ($h))
    !endif
    f=$[($a)*($b)+($d)]
    curve1=x^2+($e)*x+($f)
    curve2=($c)*x+($d)

    tot=!exec pari printtex($curve1)\
    printtex($curve2)\
    printtex( ($curve1) - ($curve2))\
    ($curve1) - ($curve2)
    
    
    form1=!line 1 of $tot
    form2=!line 2 of $tot
    form3=!line 3 of $tot
    tussen=!line 4 of $tot
    formula$n= $form1 \,=\, $form2
    x1=$[-1*$a]  
    x2=$[-1*$b]
    tex_x1=$x1
    tex_x2=$x2    
    !if $a=$b
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x2\\ $raaklijn   \end{array}\right.
	answer$n=$x1
    !else
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	XRANGE=-15,15
	YRANGE=-80,80
	y1=$[$c*$x1+($d)]
        y2=$[$c*$x2+($d)]
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	punten=points green,$x1,$y1,$x2,$y2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

