
#LET OP
# nivo's niet synchroon met bewerking.proc's
#ALTIJD NULPUNTEN
bewerking=bewerking8.proc

!if $taal=nl
    nivo_title=Bepaal de co&ouml;rdinaten van de nulpunten
    beide=de beide snijpunten met de x_as zijn 
    en=en 
    ene=het ene snijpunt met de x_as is 
!else
    nivo_title=Determine the "intersection-point co&ouml;rdinates"
    beide=both intersection points with the x_axis are
    en=and
    ene=the only intersection point with the x_axis 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
    de_top=!randitem 0,0,0,0,0,0,0,0,0,0,1
    !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 -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
    !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
	R1=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	R2=!randitem -1,-2,-3,-4,-5,-6,-7,-8,1,2,3,4,5,6,7,8
	A=$A/$R1
	B=$B/$R2
    !endif
    
    a=$C
    b=$[$C*$B - $A]
    c=$[$A*$B]
    functie$n=(($C)*x - ($A))*(x + ($B))
    X1=($A)/($C)
    X2=-1*($B)
    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 y1=subst(F,x,x1) to $sommen
    sommen=!append line y2=subst(F,x,x2) to $sommen
    sommen=!append line printtex(F) to $sommen
    sommen=!append line printtex(x1) to $sommen
    sommen=!append line printtex(x2) to $sommen
    sommen=!append line printtex(y1) to $sommen
    sommen=!append line printtex(y2) to $sommen
!next n        
    
SOMMEN=!exec pari $sommen

r=1
!for n=1 to $aantal_sommen
    X1=!line $[$r+1] of $SOMMEN
    X2=!line $[$r+2] of $SOMMEN
    Y1=!line $[$r+3] of $SOMMEN
    Y2=!line $[$r+4] of $SOMMEN
    som$n=!line $[$r+5] of $SOMMEN
    X1tex=!line $[$r+6] of $SOMMEN
    X2tex=!line $[$r+7] of $SOMMEN
    Y1tex=!line $[$r+8] of $SOMMEN
    Y2tex=!line $[$r+9] of $SOMMEN
    !if $X1 != $X2
	GOED$n=$X1,$Y1,$X2,$Y2
	goed$n=  \left\{ \begin{array}{c} \left( $X1tex : $Y1tex \right) \\ \left( $X2tex : $Y2tex \right)\end{array}\right.
	Goed$n=$beide  ($X1:$Y1) $en ($X2:$Y2)  
    !else
	GOED$n=$X1,$Y1
	goed$n=\rightarrow \left( $X1tex : $Y1tex \right)  
	Goed$n=$ene ($X1:$Y1)      
    !endif
    keuze=!randitem 1,2
    !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 + 10]    
!next n

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