Drini wrote:
> 
> 
> On Mar 25, 9:22 am, kcrisman <[email protected]> wrote:
>> Is it possible that the cvxopt package could help out?  Your problem
>> is not convex optimization per se but maybe it would have something
>> useful?  This package uses LAPACK (also part of Sage), which "provides
>> routines for solving systems of simultaneous linear equations".
>>
>> Also, is it possible (someone else will have to answer this) that
>> using the Pynac symbolic variables could help out?  But Maxima is
>> called for solve, so perhaps that wouldn't really help...
>>
>> Or could you just use a big matrix and solve it that way?  Maybe I am
>> misinterpreting your question.
>>
>> I hope *one* of these ideas helps!
>>
>> - kcrisman
> 
> 
> 
> I'm going to check. Actually, what I'm trying to do is find the
> vertices of a polytope given by some hyperplanes (therefore the linear
> equations). I know about polymake, but it can't do symbolic
> 
> Like
> ax+by = 3
> bx+dy=5
> a,b,c,d constants
> 
> I know I could get a matrix and use linear algebra to get a fast
> solution without worrying about symbolics
> but when the systems are like
> ax+by=p
> cx+dy=q
> with a,b,c,d constants, the vector in Ax=b is not numeric, so I turn
> to symbolic solving
> (actually those are simplificatinos, I'm doing 9-variable systems)
> 
> Thatnks for the hints, I will check the options you meantioned


Here it is using linear algebra:

sage: var('a,b,c,d,x,y')
(a, b, c, d, x, y)
sage: A=matrix(2,[a,b,c,d]); A
[a b]
[c d]
sage: result=vector([3,5]); result
(3, 5)
sage: soln=A.solve_right(result) # you could also do soln=A\result
sage: soln
(3/a - b*(5 - 3*c/a)/(a*(d - b*c/a)), (5 - 3*c/a)/(d - b*c/a))


Now, checking our answers:


sage: (a*x+b*y).subs(x=soln[0],y=soln[1]).simplify_full()
3
sage: (c*x+d*y).subs(x=soln[0],y=soln[1]).simplify_full()
5


Or just checking it with matrix multiplication:

sage: A*soln
(a*(3/a - b*(5 - 3*c/a)/(a*(d - b*c/a))) + b*(5 - 3*c/a)/(d - b*c/a), 
c*(3/a - b*(5 - 3*c/a)/(a*(d - b*c/a))) + (5 - 3*c/a)*d/(d - b*c/a))

Let's simplify each entry by applying the "simplify_full" function to 
each entry:

sage: (A*soln).apply_map(lambda x: x.simplify_full())
(3, 5)


This example probably ought to go into some documentation somewhere...

Jason


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

Reply via email to