早教吧 育儿知识 作业答案 考试题库 百科 知识分享

matlab问题,高分求matlab求三元方程的极值.形式如图片,这个式子应该有一个最大值,我就是想求得这个值是多少,是不是1,如果是如何得到的,最好能有一个程序求出.再写一下 如果用xz-x+1>0与xz-y

题目详情
matlab问题,高分求matlab求三元方程的极值.
形式如图片,这个式子应该有一个最大值,我就是想求得这个值是多少,是不是1,如果是如何得到的,最好能有一个程序求出.
再写一下 如果用xz-x+1>0与xz-y-1>0约束一下,看是否有最值,我的想法是如果约束后那么(x-1)(1+y-xz)-(1+y)(x-1)+(xz)^2=xz(xz-x+1)>0,说明整个值是小于1的.
▼优质解答
答案和解析
如果用xz-x+>0与xz-y-1>0约束一下,第一个约束不清晰
xz-x+>0====》xz-x+1>0
function aa
y=@(x)-(x(1)-1).*(1+x(2)-x(1).*x(3))./((1+x(2)).*(x(1)-1)-(x(1).*x(3)).^2);
[X,FVAL,EXITFLAG] =fmincon(y,[1.5 1 0.5],[],[],[],[],[1 0 0],[inf inf 1],@(x)con(x))


function [c,cq]=con(x)
c(1)=-x(1).*x(3)+x(1)-1;
c(2)=1+x(2)-x(1).*x(3);
cq=[];
Warning: Trust-region-reflective algorithm does not solve this type of problem, using
active-set algorithm. You could also try the interior-point or sqp algorithms: set the
Algorithm option to 'interior-point' or 'sqp' and rerun. For more help, see Choosing the
Algorithm in the documentation.
> In fmincon at 472
In AAAA at 3
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.

Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1 3 1
2 2
X =
1 0 1
FVAL =
0
EXITFLAG =
1
这个式子的最大值,估计是趋于0的
(x-1)(1+y-xz)-(1+y)(x-1)+(xz)^2化简后为
xz(xz-x+1)没错
可是x>1 01/x xz(xz-x+1)