n=$teller
bewerking=bewerking1.proc
KANNIET=0
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 1 of $kleuren

!if $taal=nl
    somtekst$n=Los de onderstaande vergelijking op:<br>
    nivo_title=Diverse vergelijkingen oplossen
    en=en
    raaklijn=een raaklijn
!else
    somtekst$n=Solve the next equation:<br>
    nivo_title=Solving several equations
    en=$and
    raaklijn=a tangent
!endif

!if $graad=0
    R=$teller
!else
    R=$graad
!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 $c*(x+$a)*(x+$b)=0
    curve2=hline 0,0,$color2
    vraag=!exec pari printtex($curve1) 
    vraag= $vraag = 0
    X1=$[-1*$a]
    X2=$[-1*$b]
    x1=$X1
    x2=$X2
    Y1=0
    Y2=0
    !if $taal=nl
	antwoord$n=We ontbinden de vergelijking eerst in factoren, <br>\
	dus de vergelijking wordt dan $C1 <br>
    !else
	antwoord$n=First we "factorize" the equation...<br>\
	the equations turns into: $C1 <br>    
    !endif
    nulpunten=2
    wortels$n=\left\{ \begin{array}{c} x_1 = $x1\\ x_2 = $x2  \end{array}\right.
    !if $wims_user=supervisor
	G$n= x1=$X1 $en x2=$X2
    !endif
    XRANGE=-15,15
    YRANGE=-50,50
    GOED$n=$X1,$X2
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !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=curve $color2,($c)*x+($d)
    vragen=!exec pari printtex( $pm*x^2 + ($e)*x + ($f) )\
    printtex(($c)*x + ($d))
    vraag1=!line 1 of $vragen
    vraag2=!line 2 of $vragen
    vraag= $vraag1 = $vraag2
    X1=$[-1*$a]
    X2=$[-1*$b]
    x1=$X1
    x2=$X2    
    Y1=$[$c*$X1+($d)]
    Y2=$[$c*$X2+($d)]
    !if $a=$b
	nulpunten=1
	wortels$n= \overrightarrow{een\,\,\,raaklijn }\,\,\,\,\,\,  x_1 \,\,=\,\, $x2 
	!if $wims_user=supervisor
	    G$n= x=$X1 $raaklijn
	!endif
	GOED$n=$X1
    !else
	nulpunten=2
	wortels$n=\left\{ \begin{array}{c} x_1 = $x1\\ x_2 = $x2  \end{array}\right.
        !if $wims_user=supervisor
	    G$n= x2=$X1 $en x1=$X2
	!endif
	GOED$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  
    XRANGE=-15,15
    YRANGE=-80,80
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !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)]
    curve1=($p)*x^2+($q)*x + ($r)
    curve2=curve $color2,($d)*x^2+($e)*x + ($f)

    vragen=!exec pari printtex(($p)*x^2+($q)*x + ($r)) \
    printtex(($d)*x^2 + ($e)*x + ($f))
    vraag1=!line 1 of $vragen
    vraag2=!line 2 of $vragen
    vraag= $vraag1 \,\,\,=\,\,\, $vraag2
    X1=$[-1*($a)]
    X2=$[-1*($b)]
    Y1=$[$d*$X1*$X1 + $e*$X1 + $f]
    Y2=$[$d*$X2*$X2 + $e*$X2 + $f]
    !if $a=$b
	nulpunten=1
	!if $taal=nl
	    wortels$n= \overrightarrow{ze\,\,\,raken\,\,\, elkaar }\,\,  x_1 \,\,=\,\, $X1 
	!else
	    wortels$n= \overrightarrow{a\,\,\,tangent }\,\, x_1 \,\,=\,\, $X1 
	!endif
	!if $wims_user=supervisor
	    G$n= x=$X1 $raaklijn
	!endif
	GOED$n=$X1
    !else
	nulpunten=2
	wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $X2  \end{array}\right.
        !if $wims_user=supervisor
	    G$n= x1=$X1 $en x2=$X2
	!endif
	GOED$n=$X1,$X2
    !endif	
    XRANGE=-20,20
    YRANGE=-200,200
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !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
	vraag1=!texmath ($c)*(x + ($q))^2 
	curve1=$c*(x+$q)^2
    !else
	vraag1=!texmath ($p)+($c)*(x + ($q))^2 
	curve1=($p)+$c*(x+$q)^2
    !endif
    curve2=curve $color2,($d)*(x + $e)
    vraag2=!texmath ($d)*(x + ($e))
    vraag= $vraag1 \,\,\,=\,\,\, $vraag2
    X1=$[-1*($a)]
    X2=$[-1*($b)]
    Y1=$[$d*($X1 + $e)]
    Y2=$[$d*($X2 + $e)]
    !if $a=$b
	nulpunten=1
	wortels$n= \overrightarrow{ze\,\,\,raken\,\,\, elkaar }\,\,\,\,\,\,  x_1 \,\,=\,\, $X1 
	!if $wims_user=supervisor
	    G$n= x=$X1 $raaklijn
	!endif
	GOED$n=$X1
    !else
	nulpunten=2
	wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $X2  \end{array}\right.
        !if $wims_user=supervisor
	    G$n= x1=$X1 $en x2=$X2
	!endif
	GOED$n=$X1,$X2
    !endif	
    XRANGE=-20,20
    YRANGE=-200,200
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !exit
!endif

  