n=$teller
bewerking=bewerking1.proc
KANNIET=0
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 2 of $kleuren
!if $taal=nl
    nivo_title=Diverse vergelijkingen oplossen
    somtekst$n=Los de onderstaande vergelijking  op:<br>
    antwoord$n=We werken de vergelijking eerst om in de "nul-vorm", <br>\
    daarna is het een gewone vierkantsvergelijking die we wel gemakkelijk kunnen oplossen...<br>
    
    en=en
!else
    nivo_title=Solve several equations
    somtekst$n=Solve the next equation:<br>    
    antwoord$n=We "rewrite" the equation into a "null-form",<br>\
    after that, it turns out to be a fairly normal second degree equation,<br> which we can easily solve...<br>
    
    en=and
!endif

!if $graad=0
    R=$teller
!else
    R=$graad
!endif        

!if $R=1
    #ax^2+bx=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
    curve1=$a*x^2+$b*x
    curve2=hline 0,0,$color2
    vragen=!exec pari printtex($a*x^2 + ($b)*x) \
    -1*($b)/($a)\
    printtex(-1*($b)/($a))
    vraag=!line 1 of $vragen
    vraag=$vraag = 0
    X1=0
    X2=!line 2 of $vragen
    x2=!line 3 of $vragen
    Y1=0
    Y2=0
    XRANGE=-10,10
    YRANGE=-100,100
#    antwoord=$a\cdot x^{2} + $b\cdot x=0 \Longleftrightarrow  x\left($a\cdot x+$b\right)=0 \Longrightarrow   
    !if $wims_user=supervisor
	G$n= x1=$X1 $en x2=$X2
    !endif
    wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $x2  \end{array}\right.
    GOED$n=$X1,$X2
    nulpunten=2
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !exit
!endif

!if $R=2
    #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
    curve1=$a*x^2+$b*x+$c
    curve2=hline 0,$c,$color2
    vragen=!exec pari printtex($a*x^2 + ($b)*x + ($c)) \
    -1*($b)/($a)\
    printtex(-1*($b)/($a))
    vraag=!line 1 of $vragen
    vraag=$vraag = $c
    X1=0
    X2=!line 2 of $vragen
    x2=!line 3 of $vragen
    Y1=$c
    Y2=$c
    XRANGE=-10,10
    YRANGE=-100,100
#    antwoord=$a\cdot x^{2}+$b\cdot x+$c=$c \Longleftrightarrow  x\left($a\cdot x+$b\right)=$c-$c \Longrightarrow  
    !if $wims_user=supervisor
	G$n= x1=$X1 $en x2=$X2
    !endif
    wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $x2  \end{array}\right.
    GOED$n=$X1,$X2
    nulpunten=2
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !exit
!endif

!if $R=3
    #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 
    curve1=$a*x^2+$b*x+$c
    curve2=curve $color2,$d*x+$c
    vragen=!exec pari printtex($a*x^2 + ($b)*x + ($c)) \
    printtex($d*x+($c))\
    (($d)-($b))/($a)\
    printtex(($d-$b)/$a)
    
    vraag1=!line 1 of $vragen
    vraag2=!line 2 of $vragen
    vraag=$vraag1 = $vraag2
    X1=0
    X2=!line 3 of $vragen
    x2=!line 4 of $vragen
    Y1=$c
    Y2=$[$d*$X2+$c]
    XRANGE=-10,10
    YRANGE=-100,100
#    antwoord=$a\cdot x^{2}+$b\cdot x+$c = $d\cdot x+$c \Longleftrightarrow  $a\cdot x^{2}+$b\cdot x-$d\cdot x = $c-$c \Longleftrightarrow  $a\cdot x^{2} + $[$b-$d]\cdot x = 0 \Longrightarrow       
    !if $wims_user=supervisor
	G$n= x1=$X1 $en x2=$X2
    !endif
    wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $x2  \end{array}\right.
    GOED$n=$X1,$X2
    nulpunten=2
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !exit
!endif

!if $R>3
    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
    C=!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			
	vraag=\left(x $pm $B\right)^{2} $mp $A = $C\cdot x $mm $D
	curve1=(x+$b)^2 + $a
	XX=!exec pari $c-2*$b\
	printtex($c-2*$b)
    !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			
	vraag= -\left(x $pm $B\right)^{2} $mp $A = $C\cdot x $mm $D
    	curve1=-1*(x+$b)^2 + $a
	XX=!exec pari -2*($b) - $c\
	printtex(-2*$b - $c)
    !endif
    X2=!line 1 of $XX
    x2=!line 2 of $XX 
    Y1=$d
    Y2=$[$c*$X2+$d] 
    
    curve2=curve $color2,$c*x+$d
    X1=0
    XRANGE=-20,20
    YRANGE=-100,100
    !if $wims_user=supervisor
	G$n= x1=$X1 $en x2=$X2
    !endif
    wortels$n=\left\{ \begin{array}{c} x_1 = $X1\\ x_2 = $x2  \end{array}\right.
    GOED$n=$X1,$X2
    nulpunten=2
    opgave$n=$vraag
    !readproc nivo/plaatje$nivo.proc
  !exit
!endif

