[sage-support] Re: numerically solving a polynomial system of equations

2008-08-25 Thread iSAGE

There is a matlab/octave interface to it. Look at the following
reference on http://www.math.uic.edu/~jan/
I don't know more about this since I am also at the moment collecting
information on how to solve a large system of polynomial equations.

Yun Guan and Jan Verschelde: PHClab: A MATLAB/Octave interface to
PHCpack. The abstract and  paper . Take a look at the  Poster. In IMA
Volume 148: Software for Algebraic Geometry, edited by Michael E.
Stillman, Nobuki Takayama, and Jan Verschelde. Pages 15-32, Springer-
Verlag, 2008.


Bhalchandra Thatte




On Aug 24, 10:29 pm, mabshoff [EMAIL PROTECTED]
dortmund.de wrote:
 On Aug 24, 2:22 pm, William Stein [EMAIL PROTECTED] wrote:

  On Sun, Aug 24, 2008 at 2:03 PM, Joshua Kantor [EMAIL PROTECTED] wrote:

   1. I would recommend looking at phcpack, it is designed to exploit the
   special nature of large polynomial systems, however, supposedly I
   believe it is sometimes difficult to compile, I've never used it but

            ^

  It is written in ADA.

 And building the GNU Ada compiler from sources is a giant pain unless
 you have the GNU Ada compiler to bootstrap. I did build some phcpack
 binaries for x86-64 Linux and it has a tendency to segfault when run
 on say Debian if the binary was build on a FC8 box and vice versa. I
 mainly wanted an Itanium binary, but cross compiling the ada toolchain
 was just plainly not worth it for it.

 So in conclusion: great code if you can use a binary that works, if
 you need to build from sources it plainly sucks. The lesson learned
 here is not to use exotic languages since the (alleged) benefit from
 using Ada is far outweight by the fact that the practicality of
 building the code :)

 SNIP

  William Stein

 Cheers,

 Michael

  Associate Professor of Mathematics
  University of Washingtonhttp://wstein.org
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-25 Thread mabshoff

On Aug 25, 1:21 am, iSAGE [EMAIL PROTECTED] wrote:
 There is a matlab/octave interface to it. Look at the following
 reference onhttp://www.math.uic.edu/~jan/
 I don't know more about this since I am also at the moment collecting
 information on how to solve a large system of polynomial equations.

 Yun Guan and Jan Verschelde: PHClab: A MATLAB/Octave interface to
 PHCpack. The abstract and  paper . Take a look at the  Poster. In IMA
 Volume 148: Software for Algebraic Geometry, edited by Michael E.
 Stillman, Nobuki Takayama, and Jan Verschelde. Pages 15-32, Springer-
 Verlag, 2008.

 Bhalchandra Thatte

There is also a quite sophisticated interface in Sage, but as long as
the code is written in Ada there is a zero percent chance that that
code will become standard in Sage. The optional package we have is a
bunch of binaries since Ada support is usually not available. Note
that at least until recently there was not even a 64 bit x86-64 ot
Itanium binary on Verschelde's website.

Cheers,

Michael
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-25 Thread Carl Witty

