[sage-support] Possible Sqrt Simplification Bug

2014-10-29 Thread Zak V
Hello,
I believe I found a bug in how radicals are simplified.  The general 
idea is that sqrt(x^2)=abs(x), but sage simplifies sqrt(x^2) to x instead, 
even if x is negative.  I've included a simple example below.  

sage: x = var('x')
sage: assume(x0)
sage: expr = sqrt(x^2)
sage: simp_expr=expr.simplify_radical()
sage: eqn = expr==simp_expr
sage: print eqn
sqrt(x^2) == x
sage: print eqn.subs(x=-1) #Clearly this is wrong
1 == -1
sage: abs(x).simplify() #However, Sage knows how to deal with abs(x) for x0
-x

I've never used the Sage Trac system before, so I thought posting this to 
here might instead might be a good idea.  Hope this is helpful.

Cheers,
Zak

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Passing graphics objects

2014-03-24 Thread steven . v . wilkinson
I want to create a plot by traversing a tree where some leaves of the data 
structure add line segments. I am trying to pass one graphics object to a 
function that adds a line segment to the graphics object. I assumed the 
graphics object is passed by reference so that changes inside the function 
would affect the original graphics object. However, that is not the case. How 
can one build up a graphics object via function calls?

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'lc'

2012-11-01 Thread V
Maybe this is not the problem, because as far as I can see libc6-dev is 
installed:

$ dpkg -l |grep libc6-dev
ii  libc6-dev2.11.3-4   
Embedded GNU C Library: Development Libraries and Header Files
$

Any other suggestions?

On Wednesday, October 31, 2012 8:49:03 PM UTC+1, Dima Pasechnik wrote:

 On 2012-10-31, V vesselin@gmail.com javascript: wrote: 
  --=_Part_281_17041689.1351705746629 
  Content-Type: text/plain; charset=ISO-8859-1 
  Content-Transfer-Encoding: quoted-printable 
  
  
  Sorry, I was not able to attach the full log file gcc-4.6.3.log. 
 Please=20 
  find below the most relevant parts of it. 

 it looks like you need to install libc library headers, i.e. dpkg named 
 libc6-dev 



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'lc'

2012-11-01 Thread V
Thanks! The missing library was libc6-dev-amd64. I installed it and this 
fixed the stubs-64.h error. Now the compilation breaks with the  error:

/usr/bin/ld: cannot find -lmpc

A more detailed log:

/usr/bin/ld: skipping incompatible /tmp/sage-5.3/local/lib/libmpc.a when 
searching for -lmpc
/usr/bin/ld: cannot find -lmpc
collect2: ld returned 1 exit status
make[5]: *** [cc1] Error 1
make[5]: Leaving directory 
`/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/gcc'
make[4]: *** [all-stage2-gcc] Error 2
make[4]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[3]: *** [stage2-bubble] Error 2
make[3]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'

real20m42.735s
user20m1.815s
sys 0m29.186s

Error installing package gcc-4.6.3


...

make[1]: *** [installed/gcc-4.6.3] Error 1
make[1]: Leaving directory `/tmp/sage-5.3/spkg'

I can see that I have the library libmpc installed:

$ dpkg -l |grep mpc
ii  libmpc-dev   0.8.2-1+b1 
multiple precision complex floating-point library development package
ii  libmpc2  0.8.2-1+b1 
multiple precision complex floating-point library

Any ideas? 

Thanks!

V.





