I'm making a fast and simple equation solver in python for a home assaignment where I need to calculate the value of sig_a which is between 0 and 700 for each eps_komp. I've done this with 2 for loops, the first to select the eps_komp value and the second to search for the closest value of sig_a between 0 and 700 in order for the equation to be as close to zero as possible. I defined the allowable error with "delta". It's similar logic like in bisection method. This is the code:
eps_komp = [0.00012893048999999997,
0.018839115269999998,
0.01230539995,
0.022996934109999999,
-0.0037319012899999999,
0.023293921169999999,
0.0036927752099999997,
0.020621037629999998,
0.0063656587500000002,
0.020324050569999998]
Rm=700
sigma = np.linspace(0, Rm-0.01, Rm/0.01)
delta = 0.001
sig_a = []
for j in range(len(eps_komp)):
eps_j = eps_komp[j]
for i in range(len(sig)):
eps_j - sigma[i]/Emod - (sigma[i]/RO_K)**(1/RO_n) = diff
if diff <= delta:
sig_a.append(sigma[i])
The values of eps_komp are just the first 10, there are more of them but I just gave the first 10 for an example.
Now I keep getting this error:
SyntaxError: can't assign to operator
I know it has something to do with an incorrect index but I just can't see the problem....
If anyone can help, it would mean a lot to me. Thanks.
Luka
要将diff分配给计算,它需要位于等号的左侧:
diff = eps_j - sigma[i]/Emod - (sigma[i]/RO_K)**(1/RO_n)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.