MATLAB求解方程组x^2+y^2=1xy=2%ex_20.mfunction z=ex_20(p)z(1)=p(1)^2+p(2)^2;z(2)=p(1)*p(2);保存,然后输入fsolve x=('ex_20',[0 0])错了,保存后输入x=fsolve('ex_20',[0 0])
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 05:49:04
MATLAB求解方程组x^2+y^2=1xy=2%ex_20.mfunction z=ex_20(p)z(1)=p(1)^2+p(2)^2;z(2)=p(1)*p(2);保存,然后输入fsolve x=('ex_20',[0 0])错了,保存后输入x=fsolve('ex_20',[0 0])
MATLAB求解方程组
x^2+y^2=1
xy=2
%ex_20.m
function z=ex_20(p)
z(1)=p(1)^2+p(2)^2;
z(2)=p(1)*p(2);
保存,然后输入
fsolve x=('ex_20',[0 0])
错了,保存后输入
x=fsolve('ex_20',[0 0])
MATLAB求解方程组x^2+y^2=1xy=2%ex_20.mfunction z=ex_20(p)z(1)=p(1)^2+p(2)^2;z(2)=p(1)*p(2);保存,然后输入fsolve x=('ex_20',[0 0])错了,保存后输入x=fsolve('ex_20',[0 0])
>> [x,y]=solve('x^2+y^2=1','x*y=2','x','y')
x =
((15^(1/2)*i)/2 + 1/2)^(1/2)/2 - ((15^(1/2)*i)/2 + 1/2)^(3/2)/2
((15^(1/2)*i)/2 + 1/2)^(3/2)/2 - ((15^(1/2)*i)/2 + 1/2)^(1/2)/2
(1/2 - (15^(1/2)*i)/2)^(1/2)/2 - (1/2 - (15^(1/2)*i)/2)^(3/2)/2
(1/2 - (15^(1/2)*i)/2)^(3/2)/2 - (1/2 - (15^(1/2)*i)/2)^(1/2)/2
y =
((15^(1/2)*i)/2 + 1/2)^(1/2)
-(1/2*15^(1/2)*i + 1/2)^(1/2)
(1/2 - (15^(1/2)*i)/2)^(1/2)
-(1/2 - 1/2*15^(1/2)*i)^(1/2)
>> x=vpa(x)
x =
1.1180339887498948482045868343656 - 0.86602540378443864676372317075294*i
0.86602540378443864676372317075294*i - 1.1180339887498948482045868343656
0.86602540378443864676372317075294*i + 1.1180339887498948482045868343656
- 0.86602540378443864676372317075294*i - 1.1180339887498948482045868343656
>> y=vpa(y)
y =
0.86602540378443864676372317075294*i + 1.1180339887498948482045868343656
- 0.86602540378443864676372317075294*i - 1.1180339887498948482045868343656
1.1180339887498948482045868343656 - 0.86602540378443864676372317075294*i
0.86602540378443864676372317075294*i - 1.1180339887498948482045868343656
>> ex_20([1 1])
ans =
2 1