On Thursday, November 1, 2012 12:38:19 PM UTC+1, Dima Pasechnik wrote:

 On 2012-11-01, V vesselin@gmail.com javascript: wrote: 
  --=_Part_80_29635451.1351758463692 
  Content-Type: text/plain; charset=ISO-8859-1 
  
  Maybe this is not the problem, because as far as I can see libc6-dev is 
  installed: 
  
  $ dpkg -l |grep libc6-dev 
  ii  libc6-dev2.11.3-4   
 
  Embedded GNU C Library: Development Libraries and Header Files 
  $ 
  
  Any other suggestions? 
 well, I just looked at this error: 

 /usr/include/gnu/stubs.h:9:27: fatal error: gnu/stubs-64.h: No such file 
 or directory 

 and (presuming your hardware is amd64, the file stubs-64.h should be 
 in libc6-dev 


 http://packages.debian.org/search?searchon=contentskeywords=stubs-64.hmode=exactfilenamesuite=stablearch=any
  

 maybe you don't have it? 
 Then look at the above like and try to figure out which dpkg needs to be 
 installed... 

 HTH, 
 Dmitrii 
 I


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'lc'

2012-10-31 Thread V
Hello,

I try to execute one of the examples for computing the variety of a system of 
Boolean polynomials from the Sage reference manual: 

http://www.sagemath.org/doc/reference/sage/rings/polynomial/pbori.html

and I get the error:

AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no 
attribute 'lc'

The exact code that I execute is:

R = BooleanPolynomialRing(6, ['x%d'%(i+1) for i in range(6)], order='lex')
R.inject_variables()
polys = [x1*x2 + x1*x4 + x1*x5 + x1*x6 + x1 + x2 + x3*x4 + x3*x5 + x3 + x4*x5 + 
x4*x6 + x4 + x5 + x6, x1*x2 + x1*x3 + x1*x4 + x1*x6 + x2*x3 + x2*x6 + x2 + 
x3*x4 + x5*x6, x1*x3 + x1*x4 + x1*x6 + x1 + x2*x5 + x2*x6 + x3*x4 + x3 + x4*x6 
+ x4 + x5*x6 + x5 + x6, x1*x2 + x1*x3 + x1*x4 + x1*x5 + x2 + x3*x5 + x3*x6 + x3 
+ x5 + x6, x1*x2 + x1*x4 + x1*x5 + x1*x6 + x2*x3 + x2*x4 + x2*x5 + x3*x5 + 
x5*x6 + x5 + x6, x1*x2 + x1*x6 + x2*x4 + x2*x5 + x2*x6 + x3*x6 + x4*x6 + x5*x6 
+ x5]
I = R.ideal(polys)
V1 = I.variety()  

When I run the above I get:

sage: load poly.sage
Defining x1, x2, x3, x4, x5, x6
verbose 0 (2854: multi_polynomial_ideal.py, groebner_basis) Warning: falling 
back to very slow toy implementation.
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (398, 0))

---
AttributeErrorTraceback (most recent call last)

/home/foo/ipython console in module()

/sage-4.8/sage-4.8-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/sage/misc/preparser.pyc
 in load(filename, globals, attach)
   1645 else:
   1646 # Preparse in memory only for speed.
- 1647 exec(preparse_file(open(fpath).read()) + \n, globals)
   1648 elif fpath.endswith('.spyx') or fpath.endswith('.pyx'):
   1649 import interpreter


...

The last lines of the error log are:

sage-4.8/sage-4.8-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/sage/rings/polynomial/toy_buchberger.pyc
 in inter_reduction(Q)
433 Q.add(h)
434 if Qbar == Q:
435 if base_ring.is_field():
-- 436 return set([f.lc()**(-1) * f for f in Qbar])
437 else: return Qbar

/home/foo/sage-4.8/sage-4.8-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/sage/structure/element.so
 in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2856)()

AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no 
attribute 'lc'

I am using Sage version: 'Sage Version 4.8, Release Date: 2012-01-20' on a 
64-bit machine running Debian GNU/Linux.

Thanks for your help!

Regards,
V.

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'lc'

2012-10-31 Thread V
Thank you for the quick reply! I tried to compile Sage-5.3 from source and 
I get an error related to gcc-4.6.3:

In file included from /usr/include/features.h:378:0,
 from /usr/include/stdio.h:28,
 from ../../../src/libgcc/../gcc/tsystem.h:87,
 from ../../../src/libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:9:27: fatal error: gnu/stubs-64.h: No such file or 
