image=0
n=$counter
exotext=$empty
F=f\left(x\right)\,\,=\,\,
Fa=f'\left(x\right)\,\,=\,\,
R=$level
!if $level=0
    R=$counter
!endif    
	
pm=!randitem +,-
mp=!randitem +,-
keuze=!randitem 1,2

!if $questiontype=0
    # Freestyle	
    exotext=!record 25 of lang/remarks.$taal
    sometext=!record 26 of lang/remarks.$taal
    exotext=<p><a onmouseover="return escape('$sometext')">$exotext
    helptext=$empty
    checkfile=exos/checkfile2.proc
    ss=!record 7 of lang/remarks.$taal
    question$n=$ss
    a=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
    b=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20    
    c=!randitem 2,3,4,5,6
    d=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16    
    e=!randitem 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16    
    s=!randitem -1,1
    a=$[$s*$a]
    !if $R = 1 
	!if $keuze=1
    	    functie=($a*x $pm $b)*(x^$c $mp $d*x)
    	    formula$n=$F \left($a \cdot x $pm $b \right)\cdot \left( x^{$c} $mp $d\cdot x \right)
	!else
    	    functie=($a*x^$c $pm $b*x)*(x $mp $d)
    	    formula$n=$F \left($a \cdot x^{$c} $pm $b\cdot x \right)\cdot \left( x $mp $d \right)
	!endif
	!goto READY
    !endif
    !if $R = 2 
	!if $keuze=1
    	    functie=($a*x $pm $b)*e^x
	    formula$n=$F \left( $a\cdot x $pm $b \right)\cdot e^{x}
	!else
	    functie=($a*x^$c $pm $b)*ln(x)
	    formula$n=$F  \left( $a\cdot x^{$c} $pm $b \right)\cdot \ln\left(x\right)
	!endif
	!goto READY
    !endif
    !if $R = 3 
	!if $keuze=1
	    functie=(x^$b)*ln($c*x)
	    formula$n=$F  x^{$b} \cdot \ln\left($c\cdot x\right)
	!else
	    functie=($a*x $pm $b)*e^($c*x)
	    formula$n=$F \left( $a\cdot x $pm $b \right)\cdot e^{$c x}
	!endif
	!goto READY
    !endif
    !if $R > 3 
	functie=sqrt(x)*$b^x
	formula$n=$F $b^{x} \cdot \sqrt x
    !endif
    :READY	
    answer$n=!exec maxima factor(diff($functie ,x));
    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
    # multiple choice
    
    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,9,10,11,12,13,14,15,16,17,18,19,20
    bb=!shuffle 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20    
    dd=!shuffle 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16    
    ee=!shuffle 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16    
    c=!randitem 2,3,4,5,6,7,8
    s=!randitem -1,1
    !if $options<3 or $options>7
	options=5
    !endif
    answer$n=!randint 1,$options
    total=$empty
    !for p=1 to $options
	a=!item $p of $aa
	b=!item $p of $bb
	e=!item $p of $ee
	d=!item $p of $dd
	a=$[$s*$a]
	!if $R=1    
	    !if $keuze=1
    		functie=($a*x $pm $b)*(x^$c $mp $d*x)
		!if $p=$(answer$n)
    		    formula$n=$F \left($a \cdot x $pm $b \right)\cdot \left( x^{$c} $mp $d\cdot x \right)
		!endif
	    !else
    		functie=($a*x^$c $pm $b*x)*(x $mp $d)
		!if $p=$(answer$n)
    		    formula$n=$F \left($a \cdot x^{$c} $pm $b\cdot x \right)\cdot \left( x $mp $d \right)
		!endif
	    !endif
	!endif
	!if $R = 2 
	    !if $keuze=1
    		functie=($a*x $pm $b)*e^x
		!if $p=$(answer$n)
		    formula$n=$F \left( $a\cdot x $pm $b \right)\cdot e^{x}
		!endif
	    !else
		functie=($a*x^$c $pm $b)*ln(x)
		!if $p=$(answer$n)
		    formula$n=$F  \left( $a\cdot x^{$c} $pm $b \right)\cdot \ln\left(x\right)
		!endif
	    !endif
	!endif
	!if $R = 3 
	    !if $keuze=1
		functie=(x^$c)*ln($b*x)
		!if $p=$(answer$n)
		    formula$n=$F  x^{$c} \cdot \ln\left($b\cdot x\right)
		!endif
	    !else
		functie=($a*x $pm $b)*e^($c*x)
		!if $p=$(answer$n)
		    formula$n=$F \left( $a\cdot x $pm $b \right)\cdot e^{$c x}
		!endif
	    !endif
	!endif
	!if $R > 3 
	    functie=sqrt(x)*$b^x
	    !if $p=$(answer$n)
		formula$n=$F $b^{x} \cdot \sqrt 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
