《科学计算科学计算 (42).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (42).pdf(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、7.2 S7.2 Symbolic ymbolic C CalculusalculusLimit of symbolic functionsDerivative of symbolic functionsIntegral of symbolic functionsThe command to find the limit of the symbolic function is limit().Its syntax is asfollows:limit(f,x,a)which is used to find the limit of the function f with respect to
2、variable x at point a.This function can also be used to find the unilateral limit.Its syntax is as follows:limit(f,x,a,right)limit(f,x,a,left)1.Limit of symbolic functions1.Limit of symbolic functionsExample 1:Find the two following limits.(1)(2)limxammxaxa+lim(11)nnn syms a m x n f=(x(1/m)-a(1/m)/(
3、x-a);limit(f,x,a)ans=a(1/m-1)/m g=(1+1/n)n;limit(g,n,inf)ans=exp(1)That is exactly the natural constant e.2.D2.Derivative of symbolic functionerivative of symbolic functions sIn MATLAB,the function to evaluate derivative is:diff(f,x,n)Namely,evaluate the n-th derivative of function f with respect to
4、 variable x.The usageof parameter x is the same as the limit function.It can be default,and the diff functionuse a default master variable.n represents the order,and the default value of it is 1.(2),evaluateand .Example 2:Evaluate the derivatives of functions.symsx y z f=sqrt(1+exp(x);diff(f)ans=exp
5、(x)/(2*(exp(x)+1)(1/2)zy g=x*exp(y)/y2;diff(g,x)ans=exp(y)/y2 diff(g,y)ans=(x*exp(y)/y2-(2*x*exp(y)/y3(1),evaluate y.1=+yex=yzxey2zx3.Integral of 3.Integral of s symbolic ymbolic functionsfunctions(1)Indefinite integralIn MATLAB,indefinite integral is evaluated by the int function.Its syntax is asfo
6、llows:int(f,x)That is to find the indefinite integral of function f with respect to variable x.Example 3:Evaluate indefinite integrals.(1)(2)(3)23xdx512xtxdt+syms x t f=(3-x2)3;int(f)ans=-x7/7+(9*x5)/5-9*x3+27*x g=5*x*t/(1+x2);int(g,t)ans=(5*t2*x)/(2*(x2+1)(2)Definite integralThe function used to ev
7、aluate a definite integral is the same as that of an indefiniteintegral,but its syntax is different:int(f,x,a,b)a and b respectively represents the lower limit and upper limit of the definite integral.When the function f is integrable with respect to the variable x in the closed intervala,b,the func
8、tion returns a definite integral result.When one of a and b is inf,the function returns an generalized integral.When there is a symbolic expression in a and b,the function returns a symbolicfunction.Example 4:Evaluate the definite integrals.(1)(2)(3)42sinxxtdt112xdx112+xdx syms x t int(abs(1-x),1,2)
9、ans=1/2 int(1/(1+x2),-inf,inf)ans=pi int(4*x/t,t,2,sin(x)ans=4*x*(log(sin(x)-log(2)x050100150200250300350400450500550600h(x)4.44.54.64.84.95.15.45.25.55.24.94.84.7Estimation of water flowNow according to the actual measurement,we get the width of the river somewhere is 600m,and the water depths at a
10、 certain moment in different positions of its cross-section are asshown in following table.If the current velocity of the water flow is 0.6 meters per second,try to estimate thecurrent flow of the river.It is known that the interval between 50 and 60 in the x-direction is the lower footprotection pa
11、rt of the slope revetment.According to the relevant embankment designspecifications,the slope of a riprap revetment should be less than 1:1.5.Please estimatewhether the erosion of the water has damaged the riprap revetment in this area.Analysis:We can use the data in the table to fit the curve of th
12、e riverbed first,then find the definiteintegral.By doing so,we can calculate the cross-sectional area of the river,then estimate thecurrent flow of the river.We can calculate the derivative function of the riverbed curve and determine whether thevalue of the derivative function in the corresponding
13、range less than 1:1.5.xi=0:50:600;yi=4.4,4.5,4.6,4.8,4.9,5.1,5.4,5.2,5.5,5.2,4.9,4.8,4.7;p=polyfit(xi,yi,3);plot(xi,yi,o,xi,polyval(p,xi);syms y xy=poly2sym(p,x);s=int(y,x,0,600);v=s*0.6;eval(v)The value of V is 1787.4(m3/s).xi=0:50:600;yi=4.4,4.5,4.6,4.8,4.9,5.1,5.4,5.2,5.5,5.2,4.9,4.8,4.7;yn=-yi;p=polyfit(xi,yn,3);plot(xi,yn,o,xi,polyval(p,xi);syms y x yiiy=poly2sym(p,x);yii=diff(y,x);x=50:60;k=eval(yii);all(abs(k)1/1.5)The result is 1.x=50:60;y=polyval(p,x);k=diff(y)/1;all(abs(k)1/1.5)The result is also 1.
限制150内