!goto $wims_read_parm

:def
title=Complex roots
synonyme=roots of a complex number, complex number roots
input=function
!exit

:proc
!bound order between integer 2 and 100 default 2
!if x isvarof $formula
 error=bad_formula
 !exit
!endif
result=!exec pari print(polroots(x^$order-($formula))~)
result=!declosing $result
result=!trim $result
result=!replace internal , by , $ in $ $result
result=!replace internal $ 0.0 + 0.0*I by 0 in $result
result=!replace internal $ 0.0 + by $ in $result
result=!replace internal $ 0.0 - by $ - in $result
result=!replace internal $ + 0.0*I by $ in $result
result=!replace internal $ - 0.0*I by $ in $result
result=!singlespace $result
!exit

:output
Complex
!if $order<=5
 !item $order-1 of square, cubic, quartic, quintic
!else
 $order-th
!endif
 roots of
!htmlmath $formula
$ :
!endif
<p><center><table border=0 cellpadding=0 cellspacing=0>
!set n=!itemcnt $result
!for i=1 to $n
 !set l=!item $i of $result
 <tr><td align=left nowrap><i>r</i><sub>$i</sub> =
 !htmlmath $l
!next i
</table></center> <p>
!exit

