当前位置: > 数学题在线解4元一次方程...
题目
数学题在线解4元一次方程

提问时间:2020-12-03

答案
方程:
a1x1+b1x2+c1x3+d1x4=e1
a2x1+b2x2+c2x3+d2x4=e2
a3x1+b3x2+c3x3+d3x4=e3
x1、x2、x3、x4为未知数,取值为0-9000范围内整数,其他全部为常数
现在要求用vb进行求解,求出最优的x1、x2、x3、x4值,即假设:
a1x1+b1x2+c1x3+d1x4值为s1
a2x1+b2x2+c2x3+d2x4值为s2
a3x1+b3x2+c3x3+d3x4值为s3
(s1-e1)*(s1-e1)+(s2-e2)*(s2-e2)+(s3-e3)*(s3-e3)的值最小
VB最原始的方法代码为:
VB code
m1 = -1:m2 = -1:m3 = -1:m4 = -1
aaa = -1
For n1 = 0 To 9000
For n2 = 0 To 9000
For n3 = 0 To 9000
For n4 = 0 To 9000
s1 = a1 * n1 + b1 * n2 + c1 * n3 + d1 * n4
s2 = a2 * n1 + b2 * n2 + c2 * n3 + d2 * n4
s3 = a3 * n1 + b3 * n2 + c3 * n3 + d3 * n4
If aaa = -1 Then
m1 = n1:m2 = n2:m3 = n3:m4 = n4
aaa = (s1 - e1) * (s1 - e1) + (s2 - e2) * (s2 - e2) + (s3 - e3) * (s3 - e3)
Else
If aaa < (s1 - e1) * (s1 - e1) + (s2 - e2) * (s2 - e2) + (s3 - e3) * (s3 - e3) Then
m1 = n1:m2 = n2:m3 = n3:m4 = n4
aaa = (s1 - e1) * (s1 - e1) + (s2 - e2) * (s2 - e2) + (s3 - e3) * (s3 - e3)
End If
End If
Next
Next
Next
Next
MsgBox "最优解为:" + Trim(m1) + "," + Trim(m2) + "," + Trim(m3) + "," + Trim(m4)
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.