Maple
Maple
-{H|zh-hans:重定向;zh-hant:重新导向;}--{H|zh-cn:字符;zh-tw:字元;}--{H|zh-hans:文件; zh-hant:档案;}--{H|zh-hans:快捷方式; zh-hant:捷径;}--{H|zh-hans:项目;zh-hant:专案;zh-tw:计划;zh-hk:计划;zh-mo:计划;}--{H|zh-cn:计算机; zh-sg:电脑; zh-tw:电脑;}-
MAPLE是一个符号运算和数值计算软体平台
总览.
核心功能.
用户能够直接使用传统数学符号进行输入,也可以定制个性化的界面。对于数值计算有额外的支持,能够扩展到任意精度,同时亦支持符号演算及可视化。符号演算的例子参见下文。Maple内建有一种动态的命令行风格的编程语言,该语言支持具有作用域的变量。同时亦有其他语言的接口(C、FORTRAN、Java、Matlab和Visual Basic)。还具有与Excel进行交互的接口。
架构.
Maple由一个很小的由C语言编写的内核提供Maple语言。许多功能由各种来源的函数库提供。许多数值计算由NAG数值计算库, ATLAS库, GNU多精度库提供。大部分库由Maple语言编写,并且可查看源代码。
Maple中不同的功能需要不同格式的数值数据。符号表达式在内存中以有向无环图的形式存储。标准界面和计算界面由Java语言编写。经典界面由C语言编写。
Maple代码示例.
简单指令式程序的构造:
myfac := proc(n::nonnegint)
local out, i;
out := 1;
for i from 2 to n do
out := out * i
end do;
out
end proc;
一些简单的函数也可以使用直观的箭头表示法表示
myfac := n -> product( i, i=1..n );
开方.
evalf[100](2^1/12)
1.059463094359295264561825294946341700779204317494185628559208431458761646063255722383768376863945569
求根.
f:=x^2-63*x+99=0;
solve(f,x);
formula_1, formula_2
f := x^7+3*x = 7;
solve(f,x);
RootOf(formula_3, index = 1),
RootOf(formula_3, index = 2),
RootOf(formula_3, index = 3),
RootOf(formula_3, index = 4),
RootOf(formula_3, index = 5),
RootOf(formula_3, index = 5),
RootOf(formula_3, index =7),
evalf(%);
f := sin(x)^3+5*cosh(x) = 0;
formula_10
> solve(f, x);
RootOf(formula_11
> evalf(%);
0.2873691672 - 1.111497506 I
求解方程和不等式.
根据formula_12,寻找formula_13的所有整数解。
solve({x-y > 6, (x+y)^5 = 9}, [x, y])[];
答案:
formula_14
> p1 := x*y*z-x*y^2-z-x-y; p2 := x*z-x^2-z-y+x; p3 := z^2-x^2-y^2;
> sys := {p1, p2, p3};
> var := {x, y, z};
> solve(sys, var);
{x = 0, y = y, z = -y}, {x = 3, y = 4, z = 5}, {x = 1, y = 0, z = -1}
> f1 := cos(x)+sin(3*y)+tan(5*z) = 0;
> f2 := cos(3*z)+tan(3*y^2)-sin(2*z^3) = 33;
> f3 := tan(4*x+y)-sin(5*y-4*z) = 2*x;
> sys1 := {f1, f2, f3};
> var1 := {x, y, z};
{x, y, z}
> fsolve(sys1, var1);
{x = -10.77771790, y = -2.397849343, z = -7.382158103}
矩阵与行列式.
计算矩阵的行列式。
M:= Matrix(1,2,3, [a,b,c], x,y,z); # 矩阵样例
formula_15
with(LinearAlgebra)
m:=Determinant(M);
答案:formula_16
with(VectorCalculus);
w:=Wronskian([1,x,x^3+x-1],x)
Matrix(3, 3, {(1, 1) = 1, (1, 2) = x, (1, 3) = x^3+x-1, (2, 1) = 0, (2, 2) = 1, (2, 3) = 3*x^2+1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 6*x})
d:=Determinant(w);
6x
J := Jacobian([r*sin(t)), r^2*cosh(t)], [r, t]);
m:=Matrix(2, 2, {(1, 1) = cos(t), (1, 2) = -r*sin(t), (2, 1) = sinh(t), (2, 2) = r*cosh(t)})
d:=Determinant(m);
sin(t)*r^2*sinh(t)-2r^2cos(t)cosh(t)
f := x^3+y*cos(x)+t*tan(y))
with(VectorCalculus);
h:=hessian(f,[x,y,t]);
formula_17
积分.
求formula_18.
int(cos(x/a), x);
答案:formula_19
求formula_20.
int(sin(x/a), x);
答案:formula_21
注意:Maple在积分时不提供常数项C,必须自行补上。
> int(cos(x/a), x = 1 .. 5);
16 a sin(1/a)* cos^4(1/a) - 12 a sin^2(1/a)
求解线性微分方程.
计算以下线性常微分方程的一个精确解formula_22初始条件为formula_23
dsolve( {diff(y(x),x,x) - 3*y(x) = x, y(0)=0, D(y)(0)=2}, y(x) );
答案:formula_24
非线性常微分方程.
dsolve(diff(y(x), x, x) = x^2*y(x))
解:
formula_25BesselI(formula_26,formula_27formula_28)
+formula_29BesselK(formula_26,formula_27formula_28)
级数展开.
series(tanh(x),x=0,15)
formula_33
formula_34
f:=int(exp^cosh(x),x)
series(f,x=0,15);
formula_35
formula_36
拉普拉斯变换.
with(inttrans);
> f := (1+A*t+B*t^2)*exp(c*t);
formula_37
> laplace(f, t, s);
formula_38
invlaplace(1/(s-a),s,x)
formula_39
z := y(t);
y(t)
f := diff(z, t, t)+a*(diff(z, t)) = b*z;
formula_40
with(inttrans);
g := laplace(f, t, s);
s^2*laplace(y(t), t, s) - D(y)(0) - s y(0)
+ a s^2 laplace(y(t), t, s) - a y(0) = b laplace(y(t), t, s)
invlaplace(g, s, t);
formula_40
傅里叶变换.
with(inttrans);
fourier(sin(x),x,w)
formula_42*(Dirac(w-1)+Dirac(w+1))
绘制单变量函数图形.
绘制函数formula_43,formula_44
plot(x*sin(x),x=-10..10);
绘制双变量函数.
绘制函数formula_45,formula_46和formula_47的范围为 -1到1
plot3d(x^2+y^2,x=-1..1,y=-1..1);
绘制函数动画.
-{H|zh-hans:重定向;zh-hant:重新导向;}--{H|zh-cn:字符;zh-tw:字元;}--{H|zh-hans:文件; zh-hant:档案;}--{H|zh-hans:快捷方式; zh-hant:捷径;}--{H|zh-hans:项目;zh-hant:专案;zh-tw:计划;zh-hk:计划;zh-mo:计划;}--{H|zh-cn:计算机; zh-sg:电脑; zh-tw:电脑;}-
formula_48
with(plots);
animate(subs(k = .5, f), x = -30 .. 30, t = -10 .. 10, numpoints = 200, frames = 50, color = red, thickness = 3);
with(plots)
animate3d(cos(t*x)*sin(3*t*y), x = -Pi .. Pi, y = -Pi .. Pi, t = 1 .. 2)
求解偏微分方程组.
求解偏微分方程组
formula_49
formula_50
formula_51
条件为formula_52.
eqn1:= diff(v(x, t), x) = -u(x,t)*v(x,t):
eqn2:= diff(v(x, t), t) = -v(x,t)*(diff(u(x,t), x))+v(x,t)*u(x,t)^2:
eqn3:= diff(u(x,t), t)+2*u(x,t)*(diff(u(x,t), x))-(diff(diff(u(x,t), x), x)) = 0:
pdsolve({eqn1,eqn2,eqn3,v(x,t)<>0},[u,v]): op(%);
答案: formula_53
积分方程.
寻找函数formula_54满足积分方程
formula_55.
eqn:= f(x)-3*Integrate((x*y+x^2*y^2)*f(y), y=-1..1) = h(x):
intsolve(eqn,f(x));
答案:formula_56