n=$teller
!if $graad=0
    R=$teller
!else
    R=$graad
!endif   
!if $printbaar=0
    white=white
!else 
    white=magenta
!endif
     
bewerking=bewerking1.proc 
l=<font size="+1" color=$fontcolor4><em>l</em></font>
w=<font size="+1" color=$fontcolor3><em>w</em></font>
!if $taal=nl
    nivo_title=Bepaal de snijpunten tussen wortelfunctie en rechte lijn<br>en los de ongelijkheid op. 
    boven=de grafiek van de wortelfunctie $w boven de lijn $l ligt.
    onder=de grafiek van de wortelfunctie $w onder de lijn $l ligt.
    x_as=x-as
    y_as=y-as
    of=of
    !if $HINT=1	
	hint=<p align="left">Algemene Hint:<br>
    !endif
!else
    nivo_title=Determine the intersection points of "root-function" & line<br>and solve the inequality.
    boven=the graph of the "root-function" $w is above the line $l 
    onder=the graph of the "root-function" $w is under the line $l
    x_as=x-axis
    y_as=y-axis
    of=or
    !if $HINT=1	
    	hint=no hints
    !endif	
!endif
keuze=!randitem groter,kleiner

!if $R=1
    a=!randitem 1,2,3,4,-1,-2,-3,-4
    c=!randitem -3,-2,-1,1,2,3
    !if $a>0
	b=!randint -8,-1
    !else
	b=!randint 1,8
    !endif
    !if $c>0
	d=!randitem -4,-3,-2,-1,1
	e=!randint $[$d+1],8
    !else
	d=!randitem -1,1,2,3,4
	e=!randint -9,$[$d-1]
    !endif
    l1=$e
    w1=$c*sqrt($a*x +$b) + $d
    X=!exec pari (-1*$b)/($a) + (($e - $d)*($e - $d))/($c*$c*$a)
    Y=$e
    NA=$[(-1*$b)/$a]
##voort oog
    A=!exec pari printtex($a*x + $b)
	!if $d=0
	    W1=$c \cdot \sqrt{$A} 
	!else
	    !if $d<0
		 W1=$c \cdot \sqrt{$A} $d
	    !else
		W1=$c \cdot \sqrt{$A} + $d
	    !endif
	!endif
    L1=!texmath $l1
##
    GOED$n=$X,$Y
    !if $afrondingsfactor!=0
	x=$[(round($afrondingsfactor*$X))/$afrondingsfactor]
	y=$[(round($afrondingsfactor*$Y))/$afrondingsfactor]
	na=$[(round($afrondingsfactor*$NA))/$afrondingsfactor]
    !else
	x=$X
	y=$Y
	na=$NA
    !endif
    coordinaten=($x:$y)
    !if $c>0
	!if $a>0
	    !if $keuze=groter
	        ligging=$boven
		goed$n=x>$x
		GG=x>$x
		ongelijkheid=x &gt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=$na<=x&&x<$x
		GG=$na<=x<$x
		ongelijkheid=$na &le; x &lt; $x
		latextekst=w < l
	    !endif
	!else
	    !if $keuze=groter
		ligging=$boven
		goed$n=x<$x
		GG=x<$x
		ongelijkheid=x &lt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=$x<x&&x<=$na
		GG=$x<x<=$na
		ongelijkheid=$x &lt; x &le; $na
		latextekst=w < l
	    !endif
	!endif
    !else
	!if $a>0
	    !if $keuze=groter
	        ligging=$boven
		goed$n=$na<=x&&x<$x
		GG=$na<=x<$x
		ongelijkheid=$na &le; x &lt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=x>$x
		GG=x>$x
		ongelijkheid=x &gt; $x
		latextekst=w < l
	    !endif
	!else
	    !if $keuze=groter
		ligging=$boven
		goed$n=$x<x&&x<=$na
		GG=$x<x<=$na
		ongelijkheid=$x &lt; x &le; $na
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=x<$x
		GG=x<$x
		ongelijkheid=x &lt; $x
		latextekst=w < l
	    !endif
	!endif	
    !endif
    !if $PLAATJE=1
	XRANGE=$[-1*(abs($X)+30)],$[(abs($X)+30)]
	YRANGE=$[-1*(abs($Y)+10)],$[abs($Y)+10]
	transparent=$white
        GRAFIEK=linewidth 2\
        curve red,$w1\
        curve green,$l1\
        linewidth s*14\
        point $[$X],$[$Y],yellow\
        text black,$[(abs($X)+20)],-0.5,normal,$x_as\
	textup black,-2,$[abs($Y)+5],normal,$y_as
    !endif
!endif

!if $R>1
    !if $afrondingsfactor=0
	afrondingsfactor=100
	!readproc $authordir/afronding.$taal
    !endif
    a=!randitem 1,2,3,4,-1,-2,-3,-4
    c=!randitem -3,-2,-1,1,2,3
    b=!randint 4,15
    d=!randitem -1,1,2,3,4
    !if $c>0
	!if $a>0
	    d=$[-1*$d]
	    e=!randint $d,8
	    f=!randitem -4,-3,-2,-1
	!else
	    d=$[-1*$d]
	    e=!randint $d,8
	    f=!randitem 1,2,3,4
	!endif
     !else
        !if $a>0
	    e=!randint -9,$d
	    f=!randitem 1,2,3,4
	!else
	    e=!randint -9,$d
	    f=!randitem -4,-3,-2,-1
	!endif
    !endif
    l1=$f*x+$e
    w1=$c*sqrt($a*x +$b) + $d
