Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2071 | zjchen | 1 | !goto $wims_read_parm |
2 | |||
3 | :def |
||
4 | title=Complex roots |
||
5 | synonyme=roots of a complex number, complex number roots |
||
6 | input=function |
||
7 | !exit |
||
8 | |||
9 | :proc |
||
10 | !bound order between integer 2 and 100 default 2 |
||
11 | !if x isvarof $formula |
||
12 | error=bad_formula |
||
13 | !exit |
||
14 | !endif |
||
15 | result=!exec pari print(polroots(x^$order-($formula))~) |
||
16 | result=!declosing $result |
||
17 | result=!trim $result |
||
18 | result=!replace internal , by , $ in $ $result |
||
19 | result=!replace internal $ 0.0 + 0.0*I by 0 in $result |
||
20 | result=!replace internal $ 0.0 + by $ in $result |
||
21 | result=!replace internal $ 0.0 - by $ - in $result |
||
22 | result=!replace internal $ + 0.0*I by $ in $result |
||
23 | result=!replace internal $ - 0.0*I by $ in $result |
||
24 | result=!singlespace $result |
||
25 | !exit |
||
26 | |||
27 | :output |
||
28 | Complex |
||
29 | !if $order<=5 |
||
30 | !item $order-1 of square, cubic, quartic, quintic |
||
31 | !else |
||
32 | $order-th |
||
33 | !endif |
||
34 | roots of |
||
35 | !htmlmath $formula |
||
36 | $ : |
||
37 | !endif |
||
38 | <p><center><table border=0 cellpadding=0 cellspacing=0> |
||
39 | !set n=!itemcnt $result |
||
40 | !for i=1 to $n |
||
41 | !set l=!item $i of $result |
||
42 | <tr><td align=left nowrap><i>r</i><sub>$i</sub> = |
||
43 | !htmlmath $l |
||
44 | !next i |
||
45 | </table></center> <p> |
||
46 | !exit |
||
47 |