




已阅读5页,还剩37页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Getting Started with MuPADThis guide is intended to quickly get you familiar with the way that MuPAD works. MuPAD has many features that we cannot cover in a short guide, but the guide should be enough to get you started. The program has a very nice on-line help facility for more detailed information.You should work through this guide by copying the commands into MuPAD. You could retype, or just use copy and paste.Contents:MuPAD as a calculatorGetting HelpSymbolic CalculationsSaving Your WorkVariablesFunctionsPlotting Graphs of FunctionsDifferentiationIntegrationSolving EquationsSolving InequalitiesLimitsComplex NumbersSums (or Series(级数)Power Series(幂级数)Matrices and VectorsSequences, Lists and SetsLibrariesMore on Matrices and VectorsExport the linear algebra libraryMore GraphicsDifferential EquationsNumerical Solution of ODEsElements of ProgrammingMuPAD ignores commentsMuPAD as a calculatorEnter the following. You could copy and paste into mupad, or retype.354/36MuPAD likes to do exact calculations. You can get approximate results by using float:float(%)The symbol % refers to the result of the last calculation. Similarly %2, %3, etc. refer to the second-to-last, third-to-last and so on.sqrt(%2)This cant be evaluated exactly so mupad just rationalises(合理的说明) the denominator(分母). You can further simplify expressions using mupads simplify:simplify(%)If theres a decimal point in an expression then mupad treats it as being approximate and gives an answer in terms of (依据) decimals:sqrt(118.0/69),sqrt(118/69) MuPAD has all the mathematical functions and operations that you find on a calculator, and many more:3!,exp(1),ln(2.3),sin(PI/4),log(2,16),cos(PI/3),arctan(1)Some other useful functions are floor,ceil,frac.floor(x) is the greatest integer less than or equal to x.ceil(x) is the least integer greater than or equal to x.frac(x) is the fractional part(小数部分) of x.Simicolons(分号) between expressions yield output on different lines but commas(逗号) keep the output on the same line. In fact, commas are used to put things in a sequence, so 3(1/2), 4 is regarded as one piece of output (a sequence) in the following.3; sqrt(3), 4; 23A colon suppresses(抑制,禁止) the preceding output, Quite useful for doing a bunch of calculations in one step:4: 23Getting HelpThere are two ways to use MuPADs Help feature. To find out more about a MuPAD function just enter ? followed by the function name.Try this:? logThe other way to get help is through the help menu. This starts a help browser that lets you search for information about MuPAD.Symbolic CalculationsThe functions expand,simplify,normal and factor are very useful for manipulating (,处理,化简) expressions:expand(2+x)3-(5+2*x)2+17)factor(%)simplify(2*x2+3*x+1)/(x+1)2)The function normal rewrites a rational expression(有理表达式) as a single fraction(分数):normal(2/x+3*(x+1)/(x2+1)simplify(sin(x)2+cos(x)2)Saving Your WorkThe File menu of MuPAD Light allows you to save your session as a text file. This can be opened with a text editor (such as TextPad if you use a PC), or a word processing program (such as MS Word). You could also just copy and paste everything into a word processing program(文字处理程序). If you need to use your MuPAD statements again, just copy and paste back into MuPAD. MuPAD Light uses a program VCAM Light to display graphics. You can copy and paste graphics into a MS Word document as well.MuPAD Pro users can do these things as well but this program allows users to save their work and graphics in notebooks.VariablesA variable can be assigned a value by using the symbol :=x:=22*x2+yy:=5If you ask MuPAD for the second-to-last output, it wont evaluate it with the new value of y%2but you can ask it to evaluate it with the eval command.eval(%)Variables need not just have numerical values in MuPAD. They can be equated to any MuPAD expression.B:= z2+5*z+1We could substitute(代替,替换) the value z = 5 into this expression using MuPADs subs command:subs(B,z=5)You list all of the variables that you are using with the function anames.anames(All, User)Variables can be deleted from memory and youll need to do this from time to time(不时的) when you use variables for different things.delete B, y:Now if we enter these variables then MuPAD just displays their symbols because they dont have values.B,yFunctionsWe have alrady seen that MuPAD has lots of built-in functions. We can also build our own functions.e.g. The function f(x) = x2+1 can be thought of as an operation that maps a number x to a number x2+1, i.e.x - x2+1.f:= x - x2+1f(2),f(a)Composition of functions is handled with MuPADs operator. As an example, to compute ,withg:= x - 2*x:just do this:h:= fgh(3)Alternatively, you could define h more explicitly(明确地,明白地):h:= x - f(g(x)Functions of two or more variables can be written like this:g:= (x,y)-x*yg(2,5)Its easy to write piece-wise defined functions(分段函数) in MuPAD. For example, lets enter the following function into MuPAD:f:= x- piecewise(x=-1 and x=3,x2)Plotting Graphs of FunctionsFunctions are easily plotted with plotfunc2d.plotfunc2d(sin(x), cos(x), x = -PI.PI)We can also specify the plot range in the y-direction and the number of points used to create the graph:plotfunc2d(x+1)/(x2-5), x = -8.8, y=-10.10)The default title of a graph is just the mathematical expression for what is being graphed. But you can change this with the Title option:f:=x-piecewise(x=-1 and x=3,x2-8):plotfunc2d(f(x),x=-3.4, Title = Graph of f(x)You can also change the axis labels. For example, to plot the relation w = t2, with fancy axis labels, do something like this:plotfunc2d(t2, t=-2.2, AxesTitles= time t (hours), distance w (metres)You can plot functions of two variables with plotfunc3d:plotfunc3d(1-x2-y2,x=-2.2,y=-2.2)You can even plot a number of functions, as well as specifying the number of grid points for the plot, and the point from where the plot is viewed:plotfunc3d(1-x2-y2, 3-2*x-2*y, x=-2.2, y=-2.2, Mesh=20,30,CameraDirection = -20, 5, 0)DifferentiationThe function diff differentiates:diff(x3,x)Higher order derivatives(高阶微分) are computed like this 4th derivative:diff(exp(a*x),x $4)But MuPAD also understands prime notation for derivatives.sin(x)g:=x-3*cos(x2+1):g(x)Partial derivatives(偏微分) are handled with diff. For example, to calculate ,enter the following:diff(h(x,y),x $2,y $3)The output shows another way to enter partial derivatives.diff(h(x, y), x, x, y, y, y)IntegrationUse int for indefinite or definite integrals(定积分):int(1/sqrt(1-x2),x)This is the antiderivative(原函数,反导数). Dont forget to include an arbitrary constant(任意常数)!To calculate just do this:int(1/sqrt(1-x2),x=0.1)Infinity is represented by infinity:int(1/(1+x2),x=-infinity.infinity)Sometimes there is no nice expression for an integral. In this case , MuPAD just returns the formula that you gave it. But you could still get a numerical approximation(近似值) to a definite (exp(-x3),x=0.3)float(%)If youre calculating integrals using partial fractions(部分分式,), youll find the partfrac function handy(很方便的):partfrac(2*x3+3*x+1)/(x+1)*(x+2)2), x)Solving Equationsz:=solve(x2+2*x+2)/(x+3)There are two solutions. To pick out the first solution, try this:z1solve(tan(y) = 1, y)This example involves an arbitrary constant that belongs to the set of integers(整数集) (Z_ in MuPAD). MuPAD denotes(表示) arbitrary constants with symbols X1, X2, X3, etc.To solve a system of equations, enclose the equations and the variables with curly braces(大括号):solve(2*x2+y=5, x+3*y=10, x, y)solve(a*x2+b*x+c=0,x)Notice that MuPAD lists all possible cases: The set of all complex numbers if a, b and c are all zero; the empty set if a and b are zero and c is not zero; -c/b if a=0 and b is not zero; and the usual solution to the quadratic equation(二次方程式) if a is non-zero.If we tell MuPAD that a is not zero then the solution simplifies:assume(a0): solve(a*x2+b*x+c=0,x), unassume(a)Solving InequalitiesThe function solve also solves inequalities.solve(2*x2-5*x+3=0, x)One use for this is to find out where a function is increasing.f:=x-(2*x+1)/(3*x+5)solve(f(x)0,x),simplify(%);/*此应该用simplifyp化简命令化简,MATLAB中还有一个simple也可以化简。*/Another example:solve(3*x+10,x)Limitslimit(sin(x)/x, x=0)limit(3*x2+6)/(2*x2+sin(x), x=infinity)limit(x/abs(x),x=0)Left or right limits may exist even if the actual limit does not, and they are easy to compute:limit(x/abs(x),x=0, Left),limit(x/abs(x),x=0, Right)Complex NumbersMuPAD denotes i= sqrt(-1) with the symbol I.solve(x2+x+1=0,x)The function rectform expresses a complex number in the form x +Iy.rectform(z): computes the rectangular form of the complex expression ,it splits(分裂) into .将复数转化成直角坐标的形式,即的形式.rectform(ln(1+I)Real and imaginary parts(实部与虚部) of complex numbers(复数) are found with Re and Im and the conjugate(共轭复数) with conjugate.Re(%), Im(3+2*I), conjugate(4+7*I)The absolute value of a complex number is found with abs and the argument(辐角)with arg:abs(1+5*I), arg(2+I)Sums (or Series(级数)To computeuse MuPADs sum function:sum(1/n2,n=1.infinity)sum(k,k=1.n)sum(n*exp(-n),n=1.5)sum(sin(n)/n, n=1.infinity)Although the answer is real, its written in terms of complex numbers. Use rectform to get an expression which doesnt involve complex numbers.rectform(%) /将一个复数化为x+iy形式,若没用y,也就说明这个数是实数;Sometimes MuPAD cant give a nice expression for a sum:sum(1/(n4+sqrt(n),n=1.infinity)but MuPAD can still give a numerical approximation:float(%)the Riemann zeta function , when z equal four:sum(1/nk,n=1.infinity)|k=4Power Series(幂级数)To compute 5 terms Taylor Series of cos(t) about t=PI, enter:taylor(cos(t),t=PI,5)taylor(cos(t)/t2, t=0, 4)Error: cos(t)/t2 does not have a Taylor series expansion, try series taylorseries(cos(t)/t2, t=0, 4)Matrices and VectorsMatrices and vectors are written as in these examples:A:=matrix(1, 5, 7, 6, 1, 4);b:=matrix(1,7,9);c:=matrix(6,7)To get the entries(条目) of matrices and vectors, useA1,3, b3, c2MuPAD makes use of +, *, - and for matrix algebra.A*b, c*AF:=matrix(1, 3,4, 2); G:=matrix(-2, 1, 5, 2);F+G, F*G, 2*F-3*G, F(-1), 1/FNotice that 1/F and F(-1) both give the inverse of a matrix. You can also compute the exponential of a square matrix:exp(t*F)Other useful functions for matrices and vectors are in the linear algebra library, linalg. Well return to this topic after discussing libraries. But first we should take a closer look at some other MuPAD objects that weve encountered, sequences, lists and sets, because these look a bit like vectors.Sequences, Lists and SetsIn MuPAD, a sequence is a collection of MuPAD expressions separated by commas:mysequence:= sin(t), 1, sqrt(9), 4*t3This is a single MuPAD object. But parts of it can be extracted. To get the fourth element:mysequence4When you enter MuPAD commands which involve commas you are actually entering sequences. e.g. the derivative of sin(t) is obtained by entering diff(sin(t), t). Heresint, t is the sequence.b:= sin(t), tdiff(b)Sometimes sequences involve repeated elements. MuPADs $ operator does that for us: To put n copies of an element into a sequence, just enter the object followed by $n.x, y $2, t $3Now the command diff(f(t), t $3) for the third derivative of a function should make more sense!The $ operator also works when you have an expression for the nth element of a sequence:n2 $n = 3.6Lists are sequences enclosed by square brackets (中括号,方括号). These are often used to represent points in space. Here are some examples of lists:1,2,ln(t),5,mylist:=1+0.2*i $i = 0.5Its easy to pick out individual components(独立部件) of lists:mylist2,mylisti $i=2.5Applying op removes the square brackets and converts the list into a sequence.op(mylist)Lists look just like vectors, but theyre not vectors:v1:=1,2,4, v2:=2,-4,2:v1+v2But we already know how to make a vector from a list:v1:=matrix(v1): v2:= matrix(v2):v1+v2You could use op to convert a matrix or list to the corresponding sequence:op(v1); op(v1)Sets are similar to lists but they are designed to represent the mathematical idea of a set. They are constructed by enclosing a sequence with curly brackets (大括号). MuPAD often reorders the elements just to remind you that order doesnt really matter for sets.A:=12, s, t, 54Elements of a set may be selected in the same way that they are selected for vectors, lists and sequences. Note that the order probably wont be the same as the original order:A1Sometimes you might wish to check to see if a set contains a certain element. The function bool evaluates alogical statement:bool(s in A)LibrariesMuPADs basic set of features that we have discussed so far are found in its standard library, stdlib, which is automatically exported into computer memory when MuPAD is started. There are many other libraries, and these can be found with the info command:info()- Libraries:Ax,Cat,Dom,Network,RGB,Series,Type,adt,combinat,detools,fp,generate,groebner,import,intlib,linalg,linopt,listlib,matchlib,module,numeric,numlib,ode,orthpoly,output,plot,polylib, prog,property, solvelib,specfunc, stats,stdlib,stringlib, student, transformTo get information about a particular library:info(linalg)Library linalg: the linear algebra package- Interface:linalg:addCollinalg:addRowlinalg:adjointlinalg:anglelinalg:basislinalg:charmatlinalg:charpolylinalg:collinalg:companionlinalg:concatMatrixlinalg:condlinalg:crossProductlinalg:curllinalg:delCollinalg:delRowlinalg:detlinalg:divergencelinalg:eigenvalueslinalg:eigenvectorslinalg:expr2Matrixlinalg:factorCholeskylinalg:factorLUlinalg:factorQRlinalg:frobeniusFormlinalg:gaussElimlinalg:gaussJordanlinalg:gradlinalg:hermiteFormlinalg:hessenberglinalg:hessianlinalg:hilbertlinalg:htransposelinalg:intBasislinalg:inverseLUlinalg:invhilbertlinalg:invpascallinalg:invvandermondelinalg:isHermiteanlinalg:isPosDeflinalg:isUnitarylinalg:jacobianlinalg:jordanFormlinalg:kroneckerProductlinalg:laplacianlinalg:matdimlinalg:matlinsolvelinalg:matlinsolveLUlinalg:minpolylinalg:multCollinalg:multRowlinalg:ncolslinalg:nonZeroslinalg:normalizelinalg:nrowslinalg:nullspacelinalg:ogCoordTablinalg:orthoglinalg:pascallinalg:permanentlinalg:potentiallinalg:pseudoInverselinalg:randomMatrixlinalg:ranklinalg:rowlinalg:scalarProductlinalg:setCollinalg:setRowlinalg:smithFormlinalg:stackMatrixlinalg:submatrixlinalg:substitutelinalg:sumBasislinalg:swapCollinalg:swapRowlinalg:sylvesterlinalg:toeplitzlinalg:toeplitzSolvelinalg:trlinalg:transposelinalg:vandermondelinalg:vandermondeSolvelinalg:vecdimlinalg:vectorOflinalg:vectorPotentiallinalg:wiedemannTo get help on functions within this library, enter something like:? linalg:detThere are two ways of accessing det. Without exporting the whole linear algebra library you could do this:G:=matrix(-2, 1, 5, 2); linalg:det(G)Otherwise you could use the whole linear algebra library and then use det directly (as well as many other functions).use(L, f) :exports the public function L:f of the library L to the global namespace such that it can be accessed as f without the prefix(前辍) L. use(L): exports all public functions of the library L.use(linalg)det(G), eigenvalues(G)More on Matrices and VectorsHere are some other operations that you can now do on matrices and vectors:u:=matrix(1,2,3); v:=matrix(-2,4,2)Export the linear algebra libraryif you havent already done so (see the last section). All of the functions discussed in this section require linalg.scalarProduct(u,v)crossProduct(u,v)A:=matrix(1, 5, 7, 8, 6, 1, 4, 1)transpose(A),eigenvectors(G)The function eigenvectors lists each eigenvalue(特征值), its multiplicity(重数) and a set of linearly independent eigenvectors(线性无关特征向量) for the eigenvalue. In this case the eigenvalues are -3 and 3, each with multiplicity 1.The characteristic polynomial (特征多项式)of G is found using:charpoly(G,x)Weve already seen how to solve general equations. To solve linear equations (which can be written in the form Ax=b), use matlinsolve:b:=matrix(1,2):matlinsolve(A,b)So the solution of the system Ax = b is a particular vector(特解向量) plus a linear combination of two others.Here are some other functions that you might find useful:linalg:factorLUlinalg:jordanFormlinalg:nullspacenumeric:eigenvectorsnumeric:eigenvaluesnumeric:matlinsolvenumeric:detnumeric:linsolvelinsolveMore GraphicsParametrised Curves:This function defines a parametrised spiral:R:= r - r*sin(r),r*cos(r)Use plot:Curve2d to plot such a curve.curve:=plot:Curve2d(R(r), r = 0.35) /在此能否加入参数Mesh呢?plot(curve)Parametrised Surfaces:These exist in 3 dimensional space, so we need plot:Curve3d .mycone:= u-sin(u)*cos(20*u),sin(u)*sin(20*u),cos(u)curve:=plot:Curve3d( mycone(u), u = 0. a, a =0.PI)plot(cur
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度智能设备安装与销售一体化服务合同范本
- 2025年度农业科技成果转化与应用推广合同
- 2025年新型城镇化建设中电缆敷设施工及售后服务合同
- 2025年度航天科技咨询服务合同
- 2025年度新型生态挡土墙施工劳务合同模板
- 2025保密协议培训与知识产权战略规划合同
- 2025二手房暂不过户房屋租赁与转租合同范本
- 2025版商厅出租合同附租金递增条款
- 2025贷款合同范本旅游产业开发贷款合作
- 2025版实习岗位需求实习合同范本
- 2025年残联招聘笔试大纲解读与备考指南
- 2025版厂房装修施工安全责任合同模板
- GB 16808-2025可燃气体报警控制器
- 医疗机构重点部门感染预防与控制标准WST860-2025解读宣贯
- 气体灭火系统日常维护管理手册
- 2025年汽车后市场行业当前市场规模及未来五到十年发展趋势报告
- 德育副校长工作总结课件
- 业财一体化课件
- 2025年安管人员继续教育试题及答案
- 超声弹性成像技术规范
- 钢材冷弯项目投资可行性研究分析报告(2024-2030版)
评论
0/150
提交评论