On Aug 24, 12:16 pm, Michael [EMAIL PROTECTED] wrote:
 I have a polynomial system of 50 equations in 50 unknowns. I would
 like
 to numerically solve this system (I'm interested in complex zeros).
 Seems to me that if I use sage's solve, it will sttempt to solve these
 algebraically.

 Are there any funcitons in sage for solving a polynomial or non-linear
 system
 numerically.

Other people have suggested phcpack, but not explained how to use it.

The following may or may not work for you (it depends on your
processor architecture and operating system); but if it does work,
it's actually quite easy.

First, install phc, by typing at the command line:

sage -i phc-2.3.39.p0

Then, from within Sage, you can do things like this:

sage: from sage.interfaces.phc import phc
sage: R2.x,y = PolynomialRing(QQ,2)
sage: start_sys = [x^6-y^2,y^5-1]
sage: sol = phc.blackbox(start_sys, R2)
sage: len(sol.solutions())
30
sage: sol.solutions()[0] # display the first solution
[0.309016994374947 + 0.951056516295154*I,
 0.104528463267653 + 0.994521895368273*I]

Carl

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-25 Thread William Stein

On Mon, Aug 25, 2008 at 5:32 PM, Carl Witty [EMAIL PROTECTED] wrote:

 On Aug 24, 12:16 pm, Michael [EMAIL PROTECTED] wrote:
 I have a polynomial system of 50 equations in 50 unknowns. I would
 like
 to numerically solve this system (I'm interested in complex zeros).
 Seems to me that if I use sage's solve, it will sttempt to solve these
 algebraically.

 Are there any funcitons in sage for solving a polynomial or non-linear
 system
 numerically.

 Other people have suggested phcpack, but not explained how to use it.

 The following may or may not work for you (it depends on your
 processor architecture and operating system); but if it does work,
 it's actually quite easy.

 First, install phc, by typing at the command line:

 sage -i phc-2.3.39.p0

 Then, from within Sage, you can do things like this:

sage: from sage.interfaces.phc import phc
sage: R2.x,y = PolynomialRing(QQ,2)
sage: start_sys = [x^6-y^2,y^5-1]
sage: sol = phc.blackbox(start_sys, R2)
sage: len(sol.solutions())
30
sage: sol.solutions()[0] # display the first solution
[0.309016994374947 + 0.951056516295154*I,
 0.104528463267653 + 0.994521895368273*I]


I installed phc into the public sage notebook servers, so you can try the
above at

  https://sage.math.washington.edu:8102

 -- William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-24 Thread William Stein

On Sun, Aug 24, 2008 at 12:16 PM, Michael [EMAIL PROTECTED] wrote:

 I have a polynomial system of 50 equations in 50 unknowns. I would
 like
 to numerically solve this system (I'm interested in complex zeros).
 Seems to me that if I use sage's solve, it will sttempt to solve these
 algebraically.

 Are there any funcitons in sage for solving a polynomial or non-linear
 system
 numerically.

You're probably going to want to use scipy.optimize.  It has a large
range of sophisticated numerical optimization routines.  Maybe
they can be used for what you want.  I've hardly used them, so I
can't easily say more -- hopefully somebody who has can.

sage: import scipy
scisagimport scipy.optimize
sage: scipy.optimize.
scipy.optimize.NumpyTestscipy.optimize.broyden2
 scipy.optimize.fmin_ncg scipy.optimize.moduleTNC
scipy.optimize.anderson scipy.optimize.broyden3
 scipy.optimize.fmin_powell  scipy.optimize.newton
scipy.optimize.anderson2scipy.optimize.broyden_generalized
 scipy.optimize.fmin_tnc scipy.optimize.nonlin
scipy.optimize.anneal   scipy.optimize.brute
 scipy.optimize.fminboundscipy.optimize.optimize
scipy.optimize.approx_fprimescipy.optimize.check_grad
 scipy.optimize.fsolve   scipy.optimize.ridder
scipy.optimize.bisect   scipy.optimize.cobyla
 scipy.optimize.golden   scipy.optimize.rosen
scipy.optimize.bisectionscipy.optimize.fixed_point
 scipy.optimize.lbfgsb   scipy.optimize.rosen_der
scipy.optimize.bracket  scipy.optimize.fmin
 scipy.optimize.leastsq  scipy.optimize.rosen_hess
scipy.optimize.brentscipy.optimize.fmin_bfgs
 scipy.optimize.line_search  scipy.optimize.rosen_hess_prod
scipy.optimize.brenth   scipy.optimize.fmin_cg
 scipy.optimize.linesearch   scipy.optimize.test
scipy.optimize.brentq   scipy.optimize.fmin_cobyla
 scipy.optimize.minpack  scipy.optimize.tnc
scipy.optimize.broyden1 scipy.optimize.fmin_l_bfgs_b
 scipy.optimize.minpack2 scipy.optimize.zeros

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-24 Thread Joshua Kantor

1. I would recommend looking at phcpack, it is designed to exploit the
special nature of large polynomial systems, however, supposedly I
believe it is sometimes difficult to compile, I've never used it but
it might be better suited to your problem.

http://www.math.uic.edu/~jan/download.html

2. The optimize.fsolve routine may be able to do what you want, though
I'm not sure how it will deal with that large a system

sage: import scipy
sage: from scipy import optimize
sage: def f(x):
return [float(x[0]**2-x[0]*x[1]-1),float(x[1]**2+x[0]*x[1]-2)]
:
sage: optimize.fsolve(f,[0.1r,0.1r])
array([-0.46821319,  1.66756601])

Note the float and 0.1r. scipy is not happy with sage floats or ints,
so you need to make sure everything is really python types and not
sage types.


The initial guess is very important if you give it a starting point of
[0,0] it won't converge.
Also, you can give it a jacobian which for that large a system is
probably a good idea.
do

sage: optimize.fsolve? for the arguments.


On Aug 24, 12:24 pm, William Stein [EMAIL PROTECTED] wrote:
 On Sun, Aug 24, 2008 at 12:16 PM, Michael [EMAIL PROTECTED] wrote:

  I have a polynomial system of 50 equations in 50 unknowns. I would
  like
  to numerically solve this system (I'm interested in complex zeros).
  Seems to me that if I use sage's solve, it will sttempt to solve these
  algebraically.

  Are there any funcitons in sage for solving a polynomial or non-linear
  system
  numerically.

 You're probably going to want to use scipy.optimize.  It has a large
 range of sophisticated numerical optimization routines.  Maybe
 they can be used for what you want.  I've hardly used them, so I
 can't easily say more -- hopefully somebody who has can.

 sage: import scipy
 scisagimport scipy.optimize
 sage: scipy.optimize.
 scipy.optimize.NumpyTestscipy.optimize.broyden2
  scipy.optimize.fmin_ncg scipy.optimize.moduleTNC
 scipy.optimize.anderson scipy.optimize.broyden3
  scipy.optimize.fmin_powell  scipy.optimize.newton
 scipy.optimize.anderson2scipy.optimize.broyden_generalized
  scipy.optimize.fmin_tnc scipy.optimize.nonlin
 scipy.optimize.anneal   scipy.optimize.brute
  scipy.optimize.fminboundscipy.optimize.optimize
 scipy.optimize.approx_fprimescipy.optimize.check_grad
  scipy.optimize.fsolve   scipy.optimize.ridder
 scipy.optimize.bisect   scipy.optimize.cobyla
  scipy.optimize.golden   scipy.optimize.rosen
 scipy.optimize.bisectionscipy.optimize.fixed_point
  scipy.optimize.lbfgsb   scipy.optimize.rosen_der
 scipy.optimize.bracket  scipy.optimize.fmin
  scipy.optimize.leastsq  scipy.optimize.rosen_hess
 scipy.optimize.brentscipy.optimize.fmin_bfgs
  scipy.optimize.line_search  scipy.optimize.rosen_hess_prod
 scipy.optimize.brenth   scipy.optimize.fmin_cg
  scipy.optimize.linesearch   scipy.optimize.test
 scipy.optimize.brentq   scipy.optimize.fmin_cobyla
  scipy.optimize.minpack  scipy.optimize.tnc
 scipy.optimize.broyden1 scipy.optimize.fmin_l_bfgs_b
  scipy.optimize.minpack2 scipy.optimize.zeros
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-24 Thread William Stein

On Sun, Aug 24, 2008 at 2:03 PM, Joshua Kantor [EMAIL PROTECTED] wrote:

 1. I would recommend looking at phcpack, it is designed to exploit the
 special nature of large polynomial systems, however, supposedly I
 believe it is sometimes difficult to compile, I've never used it but
  ^

It is written in ADA.

 it might be better suited to your problem.

 http://www.math.uic.edu/~jan/download.html

It is good when the zero locus is maybe not 0-dimensional,
i.e., when there are infinitely many solutions and you want
to understand them.


 2. The optimize.fsolve routine may be able to do what you want, though
 I'm not sure how it will deal with that large a system

 sage: import scipy
 sage: from scipy import optimize
 sage: def f(x):
return [float(x[0]**2-x[0]*x[1]-1),float(x[1]**2+x[0]*x[1]-2)]
 :
 sage: optimize.fsolve(f,[0.1r,0.1r])
 array([-0.46821319,  1.66756601])

 Note the float and 0.1r. scipy is not happy with sage floats or ints,
 so you need to make sure everything is really python types and not
 sage types.

It's best to just do

  RealNumber = float; Integer = int

first.

Thanks Josh!



 The initial guess is very important if you give it a starting point of
 [0,0] it won't converge.
 Also, you can give it a jacobian which for that large a system is
 probably a good idea.
 do

 sage: optimize.fsolve? for the arguments.


 On Aug 24, 12:24 pm, William Stein [EMAIL PROTECTED] wrote:
 On Sun, Aug 24, 2008 at 12:16 PM, Michael [EMAIL PROTECTED] wrote:

  I have a polynomial system of 50 equations in 50 unknowns. I would
  like
  to numerically solve this system (I'm interested in complex zeros).
  Seems to me that if I use sage's solve, it will sttempt to solve these
  algebraically.

  Are there any funcitons in sage for solving a polynomial or non-linear
  system
  numerically.

 You're probably going to want to use scipy.optimize.  It has a large
 range of sophisticated numerical optimization routines.  Maybe
 they can be used for what you want.  I've hardly used them, so I
 can't easily say more -- hopefully somebody who has can.

 sage: import scipy
 scisagimport scipy.optimize
 sage: scipy.optimize.
 scipy.optimize.NumpyTestscipy.optimize.broyden2
  scipy.optimize.fmin_ncg scipy.optimize.moduleTNC
 scipy.optimize.anderson scipy.optimize.broyden3
  scipy.optimize.fmin_powell  scipy.optimize.newton
 scipy.optimize.anderson2scipy.optimize.broyden_generalized
  scipy.optimize.fmin_tnc scipy.optimize.nonlin
 scipy.optimize.anneal   scipy.optimize.brute
  scipy.optimize.fminboundscipy.optimize.optimize
 scipy.optimize.approx_fprimescipy.optimize.check_grad
  scipy.optimize.fsolve   scipy.optimize.ridder
 scipy.optimize.bisect   scipy.optimize.cobyla
  scipy.optimize.golden   scipy.optimize.rosen
 scipy.optimize.bisectionscipy.optimize.fixed_point
  scipy.optimize.lbfgsb   scipy.optimize.rosen_der
 scipy.optimize.bracket  scipy.optimize.fmin
  scipy.optimize.leastsq  scipy.optimize.rosen_hess
 scipy.optimize.brentscipy.optimize.fmin_bfgs
  scipy.optimize.line_search  scipy.optimize.rosen_hess_prod
 scipy.optimize.brenth   scipy.optimize.fmin_cg
  scipy.optimize.linesearch   scipy.optimize.test
 scipy.optimize.brentq   scipy.optimize.fmin_cobyla
  scipy.optimize.minpack  scipy.optimize.tnc
 scipy.optimize.broyden1 scipy.optimize.fmin_l_bfgs_b
  scipy.optimize.minpack2 scipy.optimize.zeros
 




-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: numerically solving a polynomial system of equations

2008-08-24 Thread mabshoff



On Aug 24, 2:22 pm, William Stein [EMAIL PROTECTED] wrote:
 On Sun, Aug 24, 2008 at 2:03 PM, Joshua Kantor [EMAIL PROTECTED] wrote:

  1. I would recommend looking at phcpack, it is designed to exploit the
  special nature of large polynomial systems, however, supposedly I
  believe it is sometimes difficult to compile, I've never used it but

           ^

 It is written in ADA.

And building the GNU Ada compiler from sources is a giant pain unless
you have the GNU Ada compiler to bootstrap. I did build some phcpack
binaries for x86-64 Linux and it has a tendency to segfault when run
on say Debian if the binary was build on a FC8 box and vice versa. I
mainly wanted an Itanium binary, but cross compiling the ada toolchain
was just plainly not worth it for it.

So in conclusion: great code if you can use a binary that works, if
you need to build from sources it plainly sucks. The lesson learned
here is not to use exotic languages since the (alleged) benefit from
using Ada is far outweight by the fact that the practicality of
building the code :)

SNIP

 William Stein

Cheers,

Michael

 Associate Professor of Mathematics
 University of Washingtonhttp://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---