!set n=$counter
F=f\left(x\right)\,\,=\,\,
R=$level
!if $level=0
    R=$counter
!endif    
	

pm=!randitem +,-
mp=!randitem +,-

!if $questiontype isin 0,1,2
    # freestyle and multiplechoice
    ss=!record 9 of lang/remarks.$taal
    question$n=$ss
    exotext=!record 25 of lang/remarks.$taal
    sometext=!record 26 of lang/remarks.$taal
    exotext=<p><a onmouseover="return escape('$sometext')">$exotext
    helptext=$empty
    a=!randitem 2,3,4,5,6,7,8,9,10,-2,-3,-4,-5,-6,-7,-8,-9,-10
    b=!randitem 2,3,4,5,6,7  
    c=!randitem 2,3,4,5,6,7,8,9,10
    d=!randitem 3,4,5,6,7,8,9,10   
    e=!randitem 2,3,4,5,6 
    !if $b=$d
	b=$[$b+1]
    !endif
    x=!randitem -5,-4,-3,-2,-1,0,1,2,3,4,5	
    g=$[$d-1]
    !if $R = 1
	functie=$a*x^$b 
        y=$[$a*($x)^$b]
        punt=($x;$y)
        formula$n=\left\{\begin{array}{l}$F $a\cdot x^{$b} \\ \\ P $punt\end{array}
    !endif
	
    !if $R = 2
	functie=$a*x^$b $pm $c*x $mp $d
	y=$[$a*($x)^$b $pm $c*($x) $mp $d]
        punt=($x;$y)
        formula$n=\left\{\begin{array}{l}$F $a\cdot x^{$b} $pm $c\cdot x $mp $d\\ \\ P $punt\end{array}
    !endif
    !if $R >2
        mytexsize=+2
        x=!randitem -3,-2,-1,1,2,3
        keuze=!randitem 1,2
        !if $keuze=1
	    functie=$a*x^$b $pm $c/x
	    y=!exec pari $a*($x)^$b $pm $c/($x)
	    punt=($x;$y)
	    formula$n=\left\{\begin{array}{l}$F $a \cdot x^{$b} $pm \frac{$c}{x} \\ \\  P $punt\end{array}
	!else
	    e=!randitem 2,3
	    functie=$a*x^$b $pm $c/x^$e
	    y=!exec pari $a*($x)^$b $pm $c/(($x)^$e)
	    punt=($x;$y)
	    formula$n=\left\{\begin{array}{l}$F $a \cdot x^{$b} $pm \frac{$c}{x^$e} \\ \\  P $punt\end{array}
	!endif   
    !endif
    sommen=!exec pari A=deriv($functie ,x)\
    printtex(deriv($functie,x))\
    subst(A,x,$x)


    !if $questiontype isin 1,2
	# multiple choice
	checkfile=$checkdir/multiplechoice.proc
	!if $options <4 or $options > 8
	    options=4
	!endif
	exotext=!record 17 of lang/remarks.$taal
	afgeleide=!line 2 of $sommen
	tangent=!line 3 of $sommen
	answer$n=!randint 1,$options
	math=0
	plot=0
	multiimage=0
	draw=0
	image=0
	deviation=!shuffle 0.001,0.01,0.1,10,100,0.5,0.75,1.25,1.5,1.75
	slope=!record 11 of lang/remarks.$taal
	texanswer$n=\left\{\begin{array}{l}f'(x) = $afgeleide\\ \\ x = $x \end{array} \rightarrow f'($x) = $tangent \rightarrow $slope \,=\,  $tangent
	!if $tangent=0
	    choices=+,-
	!else
	    choices=+,-,*
	!endif
	!for p=1 to $options
	    w=!item $p of $deviation
	    pm=!randitem $choices
	    !if $p=$(answer$n)
		ex$p=<table><td>$slope =</td><td>$tangent</td></table>
	    !else
		ex$p=<table><td>$slope = </td><td>$[$tangent $pm $w]</td></table>
	    !endif
	!next p
    !else
	checkfile=exos/checkfile4.proc
        answer$n=!line 3 of $sommen
	afgeleide=!line 2 of $sommen
	slope=!record 11 of lang/remarks.$taal
	texanswer$n=\left\{\begin{array}{l}f'(x) = $afgeleide\\ \\ x = $x \end{array} \rightarrow  f'($x) = $(answer$n) \rightarrow $slope \,=\,  $(answer$n)
	!if $image=1
	    plot=1
	    # so GNUplot 
	    draw=0
	    XSIZE=0.6
	    YSIZE=0.6
	    x1=$[-1*(abs($x)) -2]
	    x2=$[abs($x) + 2]
	    y1=$[-1*(abs($y))-30] 
	    y2=$[(abs($y))+30] 
	    Yrange=[$y1:$y2]
	    Xrange=[$x1:$x2]
	    raaklijn=$(answer$n)*x + ($y -$(answer$n)*$x)
	    linetext=!record 10 of lang/remarks.$taal
	    image_settings$n=size 0.6,0.6; noborder ; zeroaxis linetype 3 ; tmargin 1 ; rmargin 1 ; grid xtics ytics mxtics
	    image$n= $Xrange $Yrange $functie title "f(x)" ,$raaklijn  title "$linetext P($x;$y)"
	!endif
    !endif
 !exit
!endif 


