1 Star 1 Fork 2

saigon/AI_NueralNetwork

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
一元三次求解.py 4.99 KB
一键复制 编辑 原始数据 按行查看 历史
charlieshu 提交于 2024-01-08 23:41 . move to gitee from github
from math import *
TrainNum = [2.237838566303253,2.0589884892106056,2.0291480551240966,2.0173332036138163,-4.6693219426088035,0.9951609759652751,2.5188384207786854,1.9918806571513414,1.2266739466576837,4.0022643139514,-1.0010330733366235,2.0005708390328554,-2.6126557524682523,0.9971167184675096,0.999596847578605,2.0001188240413494,2.459544412791729,2.502353632822633,2.133832333725877,2.12293026142288,-1.0783587351907045,1.00123244064561,1.1390434676440009,1.998271127257567,-4.613390479236841,1.9913059524003067,2.7425373920139267,1.9359973173159242,-2.186578344553709,1.0005082918180381,0.9994182256058091,0.5002004284619703,3.163702664314769,-2.1303997832656023,5.4297556563906255,3.9481484631542116,-2.454366366902832,0.24962264689389846,1.1278953403234482,4.0120829548791335,2.0510402247309685,2.4982950310916383,1.3840658105938237,2.0027657159080263,0.5870967023074627,1.0002005429042855,1.9999192909570385,0.9998537501778216,7.729344367980957,5.679135587066412,4.090429887641221,3.6904566888697445,-0.943041370715946,0.46580153597154084,1.3483205414377153,0.889221110386913,-4.5143581269036055,1.9944555661413288,1.9974602075976131,1.7607660562097456,-2.5878079034924824,1.0019332527809754,1.984764130771897,1.000357205756307,0.6900017857551575,1.8843510823917313,1.755315596440596,2.3033821112944324,-0.9435284070204943,0.25095651139586295,0.2767442683689296,2.515015014095056,2.1817914828425273,1.985708946120412,1.2050312506147796,2.0002220785308413,0.5284361367814545,0.9998093951153177,1.0652806349338235,1.062526643347688,3.394296346232352,3.644700666307486,3.438168626162435,3.5398548308230033,-1.3573887578012496,0.629408877035678,2.0288648663788944,0.9705806642354373,-0.8675145805755218,1.9967174431924526,1.7708968219486283,0.6250667222036341,-2.5409151010123887,1.0010689791249667,1.99858782686252,0.874041168352786,27.923049926757812,9.496171951293945,5.757174909114838,2.4253592900931835,25.280396223068237,0.7417703509447264,16.646499633789062,0.21875762799673737,-37.37845969200134,2.5417690919712186,4.5088860869873315,0.3169019380584359,-0.2674522399902344,0.8827935036346919,0.6634073762397747,0.9458361552096903,3.9460220336914062,0.6236443612724543,2.740426198230125,2.6828564293682575,-7.534810699522495,0.8420521615478374,1.6458907946944237,2.599704989664591,-4.6575735956430435,1.9990127687460153,1.8222906977316597,0.49641483156705135,-0.39342358708381653,1.00125122020189,1.9923908765343339,1.0640910714905458,4.008785157029195,1.000194562477276,-0.4839686355075292,-0.509658086639212,-3.8847543746232986,-0.5069719905750389,0.4625461851246655,0.5032956620020741,-2.530828862742055,-0.5042393442444313,0.49734268726581554,0.499908473993842,-0.16331769201497082,-0.49931458317405486,1.203675407042577,0.4999942667855448,0.9891089109560198,0.5001829267657181,0.9286096733412705,-0.5048105679161381,-0.20639610290527344,-0.5661767586698261,1.2944531263274257,0.49929808754766425,0.3526794044300914,-0.5057390748947622,0.6484309320193362,0.49999617714429,-2.649555191397667,-0.5004388461820781,1.1177849769592285,0.999702498284868,-0.9149215888824394,0.5045894750317177,1.3098780938817072,0.5643837904826796,1.9535841094329953,-0.5099713299423456,1.953781197690946,0.42187777410442906,0.9084029644727707,-0.4289688299759291,0.5645971935954588,0.4958621280234946,1.060254541967879,-0.48219556007473185,1.2082600990324863,0.499301739735339,1.0081687895435607,0.49930092011647426,0.2738320976495743,0.49158790296814914,-3.7553960978984833,-0.48605330073633013,0.013934355505625717,0.5101967463520819,-0.6037345383374486,-0.5607740444091047,0.46969897615947076,0.4999123866228372,2.033873528242111,0.5005909728327036,1.2819759496624101,1.0000035122362192,0.5516797644086182,-0.5074775787070394,0.436665877699852,0.5850316135329194,0.46690234541893005,-0.48812504205852747,0.5287497788667679,0.47105033695697784,0.4488634690642357,-0.5016312898769684,0.5150761960539967,0.46668701618909836]
#开三次方根
def pow3(a):
d = a/abs(a)
res = pow(abs(a),1/3)
res *= d
return res
#开三次方根 end
#计算方程的解
def cac(a,b,c,d):
global TrainNum
sum = 0
Cac1 = [0,0,0,0,0,0,0,0]
for i in range(8):
for j in range(4):
Cac1[i] += TrainNum[sum]*(a**j)
sum += 1
Cac1[i] += TrainNum[sum]*(b**j)
sum += 1
Cac1[i] += TrainNum[sum]*(c**j)
sum += 1
Cac1[i] += TrainNum[sum]*(d**j)
sum += 1
Cac2 = [0,0,0,0]
for i in range(4):
for j in range(8):
Cac2[i] += TrainNum[sum]*pow3(Cac1[j])
sum += 1
Cac2[i] += TrainNum[sum]*Cac1[j]
sum += 1
Res = [0,0,0]
for i in range(3):
for j in range(4):
Res[i] += TrainNum[sum]*Cac2[j]
sum += 1
Res.sort()
return Res
#计算方程的解 end
def main():
a = float(input())
b = float(input())
c = float(input())
d = float(input())
res = cac(a,b,c,d)
print(res[0]," ",res[1]," ",res[2])
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/saigonshu/ai-nueral-network.git
git@gitee.com:saigonshu/ai-nueral-network.git
saigonshu
ai-nueral-network
AI_NueralNetwork
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385