questiontype=0
cols=12
rows=6

!set n=$counter
R=$level
!if $level=0
    R=$counter
!endif    
!endif
!if $rounding <0
    rounding=0
    !readproc $remarkdir/rounding.$taal
!endif
	
checkfile=exos/checkfile4.proc
	
a=!randitem 2,3,4,5
b=!randitem 2,3,4,5,6
c=!randitem 0,1,2,3,4
d=!randitem 1,2,3,4,5    
e=!randitem 2,3,4,5 

pm=!randitem +,-
mp=!randitem +,-
keuze=!randitem 2,1
	
!if $R = 1
    !if $keuze=1
        X1=$c
        X2=$[$X1+$d]
	a=1
        f=x+$b
	Xmin=-1
	Xmax=$[$X2+4]
	formula=\pi \cdot \left( x + $b \right)^{2} 
	functie$n=pi*(x+$b)^2
	functie=x+$b
    !else
        X1=$c
        X2=$[$X1+$d]
        f=$a*x+$b
	Xmax=$[$X2+4]
	Xmin=-1
	functie$n=pi*($a*x+$b)^2 
	functie=$a*x+$b
	formula=\pi \cdot \left( $a \cdot x + $b \right)^{2} 
    !endif
    !if $image=1 or $teaching=1
	y2=!evalsubst x=$Xmax in $functie
	Y1=-5
	Y2=$[$y2+4]
	xrange=$Xmin,$Xmax
	yrange=$Y1,$Y2
        rect=rect $Xmin,$Y1,$Xmax,$Y2,black
	curve=curve red,$functie
    !endif
!endif

!if $R = 2 	
    !if $keuze=1
	b=$[-1*($pm$a)]
        X1=!randint $b,$[$b+3]
        X2=$[$X1+$d]
        functie=sqrt(x $pm $a) 
	Xmin=$[$b-2]
	Xmax=$[$X2+2]
	formula=\pi \cdot \left( x $pm $a \right)
	functie$n=pi*(x $pm $a)
    !else
	b=$[-1*($pm$a)]
        X1=!randint $b,$[$b+3]
        X2=$[$X1+$d]
        functie=x*sqrt(x $pm $a)
	Xmin=$[$b-2]
	Xmax=$[$X2+2]
	formula=\pi \left( x \cdot \sqrt{\left( x $pm $a \right)} \right)^{2}
	functie$n=pi*(x^3 $pm $a*x^2)
    !endif
    !if $image=1 or $teaching=1
	y2=!evalsubst x=$Xmax in $functie
	Y2=$[$y2+4]
	xrange=$Xmin,$Xmax
	yrange=-2,$Y2
        rect=rect $Xmin,-2,$Xmax,$Y2,black
	curve=curve red,$functie
    !endif
!endif

!if $R=3
    X1=!randitem -5,-4,-3,-2,-1
    b=$[-1*$X1]
    a=!randitem 2,4,6
    c=!randitem 1/2,1,2,2
    f=$a*sqrt(x+$b)
    tot=!exec pari $c*(x+$b)\
    ($a*$a)/($c*$c)-$b
    g=!line 1 of $tot
    X2=!line 2 of $tot
    functie1$n=$f
    functie2$n=$g
    formula=\pi \cdot \left($a^2(x+$b)-($g)^2\right)
    functie$n=pi*(-1*$c*$c*x^2+($a*$a-2*$b*$c*$c)*x+$a*$a*$b-$c*$c*$b*$b)
    Xmin=$[$X1-2]
    Xmax=$[$X2+4]
    !if $image=1 or $teaching=1
	Y2=!evalsubst x=$Xmax in $(functie2$n)
	xrange=$Xmin,$[$X2+5]
	yrange=-2,$Y2
        rect=rect $Xmin,-2,$[$X2+5],$Y2,black
	curve=curve red,$(functie1$n)\
	curve orange,$(functie2$n)
    !endif
!endif

!if $R>3
    X1=!randitem -5,-4,-3,-2,-1,2,3,4
    b=$[-1*($X1-1)]
    a=!randitem 2,3,4
    p=!randitem 4,9,16,25
    X2=$[-1*$b+$p]
    f=$a*sqrt(x+$b)
    functie1$n=$f
    c=$[sqrt($p)*$a-$a]
    g=!exec pari $c/($p-1)*(x+$b-1)+$a\
    $c/($p-1)
    functie2$n=!line 1 of $g
    d=!line 2 of $g
    e=!exec pari -1*$d*$d\
    2*$d*($d*($b-1)+$a)-$a^2\
    ($d*($b-1)+$a)^2-$a^2*$b
    p=!line 1 of $e
    q=!line 2 of $e
    r=!line 3 of $e
    !if $b>0
	b=+$b
    !else
	b=$b
    !endif
    formula=\pi \cdot \left($a^2(x$b)-\left($(functie2$n)\right)^2 \right)
    functie$n=pi*($p*x^2-$q*x-$r)
    Xmin=$[$X1-4]
    Xmax=$[$X2+2]
    !if $image=1 or $teaching=1
	Y2=!evalsubst x=$Xmax in $(functie2$n)
	xrange=$Xmin,$[$X2+5]
	yrange=-2,$Y2
        rect=rect $Xmin,-2,$[$X2+5],$Y2,black
	curve=curve red,$(functie1$n)\
	curve orange,$(functie2$n)
    !endif
!endif

!if $image=1	
    draw=1
    plot=0
    XSIZE=200
    YSIZE=200
    image$n=\
    xrange $xrange\
    yrange $yrange\
    hline 0,0,blue\
    vline 0,0,blue\
    linewidth 2\
    $curve\
    dvline $X1,0,green\
    dvline $X2,0,green\
    $rect

!else
    !if $teaching=1
	helptext=!record 63 of $remarkdir/commonremarks.$taal
	helptext=<a href="javascript:showimage();">$helptext
	insdraw_size=200,200
	!insdraw xrange $xrange\
	yrange $yrange\
	hline 0,0,blue\
	vline 0,0,blue\
	linewidth 2\
	$curve\
	dvline $X1,0,green\
	dvline $X2,0,green\
	$rect
    
    !endif
!endif


totaal=!exec maxima integrate($(functie$n) ,x,$X1,$X2);\
integrate($(functie$n),x); 

answer$n=!line 1 of $totaal
!if log isin $(answer$n)
    answer$n=!replace internal log by ln in $(answer$n)
!endif

!if $showanswer=1
    ant1= \int_{$X1}^{$X2} $formula dx \rightarrow
    ant2=!line 2 of $totaal
    !if log isin $ant2
	ant2=!replace internal log by ln in $ant2
    !endif
    ant2=!texmath $ant2 
    ant3=!texmath $(answer$n)
    texanswer$n= \left [ $ant1 $ant2 \right ]_{$X1}^{$X2}  \,\,=\,\, $ant3
!endif
ss=!record 26 of lang/remarks.$taal
question$n=$ss
!if $R<3
    F=!texmath f(x) = $functie
    test=!record 10 of lang/remarks.$taal
    formula$n=$test
!else    
    F1=!texmath f(x) = $(functie1$n)
    F2=!texmath g(x) = $(functie2$n)
    formula$n=\left\{ \begin{array}{c}$F1\\  \\ $F2 \end{array}
!endif


