这个Blog里曾经多次提到过超强数学软件Mathematica,但目前为止我还没发现它的Linux版,Wine似乎也没有用。其实,在Linux下也有很多类似于Mathematica的数学软件,其中Maxima是我用的最多的一个。这里简单介绍一下Maxima的各个函数供大家参考,也方便我自己今后查询。
安装:sudo apt-get install maxima maxima-share
运行:maxima
退出:quit();
基本运算(%i1) 2+3;
(%o1) 5
(%i2) 5*6;
(%o2) 30
(%i3) %+2;
(%o3) 32
(%i4) %o1*%o3;
(%o4) 160
(%i5) 4/7+3/4;
37
(%o5) --
28
(%i6) float(%);
(%o6) 1.321428571428571
(%i7) 2^32;
(%o7) 4294967296
(%i8) 30!;
(%o8) 265252859812191058636308480000000
(%i9) float(sqrt(2));
(%o9) 1.414213562373095
三角函数和对数函数(%i1) float(sin(1));
(%o1) 0.8414709848079
(%i2) sin(%pi/2);
(%o2) 1
(%i3) sin(%pi/2)+cos(%pi/3);
3
(%o3) -
2
(%i4) float(sec(%pi/3)+csc(%pi/3));
(%o4) 3.154700538379252
(%i5) log(1);
(%o5) 0
(%i6) float(log(10));
(%o6) 2.302585092994046
(%i7) log(%e);
(%o7) 1
(%i8) log(2^a);
(%o8) log(2) a
(%i9) %e^log(2);
(%o9) 2
变量操作(%i1) a^2-b^2;
2 2
(%o1) a - b
(%i2) a:3;
(%o2) 3
(%i3) a^2-b^2;
2
(%o3) 9 - b
(%i4) b:2;
(%o4) 2
(%i5) a^2-b^2;
(%o5) 5
(%i6) kill(a);
(%o6) done
(%i7) kill(b);
(%o7) done
(%i8) a^2-b^2;
2 2
(%o8) a - b
函数操作(%i1) f(x):=x^2-1;
2
(%o1) f(x) := x - 1
(%i2) f(2);
(%o2) 3
(%i3) f(100);
(%o3) 9999
(%i4) float(f(2/3));
(%o4) - 0.55555555555556
(%i5) a:4/5;
4
(%o5) -
5
(%i6) f(a);
9
(%o6) - --
25
多项式运算(展开、合并、化简和消元)(%i1) expand((a+b)^3);
3 2 2 3
(%o1) b + 3 a b + 3 a b + a
(%i2) factor(a^2-b^2);
(%o2) - (b - a) (b + a)
(%i3) ratsimp((x^2-1)/(x+1));
(%o3) x - 1
(%i4) eliminate([x^2+x*y+z=0,3*x+5*y+z=0,x-y-2*z^2=1],[y,z]);
4 3 2
(%o4) [- x (8 x - 2 x + 19 x - 50 x + 25)]
解方程(%i1) solve(x^2-3*x+4/x=5,x);
sqrt(5) + 1 sqrt(5) - 1
(%o1) [x = - -----------, x = -----------, x = 4]
2 2
(%i2) funcsolve(f(n)*(n+1)+2*n=1-f(n)/n,f(n));
n (2 n - 1)
(%o2) f(n) = - -----------
2
n + n + 1
(%i3) solve([x+3*y=10,1/x+x*y=4],[x,y]);
sqrt(69) - 9 4 sqrt(3) sqrt(23) - 34
(%o3) [[x = 1, y = 3], [x = - ------------, y = -----------------------],
2 9 sqrt(3) sqrt(23) - 75
sqrt(69) + 9 4 sqrt(3) sqrt(23) + 34
[x = ------------, y = -----------------------]]
2 9 sqrt(3) sqrt(23) + 75
(%i4) solve(x^2+b*x+c=0,x);
2 2
sqrt(b - 4 c) + b sqrt(b - 4 c) - b
(%o4) [x = - ------------------, x = ------------------]
2 2
(%i5) find_root(x^x=2,x,1,2);
(%o5) 1.559610469462369
(%i6) find_root(sin(x)=x/2,x,0.1,%pi);
(%o6) 1.895494267033981
数论相关(%i1) mod(100,7);
(%o1) 2
(%i2) primep(3214567);
(%o2) true
(%i3) next_prime(200);
(%o3) 211
(%i4) factor(1001);
(%o4) 7 11 13
(%i5) factor(30!);
26 14 7 4 2 2
(%o5) 2 3 5 7 11 13 17 19 23 29
(%i6) gcd(200,780);
(%o6) 20
(%i7) binomial(7,4);
(%o7) 35
(%i8) fib(7);
(%o8) 13
画函数图像(%i1) plot2d(x^3+2*x^2-3,[x,-2,2]);
*** X11 output driver not found, switching to dumb terminal!
*** If you want to use the X11 output, please install the gnuplot-x11 package
14 ++-------+--------+--------+--------+-------+--------+--------+-------++
+ + + + + + x^3+2*x^2-3 $$$$$$ $
12 ++ $+
| $ |
10 ++ $ ++
| $ |
| $ |
8 ++ $ ++
| $ |
6 ++ $$ ++
| $$ |
4 ++ $$ ++
| $$ |
2 ++ $$ ++
| $$$ |
| $$ |
0 ++ $$$ ++
| $$$$ |
-2 ++$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$ ++
$$ + + $$$$$$$$$$$$$$$$ + + + +
-4 ++-------+--------+--------+--------+-------+--------+--------+-------++
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
(%o1)
你可以通过安装gnuplot-x11让maxima在X上画图,安装方法是:sudo apt-get install gnuplot-x11
maxima也可以画3D图像,比如执行下面代码可以画出sin(x)cos(y)的图像,我就不贴图了,大家自己试试。plot3d(sin(x)*cos(y),[x,-2,2],[y,-2,2]);
做人要厚道
转贴请注明出处