Hi,

    I have a set of variables which I defined in an array and I'm trying 
to use "solve" to solve for these variables, but I get the following error:

x = []
N = 3
for i in range(N):
    string = 'x' + str(i)
    temp_var = var(string)
    x.append(temp_var)
Eqn = []
Eqn.append(x[0] + x[1] + x[2])
Eqn.append(x[0] - x[1] + x[2])

solve([Eqn[1]==0], x[1], solution_dict=True)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mc/.sage/sage_notebook/worksheets/admin/7/code/47.py", line 17, 
in <module>
    solve([Eqn[_sage_const_1 ]==_sage_const_0 ], x[_sage_const_1 ], 
solution_dict=True)
  File "", line 1, in <module>
    
  File 
"/opt/sage/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.py", 
line 509, in solve
    sol_dict=[dict([[eq.left(),eq.right()] for eq in solution]) for solution in 
sol_list]


TypeError: 'sage.symbolic.expression.Expression' object is not iterable


However the following seems to work:

solve([Eqn[1]==0], x[1])
  

[x1 == x0 + x2]

The reason I need solution_dict=True is that I need to put the solution 
in x[1], which solve does not do. Could someone please help me out?

Thanking you,
Mani chandra



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to