!goto $wims_read_parm

:def
title=Racines complexes
synonyme=racines d'un nombre complexe, nombre complexe racines
input=function
!exit

:proc
!bound order between integer 2 and 100 default 2
!if x isvarof $formula
 error=bad_formula
 !exit
!endif
formula=!rawmath $formula
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
Racines
!if $order<=5
 !item $order-1 of carrées, cubiques, quartiques, quintiques
!else
 $order-ièmes
!endif
 complexes de
!htmlmath $formula
$ :
!endif

!set n=!itemcnt $result
<ul>
!for i=1 to $n
 !set l=!item $i of $result
 <li>\(r_$i\)=
 !htmlmath $l
 </li>
!next i
</ul>
!exit