directory
compilation terminated.
make[5]: *** [_muldi3.o] Error 1
make[5]: Leaving directory 
`/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/x86_64-unknown-linux-gnu/libgcc'
make[4]: *** [all-stage1-target-libgcc] Error 2
make[4]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[3]: *** [stage1-bubble] Error 2
make[3]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'



Error installing package gcc-4.6.3

Please email sage-devel (http://groups.google.com/group/sage-devel)
explaining the problem and including the relevant part of the log file
  /tmp/sage-5.3/spkg/logs/gcc-4.6.3.log

...

Please find attached the log file. FYI, I am using Debian GNU/Linux running 
on a 64-bit machine.

Thanks for your help!

V.


On Wednesday, October 31, 2012 6:14:37 PM UTC+1, John H Palmieri wrote:



 On Wednesday, October 31, 2012 9:39:11 AM UTC-7, V wrote:

 Hello,

 I try to execute one of the examples for computing the variety of a 
 system of Boolean polynomials from the Sage reference manual: 

 http://www.sagemath.org/doc/reference/sage/rings/polynomial/pbori.html

 and I get the error:

 [snip]

  

 I am using Sage version: 'Sage Version 4.8, Release Date: 2012-01-20' on 
 a 64-bit machine running Debian GNU/Linux.

  


 Your version of Sage is too old. That example in the reference manual was 
 introduced in version 5.2 of Sage, so it doesn't work in version 4.8.

 -- 
 John



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'lc'

2012-10-31 Thread V

Sorry, I was not able to attach the full log file gcc-4.6.3.log. Please 
find below the most relevant parts of it.

...
checking whether the target assembler supports thread-local storage... yes
checking whether the thread-local storage support is from emutls... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: executing default commands
make[5]: Entering directory 
`/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/x86_64-unknown-linux-gnu/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/./gcc/xgcc 
-B/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/./gcc/ 
-B/tmp/sage-5.3/local/x86_64-unknown-linux-gnu/bin/ 
-B/tmp/sage-5.3/local/x86_64-unknown-linux-gnu/lib/ -isystem 
/tmp/sage-5.3/local/x86_64-unknown-linux-gnu/include -isystem 
/tmp/sage-5.3/local/x86_64-unknown-linux-gnu/sys-include-g -O2 -O2  -g -O2 
-DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes 
-Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g 
-DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fno-stack-protector  
 -I. -I. -I../.././gcc -I../../../src/libgcc -I../../../src/libgcc/. 
-I../../../src/libgcc/../gcc -I../../../src/libgcc/../include 
-I../../../src/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS 
-DUSE_EMUTLS -DUSE_TLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep 
-DL_muldi3 -c ../../../src/libgcc/../gcc/libgcc2.c \
  -fvisibility=hidden -DHIDE_EXPORTS
In file included from /usr/include/features.h:378:0,
 from /usr/include/stdio.h:28,
 from ../../../src/libgcc/../gcc/tsystem.h:87,
 from ../../../src/libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:9:27: fatal error: gnu/stubs-64.h: No such file or 
