# exo8 met tussenstappen
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:<=>
impossible=0
questiontype=0
checkfile=exos/checkfile2.proc
varlist=x
math=1
var1=5
# max number of arrows
cols=25
rows=6
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 $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
    
    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
    pm=!randitem 1,-1
    !if $pm=-1
	e=$[(-1*($a)) + (-1*($b)) + ($c)]
	!if $e=0
	    a=-2
	    b=4
	    c=7
	    e=5
	!endif
	f=$[-1*($a)*($b)+($d)]
    !else
	e=$[($a) + ($b) + ($c)]
	!if $e=0
	    a=-2
    	    b=4
    	    c=3
	    e=5
	!endif
	f=$[($a)*($b)+($d)]
    !endif
    curve1=($pm)*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
    #ax^2+bx+c=dx^2+ex+f
    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 -4,-3,-2,-1,2,3,4
    d=!randitem 1/2,1/3,1/4,1/5,2/3,3/4,4/5,-1/2,-1/3,-1/4,-1/5,-2/3,-3/4,-4/5
    e=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    f=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
    p=!exec pari $c+$d
    q=$[($c)*($a)+($c)*($b) + ($e)]
    r=$[($c)*($a)*($b) + ($f)]
    curve1=($p)*x^2 + ($q)*x + ($r)
    curve2=($d)*x^2 + ($e)*x + ($f)
    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)]
    y1=$[$d*$x1*$x1 + $e*$x1 + $f]
    y2=$[$d*$x2*$x2 + $e*$x2 + $f]
    !if $a=$b
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $x1\\ $raken  \end{array}\right.
	answer$n=$x1
    !else
	texanswer$n=\rightarrow \left[ \begin{array}{l} $form3 = 0 \\ x_1 = $x1\\ x_2 = $x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	curve1=($p)*x^2+($q)*x + ($r)
	curve2=($d)*x^2+($e)*x + ($f)
	XRANGE=-20,20
	YRANGE=-200,200
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

!if $R>2
    #p+c(x+q)^2=d(x+e)
    a=!randitem -5,-4,-3,-2,-1,2,3,4,5
    b=!randitem -5,-4,-3,-2,-1,2,3,4,5
    c=!randitem 1,2,3,4,-1,-2,-3,-4
    d=!randitem 2,3,4,-1,-2,-3,-4
    e=!randitem -5,-4,-3,-2,-1,2,3,4,5
    f=!randitem -5,-4,-3,-2,-1,2,3,4,5
    !if $[$c*$a + $c*$b + $d] = 0
	a=2
	b=-3
	c=-1
	d=-2
    !endif
    q=!exec pari (($c)*$a+($c)*$b+($d))/(2*($c))
    p=!exec pari ($c)*$a*$b+($d)*$e-($c)*$q*$q
    !if $p=0
	form1=!texmath ($c)*(x + ($q))^2 
	curve1=($c)*(x+($q))^2
    !else
	form1=!texmath ($p)+($c)*(x + ($q))^2 
	curve1=($p)+($c)*(x+($q))^2
    !endif
    curve2=($d)*(x + ($e))
    form2=!texmath ($d)*(x + ($e))
    formula$n= $form1 \,\,\,=\,\,\, $form2
    x1=$[-1*($a)]
    x2=$[-1*($b)]
    y1=$[$d*($x1 + $e)]
    y2=$[$d*($x2 + $e)]
    
    tot=!exec pari A=$curve1 - ($curve2)\
    printtex(A)
    tussen=!line 1 of $tot
    form3=!line 2 of $tot
    !if $a=$b 
	texanswer$n=\rightarrow \left[ \begin{array}{l}$form3 = 0 \\ x_1 = $x1\\ $raken  \end{array}\right.
	answer$n=$x1
    !else
	texanswer$n=\rightarrow \left[ \begin{array}{l}$form3 = 0 \\ x_1 = $x1\\ x_2 = $x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	curve2=($d)*(x + $e)
	XRANGE=-20,20
	YRANGE=-200,200
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

  