On 10/26/07, Jason Grout <[EMAIL PROTECTED]> wrote: > > I'm trying to numerically solve a system of equations. Currently I have: > > sage: var('x y p q') > sage: eq1 = p+q==9 > sage: eq2 = q*y+p*x==-6 > sage: eq3 = q*y^2+p*x^2==24 > sage: solve([eq1,eq2,eq3,p==1],p,q,x,y) > [[p == 3, q == 6, x == (-2*sqrt(10) - 2)/3, y == (sqrt(2)*sqrt(5) - > 2)/3], [p == 3, q == 6, x == (2*sqrt(10) - 2)/3, y == (-sqrt(2)*sqrt(5) > - 2)/3]] > > I'd like the answer to be a numeric approximation, though (i.e., > x==-2.77485177345). I can't find any other solving routines other than > the symbolic one, though. Is there a way to numerically approximate the > solution, other than going through each solution and calling n() on the > left side of each symbolic expression?
Examples using numpy and octave are give in the constructions cookbook: http://www.sagemath.org/doc/html/const/node35.html > > Thanks, > > Jason > > P.S. On a different note, my real code has something like: > > sage: [solve([eq1,eq2,eq3,p==i],p,q,x,y) for i in [1..4]] > > which produces a nested list. Is there a way to flatten the list by one > or two levels, but not flatten it all the way? Something like: > > sage: flatten([[[1,2],[3,4]],[[5,6],[7,8]]],1) > [[1,2],[3,4],[5,6],[7,8]] > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---