MATLAB第五课 代数方程求解_第1页
MATLAB第五课 代数方程求解_第2页
MATLAB第五课 代数方程求解_第3页
MATLAB第五课 代数方程求解_第4页
MATLAB第五课 代数方程求解_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、第五章:代数方程求解和其他符号函数,1、解基本代数方程 2、二次方程求解 3、符号方程绘图 4、高阶方程求解 5、解方程组 6、方程展开与合并 7、使用指数和对数函数求解方程 8、函数的级数表示 9、习题,1 解基本代数方程, x+3=0 ? x+3=0 | Error: The expression to the left of the equals sign is not a valid target for an assignment., x=3 x = 3,用solve命令解方程, x=solve(x+3=0) x = -3, x=solve(x+3) x = -3,当你传递给solv

2、e函数x+3时,MATLAB假设你传递的就是x+3=0,提问:如果你求解的方程有时候可能含有多个符号,如ax+5=0,这个时候怎么求解?,提问:如果你在MATLAB中输入方程ax+5=0,MATLAB只认为求解x。, solve(a*x+5) ans = -5/a, solve(a*x+5,a) ans = -5/x,提问:上面研究了简单的一次方程,那么遇到二阶、三阶等方程怎么办呢?,2 二次方程求解,例如求解:x2-6x-12=0?, s=solve(x2-6*x-12=0) s = 3+21(1/2) 3-21(1/2), y=3+s(1) y = 6+21(1/2) s(1)-s(2)

3、ans = 2*21(1/2), d=x2+9*x-7=0; solve(d) ans = -9/2+1/2*109(1/2) -9/2-1/2*109(1/2),把方程赋给一个变量,然后把它传递给solve也完全是可以的,提问:上面解决了方程组求解问题,那么怎么作图呢?,3 符号方程绘图,用ezplot(d),自动显示标题, d=x2+9*x-7; ezplot(d), d=x2+9*x-7; ezplot(d,-2,8),使用ezplot注意的地方, ezplot(x+3=0) ? Error using = inlineevalError in inline expression = x

4、+3=0? Error: The expression to the left of the equals sign is not a valid target for an assignment.Error in = inline.feval at 34 INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr); Error in = specgraphprivateezplotfeval at 54 z = feval(f,x(1);Error in = ezplotezplot1 a

5、t 448y,f,loopflag = ezplotfeval(f,x); Error in = ezplot at 148 hp,cax = ezplot1(cax,f1,vars,labels,args:);, ezplot(x+3),如果: -4x4, -2y2,练习1:X2+X- =0, eq=x2+x-2(1/2); s=solve(eq) s = -1/2+1/2*(1+4*2(1/2)(1/2) -1/2-1/2*(1+4*2(1/2)(1/2), x=double(s(1) x = 0.7900 ezplot(eq),4 高阶方程求解,求(x+1)2(x-2)=0, eq=(x

6、+1)2*(x-2); solve(eq) ans = 2 -1 -1,练习:求x4-5x3+4x2-5x+6=0,并绘制-10x10范 围内的图像, eq1=x4-5*x3+4*x2-5*x+6; s=solve(eq1); a=s(1) a=5/4+1/12*3(1/2)*(43*(8900+12*549093(1/2)(1/3)+2*(8900+12*549093(1/2)(2/3)+104)/(8900+12*549093(1/2)(1/3)(1/2)+1/12*(258*(8900+12*549093(1/2)(1/3)*(43*(8900+12*549093(1/2)(1/3)+2

7、*(8900+12*549093(1/2)(2/3)+104)/(8900+12*549093(1/2)(1/3)(1/2)-6*(43*(8900+12*549093(1/2)(1/3)+2*(8900+12*549093(1/2)(2/3)+104)/(8900+12*549093(1/2)(1/3)(1/2)*(8900+12*549093(1/2)(2/3)-312*(43*(8900+12*549093(1/2)(1/3)+2*(8900+12*549093(1/2)(2/3)+104)/(8900+12*549093(1/2)(1/3)(1/2)+1530*3(1/2)*(8900

8、+12*549093(1/2)(1/3)/(8900+12*549093(1/2)(1/3)/(43*(8900+12*549093(1/2)(1/3)+2*(8900+12*549093(1/2)(2/3)+104)/(8900+12*549093(1/2)(1/3)(1/2)(1/2), double(s(1) ans = 4.2588 double(s(2) ans = 1.1164 double(s(3) ans = -0.1876 + 1.1076i double(s(4) ans = -0.1876 - 1.1076i, ezplot(eq1,-10 10),5 解方程组,解: 5

9、x+4y=3 X-6y=2, s=solve(5*x+4*y=3,x-6*y=2); x=s.x x = 13/17 s=solve(5*x+4*y=3,x-6*y=2); y=s.y y = -7/34,解: w+x+4y+3z=5 2w+3x+y-2z=1 w+2x-5y+4z=3 w-3z=9, eq1=w+x+4*y+3*z=5; eq2=2*w+3*x+y-2*z=1; eq3=w+2*x-5*y+4*z=3; eq4=w-3*z=9; s=solve(eq1,eq2,eq3,eq4); w=s.w w = 1404/127 x=s.x x = -818/127 x=s.y x =

10、-53/127 x=s.z x = 87/127,6 方程展开与合并,解:(x+2)(x+3)=x2-x-6,MATLAB中用expand命令, syms x expand(x-1)*(x+4) ans = x2+3*x-4, syms x expand(cos(x+y) ans = cos(x)*cos(7/34)+sin(x)*sin(7/34), syms x y expand(cos(x+y) ans = cos(x)*cos(y)-sin(x)*sin(y),练习:展开sin(x-y), syms x; collect(x*(x2-2) ans = x3-2*x, syms x y

11、factor(x2-y2) ans = (x-y)*(x+y), syms x simplify(x4-81)/(x2-9) ans = x2+9, syms x simplify(exp(2*log(3*x) ans = 9*x2,7 使用指数和对数函数求解方程组, clear eq eq=log10(x)-log10(x-3)=1; s=solve(eq); s(1) ans = 10/3,解方程组:y=32x y=5x+1, s=solve(y=32*x,y=5x+1) s = x: 2x1 sym y: 2x1 sym s.x(1) ans = 1/9*exp(-lambertw(-1

12、/9*log(5)*5(1/9)+1/9*log(5)+1/9 s.x(2) ans = 1/9*exp(-lambertw(-1,-1/9*log(5)*5(1/9)+1/9*log(5)+1/9, a=double( s.x(1) a = 0.2876 a=double( s.x(2) a = 1.6214, eq=exp(x)+x; s=solve(eq) s = -lambertw(1) %兰帕特函数 double(s) ans = -0.5671, ezplot(eq),7 函数级数的表示, clear x syms x s=taylor(sin(x) s = x-1/6*x3+1/120*x5 ezplot(s),这个图形很不像sin(x)图像,原因MATLAB返回只是前三

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论