n=$counter
!if $rounding=-1
    rounding=0
    !readproc $remarkdir/rounding.$taal
!endif
!if $usage=2
    image=0
!endif
mathviewpanel=$module_title:x_1=:and:x_2=:sqrt()
impossible=0
questiontype=0
checkfile=$checkdir/number.proc
arglist=x
cols=15
rows=2
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 2 of $kleuren
exotext=$empty
question$n=!record 2 of lang/remarks.$taal
sometext=!record 6 of lang/remarks.$taal
helptext=!record 23 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
    #c*(x+a)(x+b)=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 -1,1
    !if $a=$b
	a=$[$a-1]
    !endif
    curve1=$c*(x+$a)*(x+$b)
    C1=!htmlmath $curve1 = 0
    form1=!exec pari printtex($curve1) 
    formula$n= $form1 = 0
    x1=$[-1*$a]
    x2=$[-1*$b]
    tex_x1=$x1
    tex_x2=$x2
    y1=0
    y2=0
    textanswer$n=!record 5 of lang/remarks.$taal
    #@ We ontbinden de vergelijking eerst in factoren, <br>dus de vergelijking wordt dan $C1 <br>
    texanswer$n=\left[ \begin{array}{l} x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
    answer$n=$x1,$x2
    !if $image=1 or $teaching=1
	XRANGE=-15,15
	YRANGE=-50,50
	curve1=curve $color1,$curve1
	curve2=hline 0,0,$color2
	!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
    
    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)
    
    form1=!line 1 of $tot
    form2=!line 2 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= \overrightarrow{ $raaklijn }\,\,\,\,\,\,  x_1 \,\,=\,\, $tex_x2 
	answer$n=$x1
    !else
	texanswer$n=\left[ \begin{array}{l} x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
#    antwoord=$a\cdot x^{2}+$b\cdot x+$c=$c \Longleftrightarrow  x\left($a\cdot x+$b\right)=$c-$c \Longrightarrow  
    !if $image=1 or $teaching=1
	curve1=$pm*x^2+($e)*x+($f)
	curve2=($c)*x+($d)
	XRANGE=-15,15
	YRANGE=-80,80
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif
!if $R=3
    #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)]
    tot=!exec pari printtex(($p)*x^2+($q)*x + ($r)) \
    printtex(($d)*x^2 + ($e)*x + ($f))
    form1=!line 1 of $tot
    form2=!line 2 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= \overrightarrow{$raken }\,\,  x_1 \,\,=\,\, $x1 
	answer$n=$x1
    !else
	texanswer$n=\left[ \begin{array}{l} 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>3
    #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 $curve2
    formula$n= $form1 \,\,\,=\,\,\, $form2
    x1=$[-1*($a)]
    x2=$[-1*($b)]
    y1=$[$d*($x1 + $e)]
    y2=$[$d*($x2 + $e)]
    !if $a=$b
	texanswer$n= \overrightarrow{$raken  }\,\,\,\,\,\,  x_1 \,\,=\,\, $x1 
	answer$n=$x1
    !else
	texanswer$n=\left[ \begin{array}{l} x_1 = $x1\\ x_2 = $x2  \end{array}\right.
	answer$n=$x1,$x2
    !endif	
    !if $image=1 or $teaching=1
	XRANGE=-20,20
	YRANGE=-200,200
	curve1=curve $color1,$curve1
	curve2=curve $color2,$curve2
	!readproc exos/image1.proc
    !endif
  !exit
!endif

  
