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
kleuren=red,blue,green,orange,purple
kleuren=!shuffle $kleuren
color1=!item 1 of $kleuren
color2=!item 2 of $kleuren
exotext=$empty
cols=20
rows=3

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

a=!randitem -3,-2,-1,2,3,4
b=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
c=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
d=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
e=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1,2,3,4,5,6,7,8,9
f=!randitem -3,-2,1,-1,2,3

#type: ax^2+bx+c=0
D=$[($b)*($b) - 4*($a)*($c)]
!if $D<0
    answer$n=nil
    texanswer$n=x \,\, \notin \,\, \Bf{R}
    image=0
    question$n=!record 2 of lang/remarks.$taal
    sometext=!record 6 of lang/remarks.$taal
    raaklijn=!item 1 of $sometext
    raken=!item 2 of $sometext

    !if $R=1
	form=!exec pari printtex(($a)*x^2 + ($b)*x+ ($c))
	formula$n= $form \,\,=\,\,0
	!exit
    !endif
    !if $R=2
	p=$[$b+$d]
	q=$[$c+$e]
	curve1=($a)*x^2 + ($p)*x + ($q)
	curve2=($d)*x+($e)
	tot=!exec pari printtex($curve1)\
	printtex($curve2)
	form1=!line 1 of $tot
	form2=!line 2 of $tot
	formula$n= $form1 \,\,=\,\, $form2
	!exit
    !endif
    !if $R=3
	r=$[$a+$f]
	p=$[$b+$d]
	q=$[$c+$e]
	curve1=($q) + ($p)*x + ($r)*x^2
	curve2=($f)*x^2+($d)*x+($e)
	tot=!exec pari printtex($curve1)\
	printtex($curve2)
	form1=!line 1 of $tot
	form2=!line 2 of $tot
	formula$n= $form1 \,\,=\,\, $form2
	!exit
    !endif
    !if $R >3
	d=!randitem 2,3,4,5,6,7,8,9
	!if $b=$[-1*$d] 
	    d=$[$d+1]
	!endif	
	tot=!exec pari e=((($d)^2)/2)\
	q=$c+e\
	p=$b+$d\
	r=$a+1/2\
	printtex(e)\
	printtex(q)\
	printtex(p)\
	printtex( (r/p)*x)
	
	e=!line 1 of $tot
	q=!line 2 of $tot
	p=!line 3 of $tot
	r=!line 4 of $tot
	ee=!line 5 of $tot
	qq=!line 6 of $tot
	pp=!line 7 of $tot
	breuk=!line 8 of $tot
	form1=$qq + $pp \cdot x \left( 1 + $breuk \right)
	form2=\frac{\left( x + $d \right)^{2}}{2}    
	formula$n= $form1 \,\,=\,\, $form2
	formula$n=!replace internal + - by - in $(formula$n)
	formula$n=!replace internal - - by + in $(formula$n)
    !endif
 !exit
!endif
# determinant >=0    
DD=$[sqrt($D)]
x1=(-1*($b) - sqrt($D))/($[2*($a)])
x2=(-1*($b) + sqrt($D))/($[2*($a)])

tot=!exec maxima $x1;\
$x2;
x1=!line 1 of $tot
x2=!line 2 of $tot
tex_x1=!texmath $x1
tex_x2=!texmath $x2
        
!if $R=1
    curve1=$a*x^2 + $b*x+ $c
    formula$n=!exec pari printtex($curve1)
    formula$n= $(formula$n) \,\,=\,\,0
    curve1=curve $color1,$a*x^2 + $b*x+ $c
    curve2=hline 0,0,$color2
    y1=0
    y2=0
    !goto READY
!endif
!if $R=2
    p=$[$b+$d]
    q=$[$c+$e]
    curve1=($a)*x^2 + ($p)*x + ($q)
    curve2=($d)*x+($e)
    tot=!exec pari printtex($curve1)\
    printtex($curve2)
    form1=!line 1 of $tot
    form2=!line 2 of $tot
    formula$n= $form1 \,\,=\,\, $form2
    y1=$[$d*$x1+$e]
    y2=$[$d*$x2+$e]
    curve1=curve $color1,$curve1
    curve2=curve $color2,$curve2
    !goto READY
!endif
!if $R=3
    r=$[$a+$f]
    p=$[$b+$d]
    q=$[$c+$e]
    tst=$f*x^2+$d*x+$e
    curve1=($q) + ($p)*x + ($r)*x^2
    curve2=$f*x^2+$d*x+$e
    tot=!exec pari printtex($curve1)\
    printtex($curve2)
    form1=!line 1 of $tot
    form2=!line 2 of $tot
    formula$n= $form1 \,\,=\,\, $form2
    y1=$[$q + $p*$x1 + $r*$x1*$x1]
    y2=$[$q + $p*$x2 + $r*$x2*$x2]
    curve1=curve $color1,$q + $p*x + $r*x^2
    curve2=curve $color2,$f*x^2+$d*x+$e
    !goto READY
!endif
!if $R >3
    d=!randitem 2,3,4,5,6,7,8,9
    !if $b=$[-1*$d] 
	d=$[$d+1]
    !endif	
    tot=!exec pari e=((($d)^2)/2)\
    q=($c)+e\
    p=($b)+($d)\
    r=($a)+(1/2)\
    printtex(e)\
    printtex(q)\
    printtex(p)\
    printtex((r/p)*x)
    
    e=!line 1 of $tot
    q=!line 2 of $tot
    p=!line 3 of $tot
    r=!line 4 of $tot
    ee=!line 5 of $tot
    qq=!line 6 of $tot
    pp=!line 7 of $tot
    breuk=!line 8 of $tot
    curve1=curve $color1,$q + $p*x + $r*x^2
    curve2=curve $color2,0.5*x^2 + $d*x +$e
    form1=$qq + $pp \cdot x \left( 1 + $breuk \right)
    form2=\frac{\left( x + $d \right)^{2}}{2}    
    formula$n= $form1 \,\,=\,\, $form2
    formula$n=!replace internal + - by - in $(formula$n)    
    formula$n=!replace internal - - by + in $(formula$n)    
    y1=$[$q + $p*$x1 + $r*$x1*$x1]
    y2=$[$q + $p*$x2 + $r*$x2*$x2]
!endif

:READY

#type: ax^2+bx+c=0
!if $[$D]=0
    answer$n=$x1
    texanswer$n=\overrightarrow{$raken} x_1 = $tex_x1
    punten=point $x1,$y1,red
!else
    !if $[$D]>0
	answer$n=$x1,$x2
	texanswer$n=\left[ \begin{array}{c} x_1 = $tex_x1\\ x_2 = $tex_x2  \end{array}\right.
    	punten=points red,$x1,$y1,$x2,$y2
    !else
	texanswer$n=\overrightarrow{geen \,\,oplossingen\,\,dus } \,\,\, x_1 \in \varnothing
	punten=$empty
	image=0
    !endif	
!endif

!if $image=1 or $teaching=1
    !readproc exos/image1.proc
!endif

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

