1 / 41

提高篇

提高篇. 第二讲 Maple 数学. 内容提要. 1、寻求帮助 2、 Maple 语言基础 3、 Maple 的数据类型 4、初等数学实验 5、函数 6、 Maple 作图 7、微积分实验. 数学魔法师. 1、寻求帮助. 从 Help( 帮助)菜单按类查找 ?命令, 例: ? animate ? anim 完整帮助信息,包括六个方面: Function: 函数 Calling sequence: 命令格式 Parameters: 参数

ura
Télécharger la présentation

提高篇

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 提高篇

  2. 第二讲 Maple数学 内容提要 1、寻求帮助 2、 Maple语言基础 3、 Maple的数据类型 4、初等数学实验 5、函数 6、 Maple作图 7、微积分实验

  3. 数学魔法师 1、寻求帮助 • 从Help(帮助)菜单按类查找 • ?命令, 例: • ?animate • ?anim • 完整帮助信息,包括六个方面: Function:函数 Calling sequence:命令格式 Parameters:参数 Synopsis:说明 Examples:例 See also:相关条目 • 查找部分信息 info(命令);函数作用 usage(命令);调用格式 example(命令);实例 related(命令);相关条目 • F1

  4. 面板输入 • 选择 view 菜单下的 palettes 特定面板 特殊符号 矩阵 运算式

  5. 2、Maple语言基础 2.1 语句和表达式 • 语句类型

  6. 例: • y:=x-> if x>1 then log(x) else sin(Pi*x/2) fi; evalf(y(2.7)); evalf(y(1)); evalf(y(0)); #判断 • 函数: y= log x (x>1) sin(π x/2) (x≤1) • x:=0: for i from 1 to 100 do x:=x+i od: x; #for-do-od • 1+2+……+100 • x:=0: for i from 1 to 100 do if x>100 then exit else x:=x+i fi od: x; #嵌套, 退出 • 1+2+…… • x:=0 : j:=0: while j<=100 do x:=x+j:j:=j+1 od:x;#while-do-od • 1+2+……+100 • > x:=0 : j:=0:for j in {1,4,5} while j<=100 do x:=x+j:j:=j+1 od:x;

  7. 例: • 判断 2^(2i-1)-1, i= 1,2,…,8 是否是素数 • i f – then – else –fi • 命令 isprime(…) • for i to 8 do #省略 • a: = 2^(2*i+1)-1; • if isprime(a) then print(a, `is a`) else print (a, `is not`) fi • od • 注: 强行换行 Shift+Enter

  8. 2.2 过程(procedure) • Maple程序的主要结构 • 关键字: proc local global end • 参数:可以是空的;如:proc() 可以限制参数类型;如:proc(x :: numeric,y :: numeric) 可以用args代表所有实际输入的参数,并可用nargs测量参数的长度。

  9. 局部变量和全局变量 • a: =1; • f: =proc( ) local a; a: =105615750/456210 evalf(a/2); end: • f( ); • a; • a: =1; • f: =proc( ) global a; a: =105615750/456210 evalf(a/2); end: • f( ); • a;

  10. 例: • 过程 • 内部变量 • 判断参数长度 • 赋值 • 循环 • 判断大小 • 输出 • 试用 • Max:=proc() • local i,m; • if nargs=0 then RETURN(FAIL) end if; • m:=args[1]; • for i from 2 to nargs do • if args[i]>m then m:=args[i] end if ; • end do; • m; • end: • Max(2,5,4,7,4,6,4);

  11. 3、 Maple的数据类型 3.1 基本数据类型

  12. 3.2 复合数据类型

  13. 3.3 软件包 • 软件包:

  14. 4、初等数学实验 4.1 数字运算 • 整数、分数运算 >p:=1153*(3^58+5^40)/(29!-7^36); • 常用运算符:+,-,*,/,^或**,abs( ) • 浮点运算 >evalf(p,20); 2→ 2.0 • 数学常数 Pi(p大写)、I(复数单位)、infinity(无穷) >Pi;infinity;

  15. 4.2 基本代数运算 • 运算符 • 基本初等函数 sqrt、^ 、exp、log、sin、cos、tan、cot、sec、csc、arc • 数值显示

  16. 例: • 3!**6; • sin(5); exp(1); • %;%% • evalf(Pi,100);

  17. 4.3 多项式 • 定义 • y:=x-> x^3-2*x^2-5*x+6;………….y(x) • z:=x^2-5*x+4; • 算术运算 • 例 • 将100!分解成素数?第1000个素数是什么? • ifactor(100!);ithprime(1000); • 例 • w:=y(x)/z; y(x)*z; y(x)-z; • gcd(y(x),z); lcm(y(x),z); • quo(y(x),z,x,'r');r;

  18. 重组 • 例: • factor(y(x)); (2*x^2-5*x+6)*z; expand(%); • 求根 • 例: • t:=x^3+2; fsolve(t);fsolve(t,x,complex); • realroot(t); roots(t); solve(t); evalf(%);

  19. 4.4 有理式 • 例: s:= (x^3-2*x^2-5*x+6)/(x^2-5*x+4); • 例: • %+x; • simplify(%);simplify(%%%); Maple

  20. 5、函数 • 自定义函数 赋值法 f:=数 或 表达式; (后赋值将替换以前的赋值, 加单引号表示符号变量) 箭头算子法 f:=x->表达式、f::=(x,y)-> 表达式; >y:=x^2-5*x+3;y(3); >y:=x->x^2-5*x+3;y(3); • 函数运算 函数可以进行+,-,*,/,@(复合运算)

  21. 说明: 函数定义

  22. 例: • lc := proc( s, u, t, v ) • description "form a linear combination of the arguments": • s * u + t * v • end proc: • print( lc ); • lc( Pi, x, -I, y ); • p:=proc(x) if x>1 then x^2-1 else 2*(1-x) fi end:p(2); • p:=piecewise(x>1,x^2-1,2*(1-x) );

  23. 6 Maple作图 • 基本命令 • 二维图形

  24. 三维图形 • 其他

  25. 例: • > plot(x^2,x=-3..3); >plot(2*x^3-6*x,x=-2.5..2.5,style=point,symbol=box); >plot([4*x-x^2+2,x^2,3*x+1],x=-2..5, color=[red,blue,green], linestyle= [20, 20]) >f:=10*sin(x)*exp(-x^2):#先定义函数 >plot(f,x=-2..5,color=green,linestyle=20);作上述函数图 >f:=x->sin(x)*exp(x): plot(f(x),x=-2..5); • > plot({[sin(t),cos(t),t=0..2*Pi],2*x-1},x=-2..2,y=-2..2); • >with(plots):animate(sin(t*x),x=-2*Pi..2*Pi, t=.5..4, color=1, linestyle =30);

  26. • 极坐标 > plot([sin(4*x),x,x=0..2*Pi],coords=polar,thickness=3); >with(plots):animate([sin(x*t),x,x=-4..4],t=1..4, coords=polar, numpoints=100,frames=100); • 曲面图: > plot3d(x^2+y^2,x=-2..2,y=-2..2,color=0.1); • 动画图 > with(plots): > animate3d( cos(t*x)*sin(t*y), x=-Pi..Pi, y=-Pi..Pi, t=1..2 ); • 三维曲线图:plot3d([x(t),y(t),z(t)],t=t1..t2],z=z1..z2,选项); >plot3d([cos(t),sin(t),t],t=0..3*Pi,z=a..b);

  27. 7、微积分实验 7.1 极限 • 格式 • limit(f(x), 极限点,选项)为极限计算指令 Limit (f(x), ……) 为极限符号,可用value显示值

  28. 例: • >Limit((x-sin(x))/x^3,x=0)=limit((x-sin(x))/x^3,x=0); >Limit(exp(1/x),x=0,left)=limit(exp(1/x),x=0,left); >Limit((x^2-3*x+2)/(5*x^2-4),x=infinity)=limit((x^2-3*x+ 2) /(5*x^2-4),x=infinity); > Limit(x^sin(x),x=0)=limit(x^sin(x),x=0); > Limit(sin(x),x=infinity)=limit(sin(x),x=infinity); > Limit(exp(x),x=-infinity)=limit(exp(x),x=-infinity); • 注:函数若由箭头算子定义,求极限函数要用f(x)形式 >y:=x->exp(x):limit(y,x=3);limit(y(x),x=3);

  29. 7.2 导数 • 格式 • diff(f,x1,x2,…) x1,x2,…为各次求混合导数的自变量 diff(f,x$m,y$n) m,n分别为对自变量x、y求导阶数 Diff 为求导符号,可用value显示值

  30. 例: • > Diff(exp(x^2),x)=diff(exp(x^2),x); >Diff(log(x+sqrt(1+x^2)),x$2); value(Diff(log(x+sqrt(1+x^2)),x$2)); simplify(value(Diff(log(x+sqrt(1+x^2)),x$2))); >Diff(x^2*cos(y),x,y$3)=diff(x^2*cos(y),x,y$3); >subs(x=3,y=4,diff(exp(sqrt(x^2+y^2)+x),x,y)); evalf(subs(x=3,y=4,diff(exp(sqrt(x^2+y^2)+x),x,y))); #计算函数在(3,4)点混合导数值 • 注:函数若由箭头算子定义,求导函数要用f(x)形式 >y:=x->sin(1/x):diff(y,x);diff(y(x),x);

  31. 7.3 积分 • 格式 • 不定积分 int(f,x) 定积分 int(f,x=a..b) Int为积分符号,用value显示值 • 重积分 int(int(f(x,y),y=y1(x)..y2(x)),x=a..b)

  32. 例: • > Int(2*x*sin(x),x)=int(2*x*sin(x),x)+c; > Int(sqrt(a^2+x^2),x)=int(sqrt(a^2+x^2),x)+C; >Int((x-2)/(x^3-1),x)=int((x-2)/(x^3-1),x)+C; > value( Int(x*ln(x),x)); >Int((x-2)/(x^3-1),x=2..3)=int((x-2)/(x^3-1),x=2..3); >int(sin(sin(x)),x=0..2);Evalf(%); • 注:箭头算子定义函数要用int(f(x),x) >f:=x->x^2-1/x:int(f(x),x); • >Int(Int(abs(y)*x^2,y=-sqrt(1-x^2)..sqrt(1-x^2)),x=-1..1) =int(int(abs(y)*x^2,y=-sqrt(1-x^2)..sqrt(1-x^2)),x=-1..1) ;

  33. 7.4 循序渐进 • 例: • f:=sqrt(x+1)/sin(x); iscont(f,x=-0.5..1); discont(f,x); • 例: • f:=sqrt(x+1)/sin(x); diff(f,x); D(f); D(f)(2); • g:=x->sqrt(x+1)/sin(x); diff(g,x); D(f); D(f)(2); evalf(%); • eqn:=x^2+y^2=1; implicitdiff(eqn,y,x);

  34. • with(student): • expr:=Int(x^2*exp(x),x); • intparts(expr,x^2); #设u=x^2, 分部积分 • value(%);

  35. 7.5 级数 • 级数 • 例: • Sum(x^n/n!,n=0..infinity)=sum(x^n/n!,n=0..infinity); • Sum(1/k^2,k=1..infinity):%=value(%); • 1/(1-x)=series(1/(1-x),x); taylor(1/(1-x),x); • sin(x)=series(sin(x),x=Pi/2,8); > • exp(x)/x=taylor(exp(x)/x,x); • series(exp(x)/x,x); • x^3/(x^4+4*x-5)=series(x^3/(x^4+4*x-5),x=infinity);

  36. • 幂级数 • with(powseries): • powcreate(f(n)=2^n/n!): • powcreate(h(n)=(-1)^(n+1)/n,h(0)=1): • Sum(2^n*x^n/n!,n=0..infinity)=tpsform(f,x,7); • powcreate(h(n)=(-1)^(n+1)/n,h(0)=1): • Sum((-1)^(n+1)*x^n/n,n=1..infinity)=tpsform(h,x,5); • powcreate(v(n)=(v(n-1)+v(n-2))/4,v(0)=4,v(1)=2): • tpsform(v, x); • 一.> • >

  37. 7.6 方程求解 • solve(方程,未知数);fsolve(方程,未知数,选项);解数值解 选项:1.complex复数域上求根 2.fulldigits保持精度 3.maxsols=n求n个解 4.范围 (省略“=”号为=0) • >p:=x->x^2+2*x-3:plot(p(x),x=-4..2); solve(p(x)); fsolve(p (x) = 12,x); >t:=solve(6*x^4-35*x^3+22*x^2+17*x-10):t1:=eval(t[1]); t2:=eval(t[2]); t3:= eval(t[3]); t4:=eval (t [4]); >p:=x->12*x^5+32*x^4-57*x^3-213*x^2-104*x+60:plot(p,-5..5, 650.. -300); solve(p(x));

  38. • > solve({2*x+3*y,y= x+1}); • >solve(x^5-3*x^4-23*x^3+27*x^2+166*x+120=0,x); >fsolve(x^5-3*x^4-23*x^3+27*x^2+166*x+120,x, -1.5..3.5); >fsolve (x^4-3*x+4,x,complex); >fsolve(x^5-3*x^4-23*x^3+27*x^2+166*x+120=0,x, maxsols=2);

  39. 7.7 微分方程,差分方程 • 微分方程 方程中未知函数要用y(x)记,n阶导可用D@@n(y)(x), 初始条件y(x0)=a,(D@@n)(y)(x0)=b • 差分方程

  40. 例: • >dsolve({diff(y(x),x)=0.003*y (x) *(100-y (x) ),y(0)=15},y(x)); >assign(“); plot(y(x),x); > dsolve(diff(y(x),x$2) - y(x) = sin(x)*x, y(x)); • > p:= dsolve({D(y)(x) = y(x), y(0)=1}, y(x),type=numeric): #解数值解 > with(plots); > odeplot(p,[x,y(x)],-1..1 );#作微分方程数值解图 • > sys := diff(y(x),x)=z(x),diff(z(x),x)=y(x): fcns := {y(x), z(x)}: > p:= dsolve({sys,y(0)=0,z(0)=1},fcns,type=numeric): > odeplot(p, [x,y(x)], -4..4, numpoints=25);

  41. SUN 再 见

More Related