TypeError: list indices must be integers or slices, not Symbol

Question:

from sympy import *

t6,a,b,c = symbols ('t6,a,b,c')
result=solve([(a*cos(t6))+(b*sin(t6))+c],[t6])
cs=[(a,-26.468147779101194),(b,4.395890741437306),(c,19.920476269921963)]

t6 = result[t6].subs(cs)

trying to solve an equation
i guess it is because it has two results
because it works fine on simplier equations

Asked By: james

||

Answers:

There is no need for list (i.e., []) inside solve()

t6,a,b,c = symbols('t6,a,b,c')
result=solve((a*cos(t6))+(b*sin(t6))+c, t6)
cs=[(a,-26.468147779101194),(b,4.395890741437306),(c,19.920476269921963)]

# solve for t6
for i in range(len(result)):
    t6 = result[i].subs(cs)
    print(t6)

output:

0.569494943945226
-0.898655036471938
Answered By: JayPeerachai
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.