image=0
n=$counter

F=f(x)\,\,=\,\,
Fa=f'(x)\,\,=\,\,

R=$level
!if $level=0
    R=$counter
!endif    
    
pm=!randitem +,-
mp=!randitem +,-
keuze=!randitem 1,2
    
!if $questiontype=0
    checkfile=exos/checkfile2.proc
    exotext=!record 25 of lang/remarks.$taal
    sometext=!record 26 of lang/remarks.$taal
    exotext=<p><a onmouseover="return escape('$sometext')">$exotext
    helptext=$empty
    ss=!record 7 of lang/remarks.$taal
    question$n=$ss
    #freestyle
    a=!randitem 2,3,4,5,6,7,8
    b=!randitem 2,3,4,5,6,7,8,9,10    
    c=!randitem 2,3,4,5,6,7,8,9,10
    d=!randitem 2,3,4,5,6,7,8,9,10    
    e=!randitem 2,3,4
    f=!randitem 2,3,4 
    !if $b=$d
	b=$[$b+1]
    !endif    
    s=!randitem -1,1
    a=$[$s*$a]
    
    !if $R = 1 
	!if $keuze=1
    	    functie=($b*x)/(x^$f $mp $d)
    	    formula$n=$F \frac{$b\cdot x}{x^{$f} $mp $d }
	!else
    	    functie=($c*x $pm $e)/($b*x $mp $d)
    	    formula$n=$F \frac{ $c \cdot x $pm $e}{$b \cdot x $mp $d }
	!endif
    !endif
    !if $R = 2
	!if $keuze=1
    	    functie=($a*x^$e $pm $b)/($c*x^$f $mp $d)
    	    formula$n=$F \frac{$a\cdot x^{$e} $pm $b }{$c\cdot x^{$f} $mp $d}
	!else
	    !if $e=2
        	functie=($a*x $pm $b)/($c*x^$e $mp x + $e)
        	formula$n=$F \frac{$a\cdot x $pm $b}{$c\cdot x^{$e} $mp x + $e}
	    !else
		g=$[$e-1]
        	functie=($a*x $pm $b)/(x^$e $mp x^$g + $e)
        	formula$n=$F \frac{$a\cdot x $pm $b}{x^{$e} $mp x^{$g} + $e}
	    !endif
	!endif
    !endif
    !if $R = 3
	!if $keuze=1 
    	    functie=($a*x^$b)/(ln(x))
    	    formula$n=$F \frac{ $a\cdot x^{$b} }{ \ln(x)}
	!else
    	    functie=($a*$b^x)/(x^$c)
    	    formula$n=$F \frac{ $a\cdot $b^{x}}{x^{$c}}
	!endif
    !endif
    !if $R > 3 
	functie=(sqrt(x))/($b^x)
        formula$n=$F \frac{\sqrt{x}}{$b^{x}}
    !endif
    
    sommen=!exec maxima factor(diff($functie ,x));  
    answer$n=!line 1 of $sommen	
    answer$n=!replace internal log by ln in $(answer$n)
    texanswer$n=!texmath $(answer$n)
    texanswer$n=!replace internal log by ln in $(texanswer$n)
    texanswer$n=$Fa $(texanswer$n)
 !exit
!endif

!if $questiontype isin 1,2
    #multiplechoice
    checkfile=$checkdir/multiplechoice.proc
    !if $questiontype=2
	rr=!record 15 of lang/remarks.$taal
    !else
	rr=!record 16 of lang/remarks.$taal
    !endif
    exotext=$rr
    ss=!record 7 of lang/remarks.$taal
    question$n=$ss
    math=1
    multiimage=0
    plot=0
    draw=0
    image=0
    aa=!shuffle 2,3,4,5,6,7,8
    bb=!shuffle 2,3,4,5,6,7,8,9,10    
    cc=!shuffle 2,3,4,5,6,7,8,9,10
    d=!randitem 2,3,4,5,6,7,8,9,10    
    e=!randitem 2,3,4
    f=!randitem 2,3,4 
    s=!randitem -1,1
    
    !if $options <4 or $options>7
	options=4
    !endif
    answer$n=!randint 1,$options
    total=$empty
    !for p=1 to $options
	a=!item $p of $aa
	b=!item $p of $bb
	c=!item $p of $cc
	a=$[$s*$a]
	!if $b=$d
	    b=$[$b+1]
	!endif    
	!if $R = 1 
	    !if $keuze=1
    		functie=($b*x)/(x^$f $mp $d)
		!if $p=$(answer$n)
    		    formula$n=$F \frac{$b\cdot x}{x^{$f} $mp $d }
		!endif
	    !else
    		functie=($c*x $pm $e)/($b*x $mp $d)
		!if $p=$(answer$n)
    		    formula$n=$F \frac{ $c \cdot x $pm $e}{$b \cdot x $mp $d }
		!endif
	    !endif
	!endif
	!if $R = 2
	    !if $keuze=1
    		functie=($a*x^$e $pm $b)/($c*x^$f $mp $d)
		!if $p=$(answer$n)
    		    formula$n=$F \frac{$a\cdot x^{$e} $pm $b }{$c\cdot x^{$f} $mp $d}
		!endif
	    !else
		!if $e=2
        	    functie=($a*x $pm $b)/($c*x^$e $mp x + $e)
		    !if $p=$(answer$n)
        		formula$n=$F \frac{$a\cdot x $pm $b}{$c\cdot x^{$e} $mp x + $e}
		    !endif
		!else
		    g=$[$e-1]
        	    functie=($a*x $pm $b)/(x^$e $mp x^$g + $e)
		    !if $p=$(answer$n)
        		formula$n=$F \frac{$a\cdot x $pm $b}{x^{$e} $mp x^{$g} + $e}
		    !endif
		!endif
	    !endif
	!endif
	!if $R = 3
	    !if $keuze=1 
    		functie=($a*x^$b)/(ln(x))
		!if $p=$(answer$n)
    		    formula$n=$F \frac{ $a\cdot x^{$b} }{ \ln(x)}
		!endif
	    !else
    		functie=($a*$b^x)/(x^$c)
		!if $p=$(answer$n)
    		    formula$n=$F \frac{ $a\cdot $b^{x}}{x^{$c}}
		!endif
	    !endif
	!endif
	!if $R > 3 
	    functie=(sqrt(x))/($b^x)
	    !if $p=$(answer$n)
    		formula$n=$F \frac{\sqrt{x}}{$b^{x}}
	    !endif
	!endif
	total=!append line factor(diff($functie ,x)); to $total
    !next p
    
    sommen=!exec maxima $total
    !for p=1 to $options
	ex=!line $p of $sommen
	ex=!replace internal log by ln in $ex
	ex=!texmath $ex
	ex$p=f'(x)\,\,=\,\, $ex
    !next p
    s=$(answer$n)
    texanswer$n=$(ex$s)
 !exit
!endif
