Re: [討論] 三元二次(?)方程式求解

看板MATLAB作者 (外派越南工作者)時間12年前 (2013/11/04 22:54), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《ding94xu04 (錯誤示範)》之銘言: : 這是一個作業... : 不過我怎麼算都是發散的解 : x^2+y^2+z=5.2 : exp(x)+y+z^2=2.44 : x^2-y^3+2*z=8.5828136 : 題目如上 : 我是利用Newton-Raphson method : 其初始值為 x=1 y=1.7 z=1.189 : 問題是這樣的 : 在第一步選擇 f1 f2 f3時不知道要怎麼取 : 有算到一組解出來,然後自己按計算機代回會發現方程式不合 : 請問要怎麼選f1 f2 f3?? : 謝謝各位解答了!! 題目其實是很複雜的,又有加上指數隱含數 用牛頓法有點困難 ------------------------------------------- function pttex135 % x(1) = x; x(2) = y;x(3) = z; f = fsolve(@pttex123,[1 1.7 1.189]) % figure(1) ezsurfc(@(x,y)myfun1(x,y)) hold on ezsurfc(@(x,y)myfun2(x,y)) hold on ezsurfc(@(x,y)myfun3(x,y)) hold on function f = pttex123(x) f(1) = x(1).^2 + x(2).^2 + x(3) - 5.2; f(2) = exp(x(1)) + x(2) + x(3).^2 - 2.44; f(3) = x(1).^2 - x(2).^3 + 2.*x(3) - 8.5828136; function z1 = myfun1(x,y) z1 = 5.2 -x^2-y^2; function z2 = myfun2(x,y) z2 = (2.44-exp(x)-y)^(1/2); function z3 = myfun3(x,y) z3 = (y^3-x^2+8.5828136)/2; -------------------------------------------------- 初始值條件 x = 0 y = 0 z = 0 x = 1 y = 3 z = 5 x = 1 y = 1.7 z =1.189 >> pttex135 Equation solved. fsolve completed because the vector of function values is near zero as measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient. <stopping criteria details> f = -0.88202 -1.5878 1.901 >> pttex135 Equation solved. fsolve completed because the vector of function values is near zero as measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient. <stopping criteria details> f = 1.0042 -1.7296 1.2 先看一下有問題再討論 -- 1.MATLAB programming 2.ASPEN process simulation package 3.FORTRN programming 4.Advance Engineering Mathematics 5.Process Control Theory 6.Chemical Engineering Basic Theory(Kinetic.thermodynamics.transport) 7.Numerical Method and Analysis 8.MATLAB Toolbox.Simulink system basic design -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 113.186.203.69
文章代碼(AID): #1ITxL2yT (MATLAB)
文章代碼(AID): #1ITxL2yT (MATLAB)