On 10/29/07, Jason Grout <[EMAIL PROTECTED]> wrote: > William Stein wrote: > > 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. > > William is correct here. > > > > > 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] > > I saw this late Saturday night and tried to get it working, but haven't > been successful yet. I think it's a matter of figuring out what fsolve > is expecting to be passed and how to interpret the results (e.g., it > appears that fsolve expects the function to take a vector, or list of > parameters, and not just a bunch of parameters). >
I definitely make no claims that using scipy.optimize.fsolve is in any way easy! That said, I've seen Josh Kantor use exactly that function many times, so he knows how to use it. You might write to him: "Josh Kantor" <[EMAIL PROTECTED]>, - 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/ -~----------~----~----~----~------~----~------~--~---