maxima tutorial

  1. 安装 yum install maxima
  2. 运行 maxima
  3. 例子

    [root@localhost ~]# maxima --version
    Maxima 5.29.1
    [root@localhost ~]# maxima
    Maxima 5.29.1
    using Lisp SBCL 1.1.2-1.fc18
    Distributed under the GNU Public License. See the file COPYING.
    Dedicated to the memory of William Schelter.
    The function bug_report() provides bug reporting information.
    (%i1) 2+3;
    (%o1)                                  5
    (%i2) 1/3;
    (%o2)                                  -
    (%i3) float(1/3);
    (%o3)                          .3333333333333333
    (%i4) sum(i^2, i, 1, 3);
    (%o4)                                 14
    (%i5) ? if
     -- Special operator: if
         Represents conditional evaluation.  Various forms of `if'
         expressions are recognized.
         `if <cond_1> then <expr_1> else <expr_0>' evaluates to <expr_1> if
         <cond_1> evaluates to `true', otherwise the expression evaluates
         to <expr_0>.
         The command `if <cond_1> then <expr_1> elseif <cond_2> then
         <expr_2> elseif ... else <expr_0>' evaluates to <expr_k> if
         <cond_k> is `true' and all preceding conditions are `false'.  If
         none of the conditions are `true', the expression evaluates to
         A trailing `else false' is assumed if `else' is missing.  That is,
         the command `if <cond_1> then <expr_1>' is equivalent to `if
         <cond_1> then <expr_1> else false', and the command `if <cond_1>
         then <expr_1> elseif ... elseif <cond_n> then <expr_n>' is
         equivalent to `if <cond_1> then <expr_1> elseif ... elseif
         <cond_n> then <expr_n> else false'.
        git/ The alternatives <expr_0>, ..., <expr_n> may be any Maxima
         expressions, including nested `if' expressions.  The alternatives
         are neither simplified nor evaluated unless the corresponding
         condition is `true'.
         The conditions <cond_1>, ..., <cond_git/n> are expressions which
         potentially or actually evaluate to `true' or `false'.  When a
         condition does not actually evaluate to `true' or `false', the
         behavior of `if' is governed by the global flag `prederror'.  When
         `prederror' is `true', it is an error if any evaluated condition
         does not evaluate to `true' or `false'.  Otherwise, conditions
         which do not evaluate to `true' or `false' are accepted, and the
         result is a conditional expression.
         Among other elements, conditions may comprise relational and
         logical operators as follows.
              Operation            Symbol      Type
              less than            <           relational infix
              less than            <=
                or equal to                    relational infix
              equality (syntactic) =           relational infix
              negation of =        #           relational infix
              equality (value)     equal       relational function
              negation of equal    notequal    relational function
              greater than         >=
                or equal to                    relational infix
              greater than         >           relational infix
              and                  and         logical infix
              or                   or          logical infix
              not                  not         logical prefix
  There are also some inexact matches for `if'.
  Try `?? if' to see them.git/

(%o5)                                true
(%i6) quit ();
[root@localhost ~]# 
  1. 画图





  2. 编程




    (%i3) batch("test.max");
    read and interpret file: /root/prj/git/euler/maxima/test.max
    (%i4)                                a : 2
    (%o4)                                  2
    (%i5)                                b : 5
    (%o5)                                  5
                                        2    3
    (%i6)                               b  + a
    (%o6)                                 33
    (%o6)                 /root/prj/git/euler/maxima/test.max

    关于batch的更多用法,请查阅帮助手册中的章节13.3 Functions and Variables for File Input and Output

  3. 其他范例
    Project Euler第1题

    sum(if (mod(i, 3) = 0) or (mod(i, 5) = 0) then i else 0, i, 1, 999)

    Project Euler第2题

    for i:3 while fib(i)<=4*10^6 do (s:s+fib(i), i:i+2)$


    (%i164) batch("euler2.max");
    read and interpret file: /root/prj/euler/maxima/euler2.max
    (%i165)                              s : 0
    (%i166) for i from 3 while fib(i) <= 4 10  do (s : fib(i) + s, i : 2 + i)
    (%i167)                           display(s)
                                      s = 4613732
    (%o167)                              done
    (%o167)              /root/prj/euler/maxima/euler2.max    
  4. 相关语法说明
    ; 代码结束符
    $ 多行代码
    , 多个语句使用(sentence1, sentence2)

  5. 帮助手册