Maple

維基百科,自由的百科全書
跳至導覽 跳至搜尋
Maple
File:Maple 2015 logo.svg
開發者楓軟英語Waterloo Maple
首次發布1982年,​44年前​(1982
目前版本2020.1(2020年6月10日,​6年前​(2020-06-10[±][1]
原始碼庫
  • {{URL|example.com|可选的显示文本}}
Module:EditAtWikidata第29行Lua錯誤:attempt to index field 'wikibase' (a nil value)
程式語言C語言, Java, Maple language
引擎
    Module:EditAtWikidata第29行Lua錯誤:attempt to index field 'wikibase' (a nil value)
    作業系統跨平台
    類型電腦代數系統
    許可協定私有
    網站www.maplesoft.com/products/maple/

    MAPLE是一個符號計算數值計算軟體平臺。

    總覽[編輯]

    核心功能[編輯]

    使用者能夠直接使用傳統數學符號進行輸入,也可以客製化個性化的介面。對於數值計算有額外的支援,能夠擴充到任意精度,同時亦支援符號演算及視覺化。符號演算的例子參見下文。Maple內建有一種動態的命令列風格的程式語言,該語言支援具有範疇的變數。同時亦有其他語言的介面(C、FORTRAN、Java、Matlab和Visual Basic)。還具有與Excel進行互動的介面。

    架構[編輯]

    Maple由一個很小的由C語言編寫的核心提供Maple語言。許多功能由各種來源的函式庫提供。許多數值計算由NAG數值計算庫, ATLAS庫, GNU多精度庫提供。大部分庫由Maple語言編寫,並且可檢視原始碼。

    Maple中不同的功能需要不同格式的數值資料。符號表達式在主記憶體中以有向無環圖的形式儲存。標準介面和計算介面由Java語言編寫。經典介面由C語言編寫。


    版本[編輯]

    版本 年份
    Maple 1.0 1982年1月
    Maple 1.1 1982年
    Maple 2.0 1982年5月
    Maple 2.1 1982年6月
    Maple 2.15 1982年8月
    Maple 2.2 1982年12月
    Maple 3.0 1983年5月
    Maple 3.1 1983年10月
    Maple 3.2 1984年4月
    Maple 3.3 1985年3月(第一個公開版本)
    Maple 4.0 1986年4月
    Maple 4.1 1987年5月
    Maple 4.2 1987年12月
    Maple 4.3 1989年3月
    Maple V 1990年8月
    Maple V R2 1992年11月
    Maple V R3 1994年3月15日
    Maple V R4 1996年1月
    Maple V R5 1997年11月1日
    Maple 6 2000年1月31日
    Maple 6.01 ?年?月
    Maple 6.02 ?年?月
    Maple 7.00 2001年5月28日
    Maple 7.01 ?年?月
    Maple 8.00 2002年4月22日
    Maple 9.00 2003年6月30日
    Maple 9.01 2003年7月10日
    Maple 9.02 2003年?月
    Maple 9.03 2003年11月5日
    Maple 9.50 2004年4月7日
    Maple 9.51 2004年8月17日
    Maple 9.52 2005年1月21日
    Maple 10 2005年5月13日
    Maple 10.01 2005年?月
    Maple 10.02 2005年11月8日
    Maple 10.03 ?年?月
    Maple 10.04 2006年5月30日
    Maple 10.05 2006年6月9日
    Maple 10.06 2006年10月2日
    Maple 11.0 2007年2月17日
    Maple 11.01 2007年7月10日
    Maple 11.02 2007年11月10日
    Maple 12.0 2008年4月10日
    Maple 12.01 2008年10月
    Maple 12.02 2008年12月
    Maple 13.0 2009年4月13日
    Maple 13.01 2009年7月8日
    Maple 13.02 2009年7月8日
    Maple 14.00 2010年4月5日
    Maple 14.01 2010年10月28日
    Maple 15 2011年4月13日
    Maple 15.01 2011年6月2日
    Maple 16 2012年3月28日
    Maple 16.01 2012年5月16日/8月27日
    Maple 16.02 2012年11月18日
    Maple 17.00 2013年2月21日/3月13日/4月10日
    Maple 18.00 2014年3月6日
    Maple 18.01 2014年5月
    Maple 18.01a 2014年7月
    Maple 18.02 2014年11月
    Maple 2015 2015年3月
    Maple 2015.1 2015年11月
    Maple 2016 2016年3月2日
    Maple 2016.1 2016年4月20日
    Maple 2016.1.a 2016年4月27日
    Maple 2017 2017年5月25日
    Maple 2017.1 2017年6月28日
    Maple 2017.2 2017年8月2日
    Maple 2017.3 2017年10月3日
    Maple 2018.0 2018年3月21日
    Maple 2019.0 2019年3月14日

    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

    File:12throotof2threethousanddigits.JPG

    求根[編輯]

    f:=x^2-63*x+99=0;

    solve(f,x);

    <math>\frac{63}{2}+\frac{3}{2}*\sqrt(397)</math>, <math>\frac{63}{2}-\frac{3}{2}*\sqrt(397)</math>

    f := x^7+3*x = 7;

    solve(f,x);

    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 1),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 2),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 3),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 4),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 5),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index = 5),
    RootOf(<math>Z^7 + 3 Z - 7</math>, index =7),

    evalf(%);

    • (1.1922047171828134),
    • (0.8658388666792263) + (0.9230818802764879) I,
    • (0.2099602786426775) + (1.3442579297631496) I,
    • (1.2519809466279554) + (0.6424819505558892) I,
    • (1.2519809466279554) - (0.6424819505558892) I,
    • (0.2099602786426775) - (1.3442579297631496) I,
    • (0.8658388666792263) - (0.9230818802764879) I


    f := sin(x)^3+5*cosh(x) = 0;


    <math> sin^3(x) + 5 cosh(x) = 0</math>

    > solve(f, x);


    RootOf(<math>sin^3(Z) - arccosh(\frac{-1}{5} sin(Z)))</math>

    > evalf(%);

    0.2873691672 - 1.111497506 I

    求解方程式和不等式[編輯]

    根據<math>x-y > 6</math>,尋找<math>(x+y)^5 = 9</math>的所有實數解。

    solve({x-y > 6, (x+y)^5 = 9}, [x, y])[];
    

    答案: <math>[x = 3^{2/5}-y, \quad y < \frac{1}{2}3^{2/5}-3]</math>

    方程組[編輯]

    代數方程組
    > 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]]);  # 矩阵样例
    
    <math>
     \begin{bmatrix}
       1 & 2 & 3 \\
       a & b & c \\
       x & y & z
     \end{bmatrix}
    

    </math>

    with(LinearAlgebra)
    
    m:=Determinant(M);
    

    答案:<math>bz-cy+3ay-2az+2xc-3xb</math>

    朗斯基行列式

    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]);

    <math> \begin{bmatrix}

    6*x-y*cos(x) & -sin(x) & 0 \\
    -sin(x) & 2*t*tan(y)*(1+tan(y)^2) & 1+tan(y)^2 \\
    0 & 1+tan(y)^2 & 0
    

    \end{bmatrix} </math>

    積分[編輯]

    求<math>\int\cos\left(\frac{x}{a}\right)dx</math>.

    int(cos(x/a), x);
    

    答案:<math>a \sin\left(\frac{x}{a}\right)</math>

    求<math>\int\sin\left(\frac{x}{a}\right)dx</math>.

    int(sin(x/a), x);
    

    答案:<math>-a \cos\left(\frac{x}{a}\right)</math>

    注意:Maple在積分時不提供常數項C,必須自行補上。

    定積分

    > int(cos(x/a), x = 1 .. 5);


    16 a sin(1/a)* cos^4(1/a) - 12 a sin^2(1/a)

    求解線性微分方程式[編輯]

    計算以下線性常微分方程式的一個精確解<math>\frac{d^2y}{dx^2}(x) - 3 y(x) = x</math>初始條件為<math>y(0) = 0 ,\quad \left. \frac{dy}{dx} \right|_{x=0} = 2</math>

    dsolve( {diff(y(x),x,x) - 3*y(x) = x, y(0)=0, D(y)(0)=2}, y(x) );
    

    答案:<math>y(x)=\frac{7}{18}\sqrt{3}e^{\sqrt{3}x}-\frac{7}{18}\sqrt{3}e^{-\sqrt{3}x}-\frac{1}{3}x</math>

    非線性常微分方程式[編輯]

    dsolve(diff(y(x), x, x) = x^2*y(x))
    

    解:

    <math>y(x)=C_{1}\sqrt(x)</math>BesselI(<math>1 \over 4</math>,<math>1 \over 2</math><math>x^2</math>)

    +<math>C_{2}\sqrt(x)</math>BesselK(<math>1 \over 4</math>,<math>1 \over 2</math><math>x^2</math>)

    級數展開[編輯]

    series(tanh(x),x=0,15)
    
    <math>x-\frac{1}{3}\,x^3+\frac{2}{15}\,x^5-\frac{17}{315}\,x^7</math>
    <math>+\frac{62}{2835}\,x^9-\frac{1382}{155925}\,x^{11}+\frac{21844}{6081075}\,x^{13}+\mathcal{O}(x^{15})</math>
    f:=int(exp^cosh(x),x)
    series(f,x=0,15);
    
    <math>e x+\frac{1}{6}e x^3+\frac{1}{30}e x^5+\frac{31}{5040}e x^7+\frac{379}{362880}e x^9</math>
    <math>+\frac{149}{907200}e x^{11}+\frac{150349}{6227020800}e x^{13}+\frac{4373461}{1307674368000} e x^{15}+\mathcal{O}(x^{17})</math>

    拉普拉斯轉換[編輯]

    with(inttrans);

    拉普拉斯轉換

    > f := (1+A*t+B*t^2)*exp(c*t);

    <math> (1+A*t+B*t^2)*e^{c*t}</math>

    > laplace(f, t, s);

    <math>\frac{1}{s-c}+\frac{A}{(s-c)^2}+\frac{2B}{(s-c)^3}</math>

    反拉普拉斯轉換

    invlaplace(1/(s-a),s,x)

    <math>e^{ax}</math>

    z := y(t);

    y(t)
    f := diff(z, t, t)+a*(diff(z, t)) = b*z;

    <math>\frac{d^2}{dt^2}y(t)+a\frac{d}{dt}y(t)=by(t)</math>

    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);

    <math>\frac{d^2}{dt^2}y(t)+a\frac{d}{dt}y(t)=by(t)</math>

    傅立葉轉換[編輯]

    with(inttrans);

    fourier(sin(x),x,w)

    <math>\Pi</math>*(Dirac(w-1)+Dirac(w+1))

    繪製單變數函式圖形[編輯]

    繪製函式<math>y=x \cdot \sin x</math>,<math>x \in(-10,10)</math>

    plot(x*sin(x),x=-10..10);
    

    File:Mathematica1DPlot.svg

    繪製雙變數函式[編輯]

    繪製函式<math>x^2+y^2</math>,<math>x</math>和<math>y</math>的範圍為 -1到1

    plot3d(x^2+y^2,x=-1..1,y=-1..1);
    

    File:Mapleplot.jpg

    繪製函式動畫[編輯]

    二維動畫

    <math>f:=2*k^2/cosh(k*(x-4*k^2*t))^2</math>

    with(plots);

    animate(subs(k = .5, f), x = -30 .. 30, t = -10 .. 10, numpoints = 200, frames = 50, color = red, thickness = 3);

    File:Bellsoliton2.gif
    鐘形孤立子
    File:3dsincos animation.gif
    三維函式動畫
    三維動畫

    with(plots)

    animate3d(cos(t*x)*sin(3*t*y), x = -Pi .. Pi, y = -Pi .. Pi, t = 1 .. 2)

    求解偏微分方程組[編輯]

    求解偏微分方程式

    <math>

    {\frac {\partial }{\partial x}}v \left( x,t

    \right) =-u \left( x,t \right) v \left( x,t \right) 
    

    </math>

    <math>

    {\frac {\partial }{\partial t}}v \left( x,t \right) =-v \left( x,t \right) {\frac {\partial }{\partial x}}u

    \left( x,t \right) +v \left( x,t \right)  \left( u \left( x,t
    \right)  \right) ^{2}
    

    </math>

    <math>

    {\frac {\partial }{\partial t}}u

    \left( x,t \right) +2\,u \left( x,t \right) {\frac {\partial }{
    

    \partial x}}u \left( x,t \right) \frac {\partial ^{2}}{\partial {x}^{2}}}u \left( x,t \right) =0 </math> 条件为<math>v(x,t)\neq 0</math>.

    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(%);
    

    答案: <math>v \left( x,t \right) ={e^{\sqrt {{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1}x}}{\it \_C3 }\,{e^{{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1t}}{\it \_C1}+{\frac {{\it \_C3}\,{e^{{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1t}}{\it \_C2}}{{e^{\sqrt {{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1}x}}}}, \ \ u \left( x,t

    \right) =\frac {\sqrt {{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1} \left( {\it \_C1}\, \left(

    {e^{\sqrt {{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1}x}} \right) ^{2{\it \_C2} \right) }{{\it \_C1}\, \left( {e^{\sqrt {{\it \_c}_
    获取编号参数{{{1}}}的正确方式是{{{1}}},而不是{{1}}。详见Template:1}x}} \right) ^{2}+{\it \_C2}} } </math>

    积分方程[編輯]

    寻找函数<math>f</math>满足积分方程 <math>f(x)-3\int_{-1}^1(xy+x^2y^2)f(y)dy = h(x)</math>.

    eqn:= f(x)-3*Integrate((x*y+x^2*y^2)*f(y), y=-1..1) = h(x):
    intsolve(eqn,f(x));
    

    答案:<math>f \left( x \right) =\int _{-1}^{1}\! \left( -15\,{x}^{2}{y}^{23\,xy \right) h \left( y \right) {dy}+h \left( x \right) </math>

    注釋[編輯]

    • 現在,MATLAB已改用MuPAD替代了matlab的Maple符號計算核心。

    參考文獻[編輯]

    • 何青 王麗芬編著《Maple教程》 科學出版社 2010 ISBN 9787030177445
    • David Betounes, Partial Differential Equations for Computational Science: With Maple and Vector Analysis Springer, 1998 ISBN 9780387983004
    • George Articolo Partial Differential Equations & Boundary Value Problems with Maple V Academic Press 1998 ISBN 9780120644759
    1. ^ Maple Product History. [2020-03-20]. 

    外部連結[編輯]

    參見[編輯]

    Template:碎形軟體