欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    科学计算科学计算 (38).pdf

    • 资源ID:67732151       资源大小:787.82KB        全文页数:18页
    • 资源格式: PDF        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    科学计算科学计算 (38).pdf

    6.46.4 Solve Nonlinear Equation and Find Solve Nonlinear Equation and Find Extreme Value of FunctionExtreme Value of FunctionThe solution of nonlinear equationsThe calculation of function extreme values1 1 The The S Solution of olution of NNonlinear onlinear E Equationsquations(1)Solving univariate nonlinear equationsThe syntax of the function is:x=fzero(filename,x0)Where filename is the function expression at the left of the quation,and x0 is the initial value.Example 1:Find the root of at x0=-5 and x0=1 as the initial value of iteration.f(x)=x-x+15 f=(x)x-1./x+5;x1=fzero(f,-5)x1=-5.1926 x2=fzero(f,1)x2=0.1926 x3=fzero(f,0.1)x3=3.7372e-16Lets take the initial value around x=0 and see what the result is.Obviously,x3 is not the solution of the equation.So it is very important to choose the initial value when solving the equation by using the fzero function,which involves the method of its internal implementation.Therefore,when usingMATLAB to solve a problem,we need to analyze the problem from different aspects instead of mechanically applying commands or programs.f=(x)x.2-1;x=;x0=-0.25:0.001:0.25;for x00=x0 x=x,fzero(f,x00);endplot(x0,x,-o)xlabel(Initial value);ylabel(The root of the equation);axis(-0.25,0.25,-1,1)As the result shows,around the zero point,the range of initial values corresponding to the same root is not continuous,and the root obtained is not the root closer to the initial value.So,the fzero function performs a numerical search process,and the result depends on the function properties and the specified initial values.The root of f(x)=x2-1=0.(2)Solution of nonlinear equationsThe optimization toolbox of MATLAB provides the solution function fsolve of systems of nonlinear equations.Its syntax is as follows:x=fsolve(filename,x0,option)x is the approximate value returned.Filename is the function expression at the left of the equation whose root is to be found.x0 is the initial value.Option is used to set the optimum parameters of the optimization toolbox and can be performed by calling the optimset function.For example,when the Display parameter is set to“off”,no intermediate results are displayed.f=(x)x-1./x+5;x1=fsolve(f,-5,optimset(Display,off)x1=-5.1926 x2=fsolve(f,1,optimset(Display,off)x2=0.1926 x3=fsolve(f,0.1,optimset(Display,off)x3=0.1926when the initial value is 0.1,t he correct result cannot be obtained by using the fzero function.But we can obtain the correct result by using the fsolve function here,because of different implementation methods and applications of different functions.In short,I t is necessary to choose and analyze from various aspects.Use the fsolve function to solve the equation of example 1.Example 2:Find the solutions of the following equations around(1,1,1)and verify the results.xxyz exyzxyz2sin000+=+=f=(x)sin(x(1)+x(2)+x(3)2*exp(x(1),x(1)+x(2)+x(3),x(1)*x(2)*x(3);f(1,1,1)ans=4.5598 3.0000 1.0000 x=fsolve(f,1,1,1,optimset(Display,off)x=0.0224 -0.0224 -0.0000 f(x)ans=1.0e-06*-0.5931 -0.0000 0.00062 2The The C Calculation of alculation of F Function unction E Extreme xtreme V ValuesaluesExtreme values of functions include maximums and minimums which are also called maximum and minimum values.MATLAB only calculates the minimum value.The maximum value of f(x)can be obtained by finding the minimum value of-f(x).(1)The unconstrained optimization problemsThe unconstrained optimization problem is described as follows:min()among them,x=x1,x2,xnT.The functions to find the minimum value are:xmin,fmin=fminbnd(filename,x1,x2,option)xmin,fmin=fminsearch(filename,x0,option)xmin,fmin=fminunc(filename,x0,option)Among them,xmin represents the minimum point.fmin represents the minimum value.filename isthe defined objective function.The input arguments xl and x2 of the first function respectivelyrepresent the left and right bounds of the interval studied.The input argumrent x0 of the latter twofunctions is a vector,representing the initial value of the extreme point.Option is an optimizationparameter that can be set by the optimset function.Example 3:Find the function of ,the minimum point on the interval(-10,-1)and(1,10).f xxx=+()15 f=(x)x-1./x+5;xmin,fmin=fminbnd(f,-10,-1)xmin=-9.9999fmin=-4.8999 xmin,fmin=fminbnd(f,1,10)xmin=1.0001fmin=5.0001(2)The constrained optimization problemThe constrained optimization problem is generally described as follows:min.()0()among them,x=x1,x2,xnT.Finding a set of x to minimize the objective function f(x)and also meeting the constraint:G(x)0.S.t.is the abbreviation of ”subject to”,meaning that x should meet the following constraints.Constraints can be subdivided into linear inequality constraints,linear equality constraints,nonlinear inequality constraints,nonlinear equality constraints,and lower and upper bounds of x.The function to find the minimum value under constraints is:xmin,fmin=fmincon(filename,x0,A,b,Aeq,beq,Lbnd,Ubnd,NonF,option)xmin,fmin,filename,x0 and option have the same meanings as those of the previous function for finding the minimum value.The remaining arguments are constraints including linear inequality constraints,linear equality constraints,lower and upper bounds of x,and functions defining nonlinear constraints.If a constraint does not exist,I t can be represented by an empty matrix.Example 4:Solve a constrained optimization problem.f=(x)0.4*x(2)+x(1)2+x(2)2-x(1)*x(2)+1/30*x(1)3;x0=0.5;0.5;A=-1,-0.5;-0.5,-1;b=-0.4;-0.5;lb=0;0;option=optimset(Display,off);xmin,fmin=fmincon(f,x0,A,b,lb,option)xmin=0.33960.3302fmin=0.2456f xxxxx xxxs txxxxxx212221213121212min()0.4130.0.50.40.50.50,0=+(3)Application of the minimum value problem.Example 5:A company has 5 factoriesA,B,C,D and E,which are located at 5 coordinate points on the x-y plane.(10,10),(30,50),(16.667,29),(0.555,29.888)and(22.2221,49.988).Suppose that the distance between two points represents the driving distance between factories in kilometers.The company plans to build a warehouse at a coordinate point on the plane and expects to make 10,18,20,14 and 25 deliveries to factories A,B,C,D and E each week on average.Ideally,to minimize the mileage of weekly delivery,where should the warehouse be located on the x-y plane?d(,)=10 102+102+18 302+502+20 16.6672+292+14 0.5552+29.8882+25 22.22212+49.9882If the coordinate point of the warehouse is(x y),the expression of the total mileage is as follows:Therefore,this problem is to find the minimum value of d(x,y)without constraints.a=10,30,16.667,0.555,22.2221;b=10,50,29,29.888,49.988;c=10,18,20,14,25;f=(x)sum(c.*sqrt(x(1)-a).2+(x(2)-b).2);xmin,fmin=fminsearch(f,15,30)xmin=19.8143 41.1247fmin=1.3618e+03Example 6:In Example 5,if the warehouse must be built on a curve y=x2 due to geographical restrictions,where should it be built?Nonlinear constrained function file funny.m:function c,h=funny(x)c=;h=x(2)-x(1)2;a=10,30,16.667,0.555,22.2221;b=10,50,29,29.888,49.988;c=10,18,20,14,25;f=(x)sum(c.*sqrt(x(1)-a).2+(x(2)-b).2);xmin,fmin=fmincon(f,15,30,funny)xmin=5.9363 35.2402fmin=1.6676e+03

    注意事项

    本文(科学计算科学计算 (38).pdf)为本站会员(奉***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开