个人工具

Maxima导引

来自Ubuntu中文

Dbzhang800讨论 | 贡献2007年6月1日 (五) 12:08的版本 函数

跳转至: 导航, 搜索

来源:http://blog.chinaunix.net/u/20/showart_172159.html

作者:win_hate

函数

定义函数

注意函数使用的符号是 :=

一元函数

f(x):=expr;

例子:

(%i1) f(x):= 1+x;
(%o1)                            f(x) := 1 + x
(%i2) f(2);
(%o2)                                  3

多元函数

f(x,y):=expr;

例子:

(%i3) f(x,y):=y^2+x^2;
                                         2    2
(%o3)                         f(x, y) := y  + x
(%i4) f(2,3);
(%o4)                                 13

初等函数

幂函数: x^2, x^(-1/2),...
指数函数:2^x, (1/2)^x, exp(x), %e^x...
在 maxima 中,常数e=2.718281828459045被记为:%e. 所以指数函数 e^x 在 maxima 中被表示为:%e^x

由于这个函数的重要性,它有一个专门的记法:exp(x).

(%i2)f(x) := %e^x;
                                            x
(%o2)                             f(x) := %e
(%i3)g(x) := exp(x);
(%o3)                           g(x) := exp(x)
(%i4)expand(f(x) - g(x));
(%o4)                                  0
对数函数:log(x)
在 maxima 中,log(x) 就是自然对数,即以 e 为底的对数,数学上常记为 ln(x)。maxima 没有其它形式的对数,要使用以 10 或 2 为底的对数,只能使用换底公式。如果把下面的代码放到 ~/.maxima/maxima-init.mac 中,则 maxima 在运行时会加载自定义函数 log10、log2,并把 ln 定义为 log。这样就可以使用 log10、log2 和 ln 了。
log10(x):=log(x)/log(10);
log2(x):=log(x)/log(2);
ln:log; 
三角函数:sin, cos, tan, cot, sec, csc
在 maxima 中,pi=3.141592653589793 被记为 %pi.
反三角函数:asin, acos, atan, acot, asec, acsc

分段函数

f(x)= x-1, x<0
      0,   x=0
      x+1, x>0
(%i2) f(x) := if x < 0 then x - 1 else (if x = 0 then 0 else 1 + x);
(%o2)    f(x) := if x < 0 then x - 1 else (if x = 0 then 0 else 1 + x)
(%i3) f(- 1);
(%o3)                                 - 2
(%i4) f(0)
(%o4)                                  0
(%i5) f(1)
(%o5)                                  2

极限

导数

集合