Subversion Repositories wimsdev

Rev

Rev 6055 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
539 bpr 1
 
2
!goto $wims_read_parm
3
 
4
:def
5
title=Factorisation
6
synonyme=factoriser, factorise
7
input=function
8
!exit
9
 
10
:proc
11
vars=!varlist nofn $formula
12
!if $vars=$empty
14895 bpr 13
  result=!exec pari print(factor($formula));
14
  factor_html=
15
  result=!translate ; to $\
539 bpr 16
$ in $result
14895 bpr 17
  result=!trim $result
18
  fn=!linecnt $result
19
  !for k from 1 to $fn
20
    ii=!line $k of $result
21
    !distribute items $ii into base,power
22
    !if $k>1
23
      factor_html=$factor_html <span class="green">&times;</span>
24
    !endif
25
    factor_html=$factor_html $base
26
    !ifval $power != 1
27
      factor_html=$factor_html<sup>$power</sup>
28
    !endif
29
  !next k
539 bpr 30
!else
14895 bpr 31
  result=!exec maxima factor($formula);
539 bpr 32
!endif
33
!exit
34
 
35
:output
36
!htmlmath $formula
37
 =
38
!if $vars=$empty
14895 bpr 39
  $factor_html
539 bpr 40
!else
14895 bpr 41
  !htmlmath $result
539 bpr 42
!endif
43
!exit