!set n=$counter
!if $level=0
    R=$counter
!else
    R=$level
!endif        
image=0
varlist=$empty
arglist=$empty
cols=15
rows=4
varcnt=0
wordmax=40
complex=1
checkfile=exos/checkfile1.proc
question$n=!record 2 of lang/remarks.$taal
!if $teaching=1
    helptext=$empty
    sometext=!record 71 of lang/remarks.$taal
    exotext=</p><a onmouseover="return escape('<img src=$module_dir/gifs/exo$subject.jpg>')">$sometext</a>
!else
    helptext=$empty
    exotext=$empty
!endif
!if $R=1
    getal1=!shuffle -5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
    getal2=!shuffle 2,3,4,5,6,7,8,9,10
    a=!item 1 of $getal1
    b=!item 2 of $getal1
    c=!item 1 of $getal2
    d=!item 2 of $getal2
    pm=!randitem +,-
    !if $[$b $pm $d]=0
	d=$[$d+1]
    !endif	
    !if $[$c - 1*($pm $d)]=0
	d=$[$d+1]
    !endif
    var1=$a + $c*i - ($b $pm $d*i)
    formula$n=!texmath $var1
    answer$n=!rawmath $[($a-$b)] + $[$c - 1*($pm $d)]*i 
    !if $[$c - 1*($pm $d)]=1
	ta=$[($a-$b)] + i 
    !else
	ta=!replace internal *i by i in $(answer$n)
    !endif
    texanswer$n=!texmath $(formula$n) \rightarrow $ta
 !exit
!endif


!if $R=2
    a=!randitem -5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
    b=!randitem 1,2,3,4,5,6,7,8
    c=!randitem 2,3,4,5,6,7,8,9
    d=!randitem 2,3,4,5,6,7,8,9
    !if $[$a*$b-$c]=0
	c=$[$c+1]
    !endif
    !if $[$b+$a*$c]=0
	c=$[$c+1] 
    !endif
    var1=($a + i)*($b + $c*i)
    formula$n=!texmath $var1
    answer$n=!rawmath $[$a*$b - $c] + $[($b+$a*$c)]*i 
    ta=!replace internal *i by i in $(answer$n)
    texanswer$n=!texmath $(formula$n) \rightarrow $ta
 !exit
!endif

!if $R=3
    a=!randitem -5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
    b=!randitem 1,2,3,4,5,6,7,8
    c=!randitem 2,3,4,5,6,7,8,9
    d=!randitem 2,3,4,5,6,7,8,9
    !if $c=$b
	b=$[$c+1]
    !endif
    var1=$a+$d*i*($b - $c*i)^2
    formula$n=!texmath $var1
    answer$n=!rawmath $[$a+2*$b*$c*$d] + $[$d*$b*$b -$d*$c*$c]*i
    ta=!replace internal *i by i in $(answer$n)
    texanswer$n=!texmath $(formula$n) \rightarrow $ta
 !exit
!endif

!if $R>3
    a=!randitem -5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
    b=!randitem 1,2,3,4,5,6,7,8
    c=!randitem 2,3,4,5,6,7,8,9
    d=!randitem 2,3,4,5,6,7,8,9
    !if $[$b*$c]=$[$a*$d]
	b=$[$b+1]
    !endif
    !if $[$b*$c]=$[-1*$a*$d]
	b=$[$b+1]
    !endif
    var1=($a+$b*i)/($c + $d*i)
    formula$n=!texmath $var1 
    tussen=!exec pari b1=($a*$c+$b*$d)/($c*$c + $d*$d)\
    b2=($b*$c - $a*$d)/($c*$c + $d*$d)
    
    B1=!line 1 of $tussen
    B2=!line 2 of $tussen
    answer$n=!rawmath $B1 + $B2*i 
    ta=!replace internal *i by i in $(answer$n)
    texanswer$n=!texmath $(formula$n) \rightarrow $ta
 !exit
!endif


