On 10/28/07, David Joyner <[EMAIL PROTECTED]> wrote: > 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
Note that his systems are nonlinear, but your examples in the constructions book are linear. So it's sort of a different thing. Some options for solving systems of nonlinear equations *numerically* include: * [100% sage] Use scipy, which wraps minpack: Type sage: import scipy.optimize sage: scipy.optimize.fsolve ? to hopefully get going. Also just try scipy.optimize.[tab] * [Not sage] Use phcpack, which is open source (GPL'd) but not included in Sage. It is able to do amazing things with solving algebraic systems numerically, using a method called "Polynomial Homotopy Continuation". There is a Sage interface to phcpack, that Marshall Hampton worked on (he frequently posts on sage-devel). Please report back, since I haven't even tried to solve your system above using either of the above approaches. William --~--~---------~--~----~------------~-------~--~----~ 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/ -~----------~----~----~----~------~----~------~--~---