#LET OP
# nivo's niet synchroon met bewerking.proc's

bewerking=bewerking5.proc

!if $taal=nl
    nivo_title=Bepaal de nulpunten 
    beide=de beide nulpunten zijn
    en=en 
    ene=het ene nulpunt is 
!else
    nivo_title=Determine the "square roots"
    beide=both intersections are
    en=and
    ene=the only intersection is 
!endif
R=$graad

#functie=(Cx -A)(x+B)= Cx^2 +xCB -xA -AB = Cx^2 +x(CB-A) -AB
#a= C
#b= CB-A
#c= AB

FF=!shuffle f,g,h,k,p,w

!for n=1 to $aantal_sommen
    F=!item $n of $FF
    !if $graad = 0
	R=$n
    !endif    
    !if $R = 1 
	A=!randitem 1,2,3,-1,-2,-3
	B=!randitem 1,2,3,-1,-2,-3
	C=!randitem 1,-1
    !endif
    !if $R = 2  
	A=!randitem 4,5,6,7,8,-1,-2,-3
	B=!randitem 1,2,3,-4,-5,-6,-7,-8
	C=!randitem 1,-1
    !endif
    !if $R = 3
	A=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	B=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	C=!randitem -2,-3,-4,2,3,4
    !endif
    !if $R >3 
	A=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	B=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	C=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
    !endif
    a=$C
    b=$[$C*$B - $A]
    c=$[$A*$B]
    functie$n=(($C)*x - ($A))*(x + ($B))
    X1=($A)/($C)
    X2=-1*($B)
    #betekend er zijn gewoon altijd nulpunten
    extra$n=1
    
    sommen=!append line F=$(functie$n) to $sommen
    sommen=!append line x1=$X1 to $sommen 
    sommen=!append line x2=$X2 to $sommen 
    sommen=!append line printtex(F) to $sommen
    sommen=!append line printtex(x1) to $sommen
    sommen=!append line printtex(x2) to $sommen
!next n        
    
SOMMEN=!exec pari $sommen

r=1
!for n=1 to $aantal_sommen
    keuze=!randitem 1,2
    X1=!line $[$r+1] of $SOMMEN
    X2=!line $[$r+2] of $SOMMEN
    som$n=!line $[$r+3] of $SOMMEN
    X1tex=!line $[$r+4] of $SOMMEN
    X2tex=!line $[$r+5] of $SOMMEN
    !if $X1 != $X2
	goed$n=  \left\{ \begin{array}{c}x_{1}= $X1tex\\ x_{2}= $X2tex\end{array}\right.
	GOED$n=$X1,$X2
	punten$n=$X1,0,$X2,0
	Goed$n=$beide x1=$X1 $en x2=$X2  
    !else
	goed$n= x = $X1tex
	GOED$n=$X1
	punten$n=$X1,0,$X1,0
	Goed$n=$ene x=$X1  
    !endif
    !if $keuze=1
	F=!item $n of $FF
	som$n=$F\left( x \right)=$(som$n)
    !else
	som$n=y\,\,= $(som$n)
    !endif
    r=$[$r + 6]    
!next n

!if $PLAATJE=1
    !for n=1 to $aantal_sommen
	plaatje$n=\
	transparent white\
	xrange -10,10\
	yrange -100,100\
	vline 0,0,blue\
	hline 0,0,blue\
	linewidth 2\
	curve green,$(functie$n)\
	linewidth 6\
	points red,$(punten$n),red
    !next n
!endif
 
