#bewerking=$commondir/number.proc
#varlist=x
bewerking=nivo/bewerking6.proc
plaatje=0
!set n=$teller
!if $graad =0
    R=$teller
!else
    R=$graad
!endif
nivo_title=!record 2 of lang/remarks.$taal
somtekst$n=!record 61 of lang/remarks.$taal 

keuze=!randitem 1,0
!if $R=1
    # a*sqrt(b+x)-c=d => sqrt(b+x)=(d+c)/a => b+x=((d+c)/a)^2 => x=-b+((d+c)/a)^2 
    # a*sqrt(b-x)-c=d => sqrt(b-x)=(d+c)/a => b-x=((d+c)/a)^2 => x=b-((d+c)/a)^2 
    a=!randitem 2,3,4,5
    b=!randitem 1,2,3,4,5,6,7,8
    c=!randitem 1,2,3,4,5,6,7,8
    d=!randitem 1,2,3,4,5,6,7,8
    !if $keuze=0
	opgave$n=$a \cdot \sqrt{\left( $b + x \right)}-$c = $d
	GOED$n=!exec pari (($d+$c)/$a)^2-$b
        goed$n=$a \cdot \sqrt{\left( $b + x \right)} =$[$d+$c] \rightarrow \sqrt{\left( $b + x \right)}=\frac{$[$d+$c]}{$a} \rightarrow $b + x=\frac{$[($d+$c)^2]}{$[$a^2]} \rightarrow x=$(GOED$n)
    !else
        opgave$n=$a \cdot \sqrt{\left( $b - x \right)}-$c = $d
        GOED$n=!exec pari $b-(($d+$c)/$a)^2
        goed$n=$a \cdot \sqrt{\left( $b - x \right)} =$[$d+$c] \rightarrow \sqrt{\left( $b - x \right)}=\frac{$[$d+$c]}{$a} \rightarrow $b - x=\frac{$[($d+$c)^2]}{$[$a^2]} \rightarrow x=$(GOED$n)
    !endif
 !exit
!endif 

!if $R=2
    a=!randitem 2,3,4,5,6,7
    b=!randitem 1,2,3,4,5,6,7
    c=!randitem 1,2,3,4,5,6,7
    d=!randitem 1,2,3,4,5,6,7
    !if $c=$d
	d=$[$c+1]
    !endif
    r=$[$c-$d]
    !if $r<0
	r=$r	
    !else
	r= + $r
    !endif
    !if $keuze=1
	# (-x+a)(x+b)=0 => -x^2+(a-b)x+ab+(x+c)^2=(x+c)^2
	!if $[$a+2*$c-$b]=0
	    a=$[$a+1]
	!endif
	p=$[$a+2*$c-$b]
        q=$[$a*$b+$c*$c]
	GOED$n=$a,$[-1*$b]
	opgave$n=\sqrt{ \left( $p \cdot x + $q  \right)} - $d = x $r
	goed$n=\sqrt{ \left( $p \cdot x + $q  \right)} = x + $[$r+$d] \rightarrow $p \cdot x + $q = (x + $[$r+$d])^2 \rightarrow x=$a \vee x=$[-1*$b]
    !else
	# (-x+a)(x+b)=0 => -x^2+(a-b)x+ab+(-x+c)^2=(-x+c)^2
	!if $[$a-2*$c-$b]=0
	    a=$[$a+1]
	!endif
	p=$[$a-2*$c-$b]
        q=$[$a*$b+$c*$c]
	GOED$n=$a,$[-1*$b]
	opgave$n=\sqrt{ \left( $p \cdot x + $q  \right)} - $d = -x $r
	goed$n=\sqrt{ \left( $p \cdot x + $q  \right)} = -x + $[$r+$d] \rightarrow $p \cdot x + $q = (-x + $[$r+$d])^2 \rightarrow x=$a \vee x=$[-1*$b]
    !endif    
 !exit
!endif 

!if $R>2
    a=!randitem 2,3,4,5,6,7
    b=!randitem 1,2,3,4,5,6,7
    c=!randitem 1,2,3,4,5,6,7
    d=!randitem 1,2,3,4,5,6,7
    keuze=2
    !if $keuze=1
        !if $c=$d
	    d=$[$c+1]
        !endif
        r=$[$c-$d]
        !if $r<0
	    r=$r	
        !else
	    r= + $r
        !endif
        p=$[$a+$b+2*$c]
        q=$[$a*$b+$c*$c]
	!if $a=$b
	    GOED$n=$[-1*$a]
	!else
    	    GOED$n=$[-1*$a],$[-1*$b]
	    f1=$[sqrt(2*(-1*$a)^2+$p*(-1*$a)+ $q) - $d]
	    f11=$[(-1*$a) + ($c - $d)]
	    f2=$[sqrt(2*(-1*$b)^2+$p*(-1*$b)+ $q) - $d]
	    f22=$[(-1*$b) + ($c - $d)]
	    !ifval $f1=$f11 and $f2=$f22
		GOED$n=$[-1*$a],$[-1*$b]
		gg= x\,=\, $[-1*$a] \vee x\,=\,$[-1*$b]
	    !else
		!if $f1=$f11
		    GOED$n=$[-1*$a]
		    gg= x\,=\, $[-1*$a]
		!else
		    GOED$n=$[-1*$b]
		    gg= x\,=\,$[-1*$b]
		!endif
	    !endif
	!endif
        opgave$n=\sqrt{ \left( 2x^2 + $p \cdot x + $q  \right)} - $d = x $r
        goed$n=\sqrt{ \left( 2x^2 + $p \cdot x + $q  \right)} = x + $[$r+$d] \rightarrow 2x^2 + $p \cdot x + $q = (x + $[$r+$d])^2 \rightarrow $gg
    !else
	!if $[$b-2*$c]=0
	    c=$[$c+1]
	!endif
	p=$[$b-2*$c]
	!if $p>0
	    p=+ $p
	!endif
	q=$[$c*$c]
	r=$[$c+$d]
        GOED$n=0,$[-1*$b]
        opgave$n=\sqrt{ \left( 2x^2 $p \cdot x + $q  \right)} + $d = -x + $r
        goed$n=\sqrt{ \left( 2x^2 + $p \cdot x + $q  \right)} = -x + $[$r-$d] \rightarrow 2x^2 + $p \cdot x + $q = (-x + $[$r-$d])^2 \rightarrow x=0 \vee x=$[-1*$b]
    !endif
 !exit
!endif


