0

I can't get the results o the next equation using Sympy, maybe I'm using the wrong tool for solve this kind of problems, this is the code i'm using:

import sympy as sym

ss1=4.16
as1=0.97    
fs1=0.38    
cs1=51.29
ss2=4.16    
as2=0.95    
fs2=0.37    
cs2=51.42
ss3=63.36
as3=13.58
fs3=3.06
cs3=6.88
ss5=1.94
as5=0.00
fs5=0.00
cs5=32.05
ss6=21.43   
as6=3.82    
fs6=52.28   
cs6=4.56
ss7=7.45    
as7=4.58    
fs7=0.42    
cs7=0.19

c,a,f,s,r1,r2,r3,r5,r6,r7 = sym.symbols('c,a,f,s,r1,r2,r3,r5,r6,r7')
eq1 = sym.Eq(cs1*r1+cs2*r2+cs3*r3+cs5*r5+cs6*r6+cs7*r7,c)
eq2 = sym.Eq(ss1*r1+ss2*r2+ss3*r3+ss5*r5+ss6*r6+ss7*r7,s)
eq3 = sym.Eq(as1*r1+as2*r2+as3*r3+as5*r5+as6*r6+as7*r7,a)
eq4 = sym.Eq(fs1*r1+fs2*r2+fs3*r3+fs5*r5+fs6*r6+fs7*r7,f)
eq5 = sym.Eq(r1+r2+r3+r5+r6+r7,1)
eq6 = sym.Eq(((100*c)/(2.8*s+1.18*a+0.65*f)), 98.5)

result = sym.solve([eq1,eq2,eq3,eq4,eq5,eq6],(c,a,f,s,r1,r2,r3,r5,r6,r7))
print(result)

The result I get is this:

{c: 138.036371184195*r3 - 9.67494414291396*r5 + 59.8621991124251*r6 + 1.33640428817057*r7 + 19.9838541859147, a: -15.4586724898762*r3 - 2.44154705493631*r5 - 13.54879986345*r6 - 4.45713912125701*r7 + 5.78633012524389, f: -11.3543362449381*r3 - 1.11577352746816*r5 + 43.700600068275*r6 - 3.99356956062851*r7 + 2.78816506262195, s: 59.2*r3 - 2.22*r5 + 17.27*r6 + 3.29*r7 + 4.16, r1: -1404.43362449381*r3 - 74.5773527468157*r5 - 820.939993172501*r6 - 404.356956062851*r7 + 241.816506262195, r2: 1403.43362449381*r3 + 73.5773527468157*r5 + 819.939993172501*r6 + 403.356956062851*r7 - 240.816506262195}


Maybe I'm using the wrong tool, as you can see the goal is to find the right values for r1, r2, r3, r4, r6, r7 (the sum of all r's = 1) which satisfies the eq6 to be = 98.5

1 Answers1

0

You have 1 equation and 4 variables (a, c, f, s): you need other 3 equations to find the values of all variables. Then you can do:

solve((eq1, eq2, eq3, eq4), (c, s, a, f))
Davide_sd
  • 10,578
  • 3
  • 18
  • 30