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

keuze=!randitem 1,2 
pm=!randitem +,-
mp=!randitem +,-
!if $questiontype=0
    # freestyle	
    image=0
    checkfile=exos/checkfile1.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
    a=!randitem 1,2,3,4,5,6,7,8,9,10,11,12
    b=!randitem 2,3,4,5,6,7,8   
    c=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
    d=!randitem 2,3,4,5,6
    e=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
    f=!randitem 2,3,4,5,6  
    !if $b=$d
	b=$[$b+1]
    !endif	
    !if $R = 1 
	s=!randitem -1,1
	a=$[$s*$a]
	!if $keuze=1 
	    functie=$a/x
	    formula$n=$F \frac{$a}{x}
	!else
	    functie=$a/x $pm $d*x
	    formula$n=$F \frac{$a}{x} $pm $d\cdot x
	!endif
	!goto READY
    !endif
    !if $R = 2 
	!if $keuze=1	
	    s=!randitem -1,1
	    a=$[$s*$a]
	    functie=$a/x^$b $pm $c
	    formula$n=$F \frac{$a}{x^$b} $pm $c
	!else
	    functie=$c*x^$d $pm $a/x^$b
	    formula$n=$F $c\cdot x^$d $pm \frac{$a}{x^$b}
	!endif
	!goto READY
    !endif
    !if $R = 3
        s=!randitem -1,1
        e=$[$s*$e]
	!if $keuze=1 
    	    functie=$e*x^$d $pm $c*x^$b $mp $a/x^$f
    	    formula$n=$F $e\cdot x^$d $pm $c\cdot x^$b $mp \frac{$a}{x^$f} 
	!else
    	    functie=$e $mp $a/x^$d $pm $c/x^$b 
    	    formula$n=$F $e $mp \frac{$a}{x^$d} $pm \frac{$c}{x^$b}  
	!endif
	!goto READY
    !endif
    !if $R > 3
	s=!randitem -1,1
	a=$[$s*$a]
	functie=$a/x^$b*($f*x^$d $pm $c)
	formula$n=$F \frac{$a}{x^$b} \cdot($f\cdot x^$d $pm $c)
    !endif
    :READY
    sommen=!exec pari deriv($functie ,x)\
    printtex(deriv($functie,x))
    answer$n=!line 1 of $sommen
    texanswer$n=!line 2 of $sommen
    texanswer$n=$Fa $(texanswer$n)
 !exit
!endif

!if $questiontype isin 1,2
    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
    plot=0
    draw=0
    image=0
    multiimage=0
    aa=!shuffle 1,2,3,4,5,6,7,8,9,10,11,12
    b=!randitem 2,3,4,5,6,7,8   
    c=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
    d=!randitem 2,3,4,5,6
    e=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
    f=!randitem 2,3,4,5,6  
    !if $b=$d
	b=$[$b+1]
    !endif
    !if $options<4 or $options >8
	options=4
    !endif
    answer$n=!randint 1,$options
    total=$empty
    !if $R = 1
	!for p=1 to $options
	    a=!item $p of $aa
	    s=!randitem -1,1
	    a=$[$s*$a]
	    functie=$a/x $pm $d*x
	    !if $p = $(answer$n)
		formula$n=$F \frac{$a}{x} $pm $d\cdot x
	    !endif
	    total=!append line printtex(deriv($functie,x)) to $total
	!next p
	!goto READY2
    !endif
    !if $R = 2
	!for p=1 to $options
	    a=!item $p of $aa
	    s=!randitem -1,1
	    a=$[$s*$a]
	    !if $keuze=1	
		s=!randitem -1,1
		functie=$a/x^$b $pm $c
		!if $p = $(answer$n)
		    formula$n=$F \frac{$a}{x^$b} $pm $c
		!endif
	    !else
		functie=$c*x^$d $pm $a/x^$b
		!if $p = $(answer$n)
		    formula$n=$F $c\cdot x^$d $pm \frac{$a}{x^$b}
		!endif
	    !endif
	    total=!append line printtex(deriv($functie,x)) to $total
	!next p
	!goto READY2
    !endif
    !if $R = 3
	!for p=1 to $options
	    a=!item $p of $aa
	    s=!randitem -1,1
	    a=$[$s*$a]
    	    y=!randitem -1,1
    	    e=$[$y*$e]
	    !if $keuze=1 
    		functie=$e*x^$d $pm $c*x^$b $mp $a/x^$f
		!if $p = $(answer$n)
    		    formula$n=$F $e\cdot x^$d $pm $c\cdot x^$b $mp \frac{$a}{x^$f} 
		!endif
	    !else
    		functie=$e $mp $a/x^$d $pm $c/x^$b 
		!if $p = $(answer$n)
    		    formula$n=$F $e $mp \frac{$a}{x^$d} $pm \frac{$c}{x^$b}
		!endif
	    !endif
	    total=!append line printtex(deriv($functie,x)) to $total
	!next p
	!goto READY2
    !endif
    !if $R > 3
	!for p=1 to $options
	    a=!item $p of $aa
	    s=!randitem -1,1
	    a=$[$s*$a]
	    functie=$a/x^$b*($f*x^$d $pm $c)
	    !if $p = $(answer$n)
		formula$n=$F \frac{$a}{x^$b} \cdot($f\cdot x^$d $pm $c)
	    !endif
	    total=!append line printtex(deriv($functie,x)) to $total
	!next p
    !endif
    :READY2
    sommen=!exec pari $total
    !for p=1 to $options
	ex=!line $p of $sommen
	ex$p=f'(x)\,\,=\,\, $ex
    !next p
    s=$(answer$n)
    texanswer$n=$(ex$s)
 !exit
!endif
