Re: [sage-support] Re: Polynomial representation over GF(2^n)

2012-06-16 Thread Martin Albrecht


On Wednesday 13 Jun 2012, Oleksandr Kazymyrov wrote:
> And one more.
> 
> The following is quite strange:
> sage: K=GF(2^8,'a',modulus=ZZ['x']("x^8 + x^7 + x^6 + x^4 + x^3 + x^2 +
> 1")) sage: b=K.multiplicative_generator()
> sage: c=K(0)
> sage: c.log(b)
> 0
> sage: c=K(1)
> sage: c.log(b)
> 0
> 
> How to determine when c is 0 and when 1? Perhaps log should return
> -1 for finite fields when c=0?

Yep, this looks like a bug. Can you open a ticket and perhaps provide a patch?
 
> Kind regards,
> Oleksandr
> 
> On Wednesday, June 13, 2012 3:02:46 PM UTC+2, Oleksandr Kazymyrov wrote:
> > Hi all,
> > 
> > Continuing the
> > question > /cvtz4Zh-WYQ> ...
> > 
> > Input data:
> > sage: K=GF(2^8,'a',modulus=ZZ['x']("x^8 + x^7 + x^6 + x^4 + x^3 + x^2 +
> > 1"))
> > sage: K.multiplicative_generator()
> > a^4 + a^3 + a
> > sage: P=PolynomialRing(K,'x')
> > sage: pol=P.random_element(5)
> > sage: pol
> > (a^7 + a^5 + a^3 + 1)*x^5 + (a^5 + a^4 + a^3 + a^2 + a + 1)*x^4 + (a^7 +
> > a^3 + a^2 + a)*x^3 + (a^5 + a^2)*x^2 + (a^6 + a^5 + a^4 + 1)*x + a^3
> > 
> > 1. How to represent *pol *using multiplicative generator? The output must
> > be b^(i1)*x^5 + b^(i2)*x^4 + b^(i3)*x^3 + b^(i4)*x^2 + b^(i5)*x + a^3,
> > where b = K.multiplicative_generator(), i1-i5 logarithmic representation
> > of (a^7 + a^5 + a^3 + 1), (a^5 + a^4 + a^3 + a^2 + a + 1)...
> > 
> > I have a correct function:
> > sage: b=K.multiplicative_generator()
> > sage: P(["({0})^{1}".format(b,i.log(b)) for i in pol.coeffs()]) == pol
> > True
> > sage: ["({0})^{1}".format(b,i.log(b)) for i in pol.coeffs()]
> > ['(a^4 + a^3 + a)^27', '(a^4 + a^3 + a)^234', '(a^4 + a^3 + a)^195',
> > '(a^4 + a^3 + a)^134', '(a^4 + a^3 + a)^79', '(a^4 + a^3 + a)^101']
> > 
> > If I have one program then the above method suits me. But if two, i.e.
> > one program represents polynomial in the form b^(i1)*x^5 ... and returns
> > b and another program tries to restore it, then I worry about the phrase
> > The docs for multiplicative_generator() say: "return a generator of the
> > multiplicative group", then add "Warning: This generator might change
> > from one version of Sage to another."
> > 
> > 2. So the question is how to uniquely reconstruct the original *pol*, if
> > I have *modulus*, *multiplicative generator *and* representation of pol
> > as *b^(i1)*x^5...?
> > 
> > Regards,
> > Oleksandr

Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://martinralbrecht.wordpress.com/
_jab: martinralbre...@jabber.ccc.de

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Numerically integrating over a region defined by linear inequalities

2012-06-16 Thread Alastair Irving

Hi

I want to numerically evaluate the integral of a function f(x,y) over a 
region defined by linear inequalities, for example

1/8<=y<=x<=1/3
x+y<=1/3.
I can do this with a repeated call to numerical_integral because I can 
re-write the constraints as y<=min(x,1/3-x).  However, this solution 
isn't very satisfying in general.  If I have more constraints and/or 
more variables then working out the limits on the repeated integrals by 
hand is going to be rather unpleasant.


Is there any way I can get sage to compute the integral directly from 
the inequalities.  For example, if I use a Polyhedron object to store 
the region of interest is there any way of getting functions from it 
which describe the limits of integration?  Ideally, if P is a Polyhedron 
it would be nice to have something like P.integral(f) which computes the 
integral of f over P.


Many thanks

Alastair Irving

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Numerically integrating over a region defined by linear inequalities

2012-06-16 Thread Dima Pasechnik
On 2012-06-16, Alastair Irving  wrote:
> Hi
>   
> I want to numerically evaluate the integral of a function f(x,y) over a 
> region defined by linear inequalities, for example
> 1/8<=y<=x<=1/3
> x+y<=1/3.
> I can do this with a repeated call to numerical_integral because I can 
> re-write the constraints as y<=min(x,1/3-x).  However, this solution 
> isn't very satisfying in general.  If I have more constraints and/or 
> more variables then working out the limits on the repeated integrals by 
> hand is going to be rather unpleasant.
>
> Is there any way I can get sage to compute the integral directly from 
> the inequalities.  For example, if I use a Polyhedron object to store 
> the region of interest is there any way of getting functions from it 
> which describe the limits of integration?  Ideally, if P is a Polyhedron 
> it would be nice to have something like P.integral(f) which computes the 
> integral of f over P.

there are plans to create a Sage interface to LattE Integrale, a package
that can in particular solve these kinds of tasks.
(see http://www.math.ucdavis.edu/~latte/)

For the time being you can roll your own, at least for compact P: 
compute a triangulation of P and for each simplex of triangulation use
an explicit formula.

HTH,
Dmitrii
>
> Many thanks
>
> Alastair Irving
>

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Error message when use vectors in Sage 5 with Ubuntu 12.04...

2012-06-16 Thread Chris Seberino
I installed Ubuntu 12.04 about 2 weeks ago along with Sage 5.
I just now tried using vectors for the first time and got this error...

sage: vector( [-1,2] ) 
---
AttributeErrorTraceback (most recent call last)

/home/cs/Ws/Lone_Star/1401/Exams/ in ()

/usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/sage/modules/free_module_element.so
 
in sage.modules.free_module_element.vector 
(sage/modules/free_module_element.c:3789)()

/usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/__init__.py
 
in ()
134 return loader(*packages, **options)
135 
--> 136 import add_newdocs
137 __all__ = ['add_newdocs']
138 

/usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/add_newdocs.py
 
in ()
  7 #   core/fromnumeric.py, core/defmatrix.py up-to-date.
  8 
> 9 from numpy.lib import add_newdoc
 10 
 11 
###

/usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/lib/__init__.py
 
in ()
 11 
 12 import scimath as emath
---> 13 from polynomial import *
 14 #import convertcode
 15 from utils import *

/usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/lib/polynomial.py
 
in ()
  9 import re
 10 import warnings
---> 11 import numpy.core.numeric as NX
 12 
 13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack

AttributeError: 'module' object has no attribute 'core'
sage: 

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org