n=$counter
checkfile=$checkdir/equation.proc
ss=!record 14 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
F=f\left(x\right)\,\,=\,\,
R=$level
!if $level=0
    R=$counter
!endif    
	
a=!randitem 2,3,4,5,6,7,-2,-3,-4,-5,-6,-7
b=!randitem 2,3,4,5
c=!randitem 2,3,4,5,6,7,8,9,10
keuze=!randitem 0,1
pm=!randitem +,-

# alg form lijn y=mx+q
!if $R =1
    X=!randitem -4,-3,-2,-1,0,1,2,3,4	
    functie=$a*x^$b $pm $c 
    Y=$[$a*($X)^$b $pm $c]
    punt=($X;$Y)
    m=($b)*($a)*($X)^($b-1)
    q=($a)*($X)^($b) $pm ($c) - ($b)*($a)*($X)^($b)
    sommen=!exec pari A=($m)*x+($q)\
    printtex(A)\
    printtex(deriv($functie,x))
    
    answer$n=!line 1 of $sommen
    raaklijn=!line 2 of $sommen
    afgeleide=!line 3 of $sommen
    formula$n=\left\{\begin{array}{l}$F $a\cdot x^{$b} $pm $c \\ \\ P $punt\end{array}
!endif
	
!if $R =2
    X=!randitem 1,4,9,16,25,36,49
    !if $keuze=1
	Xrange=[0:$[$X+10]]
	functie=$a*sqrt(x)
	m=$a/(2*$[sqrt($X)])
	q=1/2*($a)*$[(sqrt($X))]
	Y=$[$a*sqrt($X)]
	punt=($X;$Y)
	afgeleide=\frac{$a}{2\cdot \sqrt{x}}
	formula$n=\left\{\begin{array}{l}$F $a\cdot \sqrt{x} \\ \\ P $punt\end{array}
    !else
    	Xrange=[0:$[$X+10]]
	functie=$a*x*(sqrt(x))
	m=3/2*($a)*(sqrt($X))
	q=-1/2*($a)*($X*(sqrt($X)))
	Y=$[$a*($X)*(sqrt($X))]
	punt=($X;$Y)
	afgeleide=\frac{3}{2} \cdot $a \cdot \sqrt{x}
	formula$n=\left\{\begin{array}{l}$F $a\cdot x \cdot \sqrt{x} \\ \\ P $punt\end{array}
    !endif
    sommen=!exec pari A=($m)*x+($q)\
    printtex(A)
    
    answer$n=!line 1 of $sommen
    raaklijn=!line 2 of $sommen 
!endif    

!if $R >2
    !if $keuze=1	
	functie=x*sqrt(x+$b)
	sr=!randitem 1,2,3,4,5,6
	r=$[$sr*$sr]
	X=$[-$b+$r]
	m=$sr + $X/(2*$sr)
	q=(-1*$X*$X)/(2*$sr)
	Y=$[($m)*($X)+($q)]
	punt=($X;$Y)
	afgeleide=\sqrt{(x+$b)} + x\cdot \frac{1}{2 \cdot \sqrt{x+$b}}
	formula$n=\left\{\begin{array}{l}$F x \cdot \sqrt{x + $b} \\ \\ P $punt\end{array}	
    !else
	functie=$a*x*sqrt(x+$b)
	sr=!randitem 1,2,3,4,5,6
	r=$[$sr*$sr]
	X=$[-$b+$r]
	m=$a*($sr + $X/(2*$sr))
	q=(-1*($a)*($X)*($X))/(2*$sr)
	Y=$[($m)*($X)+($q)]
	punt=($X;$Y)
	afgeleide=$a \cdot \sqrt{(x+$b)} + $a\cdot x\cdot \frac{1}{2 \cdot \sqrt{x+$b}}
	formula$n=\left\{\begin{array}{l}$F $a\cdot x \cdot \sqrt{x + $b} \\ \\ P $punt\end{array}	    
    !endif
    
    Xrange=[$[(-1*$b)-4]:$[$X+10]]
    sommen=!exec pari A=($m)*x+($q)\
    printtex(A)
    
    answer$n=!line 1 of $sommen
    raaklijn=!line 2 of $sommen 
!endif    

!if x isin $(answer$n)
    varlist=x
!else
    varlist=nil
!endif
arglist=y,g(x),g:x         

texanswer$n=\left\{\begin{array}{l}f'(x) = $afgeleide \\ \\ \\ P $punt \end{array} \rightarrow  y=$raaklijn 

!if $image=1
    plot=1
    draw=0
    XSIZE=0.6
    YSIZE=0.6
    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 mytics
    image$n=$Xrange $Yrange $functie title "f(x)" , $[($m)]*x+$[($q)] title "$linetext  P($X:$Y)"
!endif

!exit