directory
compilation terminated.
make[5]: *** [_muldi3.o] Error 1
make[5]: Leaving directory 
`/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build/x86_64-unknown-linux-gnu/libgcc'
make[4]: *** [all-stage1-target-libgcc] Error 2
make[4]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[3]: *** [stage1-bubble] Error 2
make[3]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/sage-5.3/spkg/build/gcc-4.6.3/gcc-build'

real2m53.027s
user2m34.986s
sys 0m13.329s

Error installing package gcc-4.6.3

Please email sage-devel (http://groups.google.com/group/sage-devel)
explaining the problem and including the relevant part of the log file
  /tmp/sage-5.3/spkg/logs/gcc-4.6.3.log
Describe your computer, operating system, etc.
If you want to try to fix the problem yourself, *don't* just cd to
/tmp/sage-5.3/spkg/build/gcc-4.6.3 and type 'make' or whatever is appropriate.
Instead, the following commands setup all environment variables
correctly and load a subshell for you to debug the error:
  (cd '/tmp/sage-5.3/spkg/build/gcc-4.6.3'  '/tmp/sage-5.3/sage' -sh)
When you are done debugging, you can type exit to leave the subshell.



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: substitution problem

2009-03-31 Thread V

On Mar 30, 6:07 pm, Jason Grout jason-s...@creativetrax.com wrote:
 V wrote:
  Hi,

  I'm fairly new to sage with some background in maxima.

  My workbook is shared at
 http://www.sagenb.org/home/pub/410/

  the last three lines show the error I get.

  Basically, I derive an equilibrium condition that I would like to use
  in the previous stage of my game (solving by backwards induction), but
  maxima fails (line -2) with simplifying after the substitution is
  made, even though the substitution is successful (line -3).

  I expect to receive the line in the last paragraph as defined by
  D1p.

  Is this a bug or did I made a mistake?

 In this line,

 solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)

 you are trying to solve for q1, but q1 is not a variable, it's the
 expression:

 f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1

 Did you mean to solve for a variable in the solve statement above?


The expression in the solve line would be a demand function where q
stands for quantity. But as it is derived from a later stage of the
game, q is present on the right hand side as well, and I would like
to express the demand function explicitly, that is I have q=f(q,x)
where x are all the other parameters and q is defined implicitly, and
I would like to have q=g(x).

I thought solve would do this for me, even though I already understand
why it doesn't, I still don't know how to do it. Could you give me a
hint, please?

Thanks, V
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: substitution problem

2009-03-31 Thread V

This is exactly what I wanted. Thanks for your help! :)

I'll look up the maxima manuals to see if I can force it to think
harder. Thanks anyway!

Have a nice day!
V

On Mar 31, 3:35 pm, Jason Grout jason-s...@creativetrax.com wrote:
 V wrote:
  On Mar 30, 6:07 pm, Jason Grout jason-s...@creativetrax.com wrote:
  V wrote:
  Hi,
  I'm fairly new to sage with some background in maxima.
  My workbook is shared at
 http://www.sagenb.org/home/pub/410/
  the last three lines show the error I get.
  Basically, I derive an equilibrium condition that I would like to use
  in the previous stage of my game (solving by backwards induction), but
  maxima fails (line -2) with simplifying after the substitution is
  made, even though the substitution is successful (line -3).
  I expect to receive the line in the last paragraph as defined by
  D1p.
  Is this a bug or did I made a mistake?
  In this line,

  solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)

  you are trying to solve for q1, but q1 is not a variable, it's the
  expression:

  f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1

  Did you mean to solve for a variable in the solve statement above?

  The expression in the solve line would be a demand function where q
  stands for quantity. But as it is derived from a later stage of the
  game, q is present on the right hand side as well, and I would like
  to express the demand function explicitly, that is I have q=f(q,x)
  where x are all the other parameters and q is defined implicitly, and
  I would like to have q=g(x).

  I thought solve would do this for me, even though I already understand
  why it doesn't, I still don't know how to do it. Could you give me a
  hint, please?

 I see.

 Disclaimer: I don't know the mathematics that you are doing, so forgive
 me if I mess things up below...

 When you do q1==q1.subs(...), what the computer sees is:

 f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1
 == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
 alpha)*beta + alpha^2 - alpha)*q1^alpha^2*A^(1 - alpha^2)

 This doesn't seem like what you want; you want the left side to be a
 single variable, and the right side to have q1 be that same single
 variable.  So maybe you can do something like:

 sage: var('q')
 sage: q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q)
 q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
 alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)
 sage:
 solve(q==q1.substitute(q2=sol2[0][1].right()).simplify_full().subs(q1=q), q)
 [q == f1^(alpha^2 - 1)*p1^((alpha - alpha^2)*beta + alpha - 1)*p2^((1 -
 alpha)*beta + alpha^2 - alpha)*q^alpha^2*A^(1 - alpha^2)]

 So it doesn't look like maxima is able to handle this.

 Jason
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] substitution problem

2009-03-30 Thread V

Hi,

I'm fairly new to sage with some background in maxima.

My workbook is shared at
http://www.sagenb.org/home/pub/410/

the last three lines show the error I get.

Basically, I derive an equilibrium condition that I would like to use
in the previous stage of my game (solving by backwards induction), but
maxima fails (line -2) with simplifying after the substitution is
made, even though the substitution is successful (line -3).

I expect to receive the line in the last paragraph as defined by
D1p.

Is this a bug or did I made a mistake?

Thanks for your help!
V

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---