##voort oog
    A=!exec pari printtex($a*x + $b)
	!if $d=0
	    W1=$c \cdot \sqrt{$A} 
	!else
	    !if $d<0
		 W1=$c \cdot \sqrt{$A} $d
	    !else
		W1=$c \cdot \sqrt{$A} + $d
	    !endif
	!endif
    L1=!texmath $l1
##
    A=$[$f*$f]
    B=$[2*($e-$d)*$f-$c*$c*$a]
    C=$[($e-$d)*($e-$d)-$c*$c*$b]
    D=$[sqrt($B*$B-4*$A*$C)]
    NA=$[(-1*$b)/$a]
    !if $a>0
	X=!exec pari (-1*$B-$D)/(2*$A)
	Y=$[$f*$X+$e]
    !else
	X=!exec pari (-1*$B+$D)/(2*$A)
	Y=$[$f*$X+$e]
    !endif
    GOED$n=$X,$Y
    !if $afrondingsfactor!=0
	x=$[(round($afrondingsfactor*$X))/$afrondingsfactor]
	y=$[(round($afrondingsfactor*$Y))/$afrondingsfactor]
	NA=$[(round($afrondingsfactor*$NA))/$afrondingsfactor]
    !else
	x=$X
	y=$Y
    !endif
    coordinaten=($x:$y)
    !if $c>0
	!if $a>0
	    !if $keuze=groter
	        ligging=$boven
		goed$n=x>$x
		GG=x>$x
		ongelijkheid=x &gt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=$NA<=x&&x<$x
		GG=$NA<=x<$x
		ongelijkheid=$NA &le; x &lt; $x
		latextekst=w < l
	    !endif
	!else
	    !if $keuze=groter
		ligging=$boven
		goed$n=x<$x
		GG=x<$x
		ongelijkheid=x &lt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=$x<x&&x<=$NA
		GG==$x<x<=$NA
		ongelijkheid=$x &lt; x &le; $NA
		latextekst=w < l
	    !endif
	!endif
    !else
	!if $a>0
	    !if $keuze=groter
	        ligging=$boven
		goed$n=$NA<=x&&x<$x
		GG=$NA<=x<$x
		ongelijkheid=$NA &le; x &lt; $x
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=x>$x
		GG=x>$x
		ongelijkheid=x &gt; $x
		latextekst=w < l
	    !endif
	!else
	    !if $keuze=groter
		ligging=$boven
		goed$n=$x<x&&x<=$NA
		GG=$x<x<=$NA
		ongelijkheid=$x &lt; x &le; $NA
		latextekst=w > l
	    !else
		ligging=$onder
		goed$n=x<$x
		GG=x<$x
		ongelijkheid=x &lt; $x
		latextekst=w < l
	    !endif
	!endif
    !endif
    !if $PLAATJE=1
	XRANGE=$[-1*(abs($X)+30)],$[(abs($X)+30)]
	YRANGE=$[-1*(abs($Y)+10)],$[abs($Y)+10]
	transparent=$white
	GRAFIEK=linewidth 2\
	curve red,$w1\
	curve green,$l1\
	linewidth s*14\
	point $X,$Y,yellow\
        text black,$[(abs($X)+20)],-0.5,normal,$x_as\
	textup black,-2,$[abs($Y)+5],normal,$y_as
    !endif
!endif
opgave$n=$latextekst \rightarrow \left\{\begin{array}{c}l(x)=$L1\\\\w(x)=$W1\end{array}
!if $taal=nl
    somtekst$n=Gegeven de rechte lijn $l en wortelfunctie $w  <br>\
    <ul>\
    <li>Bepaal de co&ouml;rdinaten van de snijpunten tussen $l en $w </li>\
    <li>Geef aan voor welke <em>x</em>-waarden de grafiek van $ligging  .</li>\
    <li>$AFRONDING</li></ul>
    antwoord$n=<div align="left">Het goede antwoord is dus: <ul><li>de snijpunten   $coordinaten  </li>\
    <li>En waar de grafiek van  $ligging  geldt:<br> $ongelijkheid</li></ul></div>
!else 
    somtekst$n=Given the line $l and "root-function" $w  <br>\
    <ul>\
    <li>Determine the co&ouml;rdinates of the intersection points of $l and $w </li>\
    <li>And for which <em>x</em>-values $ligging .</li>\
    <li>$AFRONDING</li></ul>
    antwoord$n=<p align="left">The correct answers are: <ul><li>$coordinaten</li>\
    <li> $ligging  when : $ongelijkheid</li></ul></p> 
!endif

!if $PLAATJE=1
    XSIZE=240
    YSIZE=240
    knipperen=1
    aantal_beeldjes=2
    plaatje$n=320,400\
    transparent $transparent\
    xrange $XRANGE\
    yrange $YRANGE\
    linewidth 1\
    vline 0,0,blue\
    hline 0,0,blue\
    plotsteps 1000\
    $GRAFIEK
!endif  
    
