matlab 解2元方程
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 13:55:14
matlab 解2元方程
1/6+(5/6)/(1+exp(1.702*x*y))=1/2
1/6+(5/6)/(1+exp(-1.702*x*(1-y)))=1
写出 matlab 的计算代码
1/6+(5/6)/(1+exp(1.702*x*y))=1/2
1/6+(5/6)/(1+exp(-1.702*x*(1-y)))=1
写出 matlab 的计算代码
直接用solve解不行,先进行整合.
f1='1/6+(5/6)/(1+exp(1.702*xy))-1/2'%把x*y当成一个变量
xy=solve(f1)%求解xy的值
f2='1/6+(5/6)/(1+exp(-1.702*x+1.702*xy))-1'%展开
f3=subs(f2,'xy',xy)%把xy的值代f2
x=solve(f3)%求解x
f4='1/6+(5/6)/(1+exp(1.702*x*y))-1/2'%再拆开xy
f5=subs(f4,'x',x)%代入x
y=solve(f5)%求解y
运行结果:
f1 =1/6+(5/6)/(1+exp(1.702*xy))-1/2
xy =.23822861815990856755464930403311
f2 =1/6+(5/6)/(1+exp(-1.702*x+1.702*xy))-1
f3 =-5/6+5/6/(1+exp(-1.702*x+.40546510810816438197801311546435))
x =185.69932338571710748362082828445
f4 =1/6+(5/6)/(1+exp(1.702*x*y))-1/2
f5 =-1/3+5/6/(1+exp(316.06024840249051693712264974013*y))
y =.12828728388260336678414831727309e-2
验证答案:
>> 1/6+(5/6)/(1+exp(1.702*x*y))
ans =
.50000000000000000000000000000000
>> 1/6+(5/6)/(1+exp(-1.702*x*(1-y)))
ans =
1.0000000000000000000000000000000
f1='1/6+(5/6)/(1+exp(1.702*xy))-1/2'%把x*y当成一个变量
xy=solve(f1)%求解xy的值
f2='1/6+(5/6)/(1+exp(-1.702*x+1.702*xy))-1'%展开
f3=subs(f2,'xy',xy)%把xy的值代f2
x=solve(f3)%求解x
f4='1/6+(5/6)/(1+exp(1.702*x*y))-1/2'%再拆开xy
f5=subs(f4,'x',x)%代入x
y=solve(f5)%求解y
运行结果:
f1 =1/6+(5/6)/(1+exp(1.702*xy))-1/2
xy =.23822861815990856755464930403311
f2 =1/6+(5/6)/(1+exp(-1.702*x+1.702*xy))-1
f3 =-5/6+5/6/(1+exp(-1.702*x+.40546510810816438197801311546435))
x =185.69932338571710748362082828445
f4 =1/6+(5/6)/(1+exp(1.702*x*y))-1/2
f5 =-1/3+5/6/(1+exp(316.06024840249051693712264974013*y))
y =.12828728388260336678414831727309e-2
验证答案:
>> 1/6+(5/6)/(1+exp(1.702*x*y))
ans =
.50000000000000000000000000000000
>> 1/6+(5/6)/(1+exp(-1.702*x*(1-y)))
ans =
1.0000000000000000000000000000000