Re: [sage-support] Re: Bug in Graph.is_chordal

2011-10-29 Thread Nathann Cohen
Hellooo again !!!

I finally wrote this patch, available there :

http://trac.sagemath.org/sage_trac/ticket/11961

Though the two algorithms are very similar, I thought it better to
split it into two different parts, so that one can understand better
how each of them works without having to bear with if algorithm == A
every second line. Two implementations are now available, two are
checked before being returned, both pass all tests. We should be on
the safe side, now :-D

Thank you for your help !! :-)

Nathann

-- 
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: [sage-edu] A typical microeconomic problem with SAGE (Constrained optimization)

2011-10-29 Thread David Joyner
Cross-posting. See below.

On Sat, Oct 29, 2011 at 10:38 AM, Julio del Corral Cuervo
jdelcorra...@gmail.com wrote:
 I am a lecturer in Microeconomics in a Spanish University and I am
 trying to show students how can be handled some microeconomics problem
 into SAGE.

 The first problem that I faced is that i am not able to solve the
 subsequent problem
 Minimize x+2*y
 subject to 16=2*x**0.25*y**0.5

 I have tried several ways to handle this problem. One of them is:

 var('x,y,lam')
 L(x,y,lam)= x+2*y -lam*(16-2*x**0.25*y**0.5)
 eq1=L.diff(x)
 eq2=L.diff(y)
 eq3=L.diff(lam)
 solve([eq1==0,eq2==0,eq3==0], x,y,lam)


 But I do not obtain any result neither in the web version nor the the
 virtual box version.


This might be a bug (?).
I'll cc sage-support.


 Thanks for the help,
 Julio del Corral
 http://www3.uclm.es/profesorado/jcorral/I-Index.php

 --
 You received this message because you are subscribed to the Google Groups 
 sage-edu group.
 To post to this group, send email to sage-...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sage-edu+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sage-edu?hl=en.



-- 
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: A typical microeconomic problem with SAGE (Constrained optimization)

2011-10-29 Thread achrzesz
If you realy need the exact solution then you can tray something like
that


var('x,y,lam,x4,y2')
assume(x40)
assume(y20)
L= x+2*y -lam*(16-2*x^(1/4)*y^(1/2))
eq1=numerator(factor(L.diff(x)))
eq1=eq1(y=y2^2,x=x4^4).full_simplify()
eq2=numerator(factor(L.diff(y)))
eq2=eq2(y=y2^2,x=x4^4).full_simplify()
eq3=numerator(factor(L.diff(lam)))
eq3=eq3(y=y2^2,x=x4^4).full_simplify()
s=solve([eq1==0,eq2==0,eq3==0], x4,y2,lam)
print [[(sol[0].rhs())^4,(sol[1].rhs())^2] for sol in s if
sol[0].rhs()0 and sol[1].rhs()0]

[16,16]]

But the numerical approach is simpler:

sage: from scipy.optimize import fmin_slsqp
sage: fmin_slsqp(lambda x:x[0]+2*x[1], [2.0, 2.0], eqcons=[lambda x:
16.0-2*x[0]**0.25*x[1]**0.5])
Optimization terminated successfully.(Exit mode 0)
Current function value: 47.996459
Iterations: 9
Function evaluations: 36
Gradient evaluations: 9
array([ 16.018 ,  15.9893])

Compare the picture:
var('x y z')
p1=implicit_plot3d(16-2*x^(1/4)*y^(1/2),(x,0,32),(y,0,32),(z,0,100))
p2=plot3d(x+2*y,(x,0,32),(y,0,32),color='red')
(p1+p2).show()

Andrzej Chrzeszczyk

-- 
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] Ticket # 5310 and related issues

2011-10-29 Thread Rolandb
Hi,

What the status is of factoring integers: from 1 up to 80-100 digits?
Ticket #5310 seems to address this by implementing Msieve, but I
noticed no activity lately.

For instance n.trail_division() speeds up calculations a lot, but it
seems not be integrated with a general approach. This implies that for
small integers up to 10^8 the speed of n.trail_division() seems not to
be used by factor().

To illustrate my point, please look at the following example.

def fastfactor(n):
if n in [1,0,-1]: return [(n,1)]

uit=[]
d=1
while n not in [1,d]:
d=n.trial_division()
e=1
n=n//d
while n%d==0:
e+=1
n=n//d
uit.append((d,e))
if n1: uit.append((n,1))
return uit

m=6
timeit('for i in xsrange(10^m,10^m+1000): fastfactor(i)')
timeit('for i in xsrange(10^m,10^m+1000): list(i.factor())')

25 loops, best of 3: 8.15 ms per loop
25 loops, best of 3: 30.6 ms per loop

I sincerely hope that release 4.7.3 will also focus on speeding up the
most used functions like factor, but also uniq, gcd, xgcd and other
elementary functions.

Thanks in advance for your informative reply.

Roland

-- 
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] Area of the intersection of two regions

2011-10-29 Thread Renan Birck Pinheiro
Hello,

Suppose I want to get the area of the intersection of two regions, given by
x^2+y^2  4 and x+y1 .

In Mathematica I can use

Integrate[
 Boole[And[x^2 + y^2  4,
   x + y  1]], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

Boole is a function which turns True into 1 and False into 0.

How can I do the same in SAGE? I tried:

def boole(x):
if(x == True):
return 1
return 0

integrate(integrate( boole(x^2+y^24 and x+y1),(x,-oo,oo)),(y,-oo,oo))

but it doesn't work (gives zero).

Thanks!
-- 
Renan Birck Pinheiro - Grupo de MicroeletrĂ´nica
http://www.ufsm.br/gmicro- Engenharia
Elétrica http://www.ufsm.br/cee/UFSM http://www.ufsm.br

http://renanbirck.blogspot.com / skype: renan.ee.ufsm

-- 
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


Re: [sage-support] Ticket # 5310 and related issues

2011-10-29 Thread William Stein
Sage's factor currently just calls pari which makes no use of anything
anywhere else in sage.  It would be nice if somebody were to change this,
but I have seen many people try and fail.

On Saturday, October 29, 2011, Rolandb rola...@planet.nl wrote:
 Hi,

 What the status is of factoring integers: from 1 up to 80-100 digits?
 Ticket #5310 seems to address this by implementing Msieve, but I
 noticed no activity lately.

 For instance n.trail_division() speeds up calculations a lot, but it
 seems not be integrated with a general approach. This implies that for
 small integers up to 10^8 the speed of n.trail_division() seems not to
 be used by factor().

 To illustrate my point, please look at the following example.

 def fastfactor(n):
if n in [1,0,-1]: return [(n,1)]

uit=[]
d=1
while n not in [1,d]:
d=n.trial_division()
e=1
n=n//d
while n%d==0:
e+=1
n=n//d
uit.append((d,e))
if n1: uit.append((n,1))
return uit

 m=6
 timeit('for i in xsrange(10^m,10^m+1000): fastfactor(i)')
 timeit('for i in xsrange(10^m,10^m+1000): list(i.factor())')

 25 loops, best of 3: 8.15 ms per loop
 25 loops, best of 3: 30.6 ms per loop

 I sincerely hope that release 4.7.3 will also focus on speeding up the
 most used functions like factor, but also uniq, gcd, xgcd and other
 elementary functions.

 Thanks in advance for your informative reply.

 Roland

 --
 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


-- 
William Stein
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 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org