ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 Feb 2019 07:50:00 -0600where to report bugs found using systems used by sage?https://ask.sagemath.org/question/42895/where-to-report-bugs-found-using-systems-used-by-sage/I am finding lots of bugs in systems used by sageMath. So not sure if I should report them to sagebug tracking as I have been doing, or to the other systems. The problem I can't find a place to report them for the other systems.
For example
>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.3.rc0, Release Date: 2018-07-08 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable. ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: var('x d a c b')
(x, d, a, c, b)
sage: integrate(sqrt(d*x^2 + e*x + c)*sqrt((b*x^2 + a)^2)/x^4,x, algorithm="giac")
Giac crashed -- automatically restarting.
sage0*x
#another bug. Just Added also as new comment ticket
# at https://trac.sagemath.org/ticket/25822
sage: var('x g b f n c a d');
sage: integrate(1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3),x, algorithm="giac")
Done
I searched and searched, and can't find even a forum for Giac or a place to report a bug. is giac even supported system? I went to https://www-fourier.ujf-grenoble.fr/~parisse/giac.html and I see no place to report bugs. I clicked on the forum link there, but it is dead link.
Same for Maxima. I can't find where to report bugs found it is when using sagemath.
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.3.rc0, Release Date: 2018-07-08 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable. ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
var('x')
integrate(log(sin(x))*sin(x)^2,x)
;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;
I once send email about a different maxima bug to maxima-bugs@lists.sourceforge.net but
never heared back and I do not see it posted on anywhere on sourceforge. I do not think any one reads these.
May be sagemath should have an OFFICIAL web page, listing the exact location of where
to report bugs found in systems used by sagemath if they are not to be reported to sagemath
bug database?NasserTue, 10 Jul 2018 14:51:00 -0500https://ask.sagemath.org/question/42895/Strange matrix producthttps://ask.sagemath.org/question/45547/strange-matrix-product/When I enter
A = matrix([[1, 2], [-1, 0], [1, 1]])
B = matrix([[0, 4], [1, -1], [1, 2]])
A*B
I get an error message, as expected.
But when I enter
A = matrix(QQ, [[1, 2], [-1, 0], [1, 1]])
B = matrix(QQ, [[0, 4], [1, -1], [1, 2]])
A*B
I get the output
[ 1 0]
[ 1 -2]
[ 1 3]
However, if I try
A = matrix(QQ, [[1, 2], [-1, 0], [1, 1]])
B = matrix(QQ, [[0, 4], [1, -1], [1, 2], [2, 2]])
A*B
I get an error message.
In all of the examples I try, Sage will give some output for a matrix product of two matrices of the same size as long as the field QQ is specified for at least one of the matrices. I’ve searched online and haven’t found anything to help me understand this. This will be problematic for my students who might draw the conclusion that the standard matrix product is defined when it really isn't. Can anyone help me understand this?SteveSMon, 25 Feb 2019 07:50:00 -0600https://ask.sagemath.org/question/45547/Characteristic polynomial of symbolic matrix of size 7https://ask.sagemath.org/question/43839/characteristic-polynomial-of-symbolic-matrix-of-size-7/There is a problem when computing the characteristic polynomial of a matrix of size greater than 7 containing a large number of symbolic variables.
<pre><code>a = SR.var('a', 100)
M = identity_matrix(SR, 7)
for i in range(7):
for j in range(7):
M[i,j] = a[i*7+j]
print(M.charpoly().degree()) # prints 5
</code></pre>
The value it should print is 7. Over $\mathbb{Z}[a_0,a_1,\dots]$, the result is correct.
I use Sage 8.3 (Release Date: 2018-08-03), installed from the official repository of Archlinux. The bug is present both in command line and with `sage file.sage` (if I copy and paste the code above).ScreenNameSat, 06 Oct 2018 01:04:49 -0500https://ask.sagemath.org/question/43839/Computing polyhedron from MIPhttps://ask.sagemath.org/question/33782/computing-polyhedron-from-mip/ I want to run the following code (I'm using SAGE v6.10 release version 2015-12-18):
P = MixedIntegerLinearProgram()
x = P.new_variable()
A = random_matrix(RR, 3, 2);
P.add_constraint(A*x <= [2.1,1.5,0.4])
P.polyhedron()
However, it outputs the error message:
> AttributeError: type object 'float'
> has no attribute 'fraction_field'
I noticed that if instead of using real variables I use only integer variables, then it works fine. For instance:
P = MixedIntegerLinearProgram()
x = P.new_variable()
A = random_matrix(ZZ, 3, 2);
P.add_constraint(A*x <= [2,1,0])
P.polyhedron()
outputs:
> A 2-dimensional polyhedron in QQ^2
> defined as the convex hull of 1 vertex
> and 2 rays
What do you suggest to overcome this problem?
ThanksmforetsTue, 14 Jun 2016 07:09:09 -0500https://ask.sagemath.org/question/33782/a problem with variables in real domainshttps://ask.sagemath.org/question/37766/a-problem-with-variables-in-real-domains/Hi,
I have a problem with setting the domains of definition of variables.
For example, typing
var("y") ; assume(y, "real")
conjugate(y + I)
I get the result `y + I`. The same with `var("y", domain="real")`.
Where I'm wrong?
thanks!danieleFri, 02 Jun 2017 12:12:44 -0500https://ask.sagemath.org/question/37766/Sage seems to be improperly computing an infinite sum, and giving an incorrect answerhttps://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/Reference this question: https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/
Here is the evaluation of an infinite sum in sage:
var('n')
f(n) = (-1)^(n+1)/(3*n+6*(-1)^n)
sum(f(2*n)+f(2*n+1),n,0,oo)
1/3*log(2) - 7/9
Evaluating the same sum in Mathematica:
f[n_] := (-1)^(n + 1)/(3*n + 6*(-1)^n)
Sum[f[2*n] + f[2*n + 1], {n, 0, Infinity}]
1/6 (-2 + Log[4])
Sage seems to be giving an incorrect solution. Am I missing something?rtcWed, 02 Nov 2016 12:23:14 -0500https://ask.sagemath.org/question/35354/hurwitz_zeta bug?https://ask.sagemath.org/question/9157/hurwitz_zeta-bug/The doc (reference/sage/combinat/combinat.html) says:
"hurwitz_zeta(s,x,N) returns the value of the zeta(s,x) to N decimals, where s and x are real."
With Sage 5.0 I get:
hurwitz_zeta(3,1,32) = 1.202056903159594285...
hurwitz_zeta(-3,1,32) -> SyntaxError: unexpected EOF while parsing
petropolisTue, 17 Jul 2012 08:57:50 -0500https://ask.sagemath.org/question/9157/to_directed() affects original graphhttps://ask.sagemath.org/question/36705/to_directed-affects-original-graph/ I've stumbled on what I think is a bug. When you create a directed graph from some original graph and then making changes on the new, this can affect the old one. I'm not sure if it should be like this and one should always copy the graph first. Here's a minimal example that for be gives an error "KeyError: 0".
G1=graphs.RandomGNP(5,0.5)
G1.plot(save_pos=True)
G2=G1.to_directed()
G2.delete_vertex(0)
G2.add_vertex(5)
G2.plot()
G1.plot()AckslThu, 23 Feb 2017 04:27:23 -0600https://ask.sagemath.org/question/36705/how to turn off symbolic sum evaluationhttps://ask.sagemath.org/question/9649/how-to-turn-off-symbolic-sum-evaluation/I made some symbolic manipulation and finally... I want to save a 'sum()' in a input form (a evaluated version is horrible big). It is possible to turn off the sum evaluation in SAGE? F_RanekMon, 04 Nov 2013 03:15:35 -0600https://ask.sagemath.org/question/9649/chromatic polynomial of empty graphhttps://ask.sagemath.org/question/34831/chromatic-polynomial-of-empty-graph/ I know it is kind of silly, but the computation of the chromatic polynomial of the empty graph loops forever.
graphs.EmptyGraph().chromatic_polynomial()
(no question here... just a comment. I guess it is easy to correct, since it is supposed to be 1)EmersonLThu, 15 Sep 2016 18:04:32 -0500https://ask.sagemath.org/question/34831/canonicalize_radical for matrices.https://ask.sagemath.org/question/34302/canonicalize_radical-for-matrices/The following all works
sage: a = sqrt(2)*sqrt(3)*sqrt(6)
sage: v = vector([a])
sage: M = Matrix([v, v])
sage: a.canonicalize_radical()
6
sage: v.canonicalize_radical()
(6)
However the following doesn't work:
sage: M = Matrix([v, v])
sage: M.canonicalize_radical()
EDIT: Could somebody please tell me the right place to ask for "vectorization of canonicalize_radical for matrices" as a new feature of sage?Saul SchleimerTue, 02 Aug 2016 13:46:22 -0500https://ask.sagemath.org/question/34302/Inconsistency in q_analogues?https://ask.sagemath.org/question/34140/inconsistency-in-q_analogues/In:
from sage.combinat.q_analogues import q_int
from sage.combinat.q_analogues import q_factorial
from sage.combinat.q_analogues import q_binomial
from sage.combinat.q_analogues import q_catalan_number
print q_int(5).parent()
print q_factorial(5).parent()
print q_binomial(3,2).parent()
print q_catalan_number(5).parent()
Out:
Univariate Polynomial Ring in q over Integer Ring
Univariate Polynomial Ring in q over Integer Ring
Univariate Polynomial Ring in q over Integer Ring
Fraction Field of Univariate Polynomial Ring in q over Integer Ring
What is the reason that the q_catalan_numbers have a different type than, say, the q_factorials?Peter LuschnyTue, 19 Jul 2016 14:47:44 -0500https://ask.sagemath.org/question/34140/Anticommutator of matriceshttps://ask.sagemath.org/question/9278/anticommutator-of-matrices/Dear all.
I was playing around with matrices, and found out that the commutator is defined, however, I didn't find the anti-commutator.
**Question**
- Is it implemented?
The implementation of commutator is about 5 lines (including comments), so the inclusion of it would be marginal.
Cheers.DoxThu, 30 Aug 2012 05:52:52 -0500https://ask.sagemath.org/question/9278/qepcad failing to replicate exampleshttps://ask.sagemath.org/question/26771/qepcad-failing-to-replicate-examples/ I was attempting to replicate the examples seen here (http://www.sagemath.org/doc/reference/interfaces/sage/interfaces/qepcad.html), but I keep getting errors.
Given
︠482004e5-daf3-4312-b5d7-a61b41d210a4s︠
var('a,b,c,d,x,y,z')
qf = qepcad_formula;
ellipse = 3*x^2 + 2*x*y + y^2 - x + y - 7
F = qf.exists(y, ellipse == 0); F
qepcad(F)
︡202e02ca-ac90-4b34-afab-7d6ceb6d41f5︡{"stdout":"(a, b, c, d, x, y, z)\n"}︡{"stdout":"(E y)[3 x^2 + 2 x y + y^2 - x + y - 7 = 0]\n"}︡{"stderr":"Error in lines 5-5\n"}︡{"stderr":"Traceback (most recent call last):\n File \"/projects/45572f4b-6bd1-49bd-9d46-5f340788b465/.sagemathcloud/sage_server.py\", line 879, in execute\n exec compile(block+'\\n', '', 'single') in namespace, locals\n File \"\", line 1, in <module>\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/qepcad.py\", line 1431, in qepcad\n qe = Qepcad(formula, vars=vars, **kwargs)\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/qepcad.py\", line 777, in __init__\n qex._send('[ input from Sage ]')\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/expect.py\", line 212, in _send\n self._start()\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/expect.py\", line 445, in _start\n raise RuntimeError(\"unable to start %s\" % self.name())\nRuntimeError: unable to start QEPCAD\n"}︡
︠5c912bc8-cd8b-495c-9fa3-eda33c34530e︠
MickleMouseFri, 08 May 2015 19:08:34 -0500https://ask.sagemath.org/question/26771/Strange error with multivariate polynomialshttps://ask.sagemath.org/question/8917/strange-error-with-multivariate-polynomials/Hi -
I'm trying to calculate the resultant (with respect to one variable, say x) of a pair of 2-variable polynomials. Following some advice I found in [this trac ticket](http://trac.sagemath.org/sage_trac/ticket/2693), I tried entering something like this:
R.<x,y> = RR[]
P = 4*x^3*y^2 + 7*x^5*y - 3*x*y^4
Q = 5*x^3*y^3 - 9*y^2
P.polynomial(x).resultant(Q.polynomial(x))
However, `P.polynomial(x)` returns the error:
`ValueError: max() arg is an empty sequence`
(Full error message pasted below.) Same problem with `P.polynomial(y)`, etc. It seems to work okay if the coefficient ring is `ZZ` or `QQ` instead of `RR`.
Does anyone know why this is happening, or of a different workaround for calculating these resultants?
Thanks!
Full error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_28.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Ui48eCx5PiA9IFJSW10KcCA9IHggKyB5CnEgPSB4KnkKcC5wb2x5bm9taWFsKHgpLnJlc3VsdGFudChxLnBvbHlub21pYWwoeCkp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/5h/c6x89ch91fjgr43q99g8wbjw0000gn/T/tmpVUVLIc/___code___.py", line 5, in <module>
exec compile(u'p.polynomial(x).resultant(q.polynomial(x))
File "", line 1, in <module>
File "multi_polynomial.pyx", line 452, in sage.rings.polynomial.multi_polynomial.MPolynomial.polynomial (sage/rings/polynomial/multi_polynomial.c:5376)
File "parent.pyx", line 988, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7355)
File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3311)
File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3214)
File "/Applications/Sage-4.8-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_ring.py", line 407, in _element_constructor_
return C(self, x, check, is_gen, construct=construct, **kwds)
File "polynomial_real_mpfr_dense.pyx", line 87, in sage.rings.polynomial.polynomial_real_mpfr_dense.PolynomialRealDense.__init__ (sage/rings/polynomial/polynomial_real_mpfr_dense.c:3418)
ValueError: max() arg is an empty sequence
jdcMon, 23 Apr 2012 03:33:16 -0500https://ask.sagemath.org/question/8917/How to evaluate $\int_1^2 e^{x^3} dx$?https://ask.sagemath.org/question/26212/how-to-evaluate-int_12-ex3-dx/I tried to evaluate $\int_1^2 e^{x^3} dx$ in Sage. Is this a bug?
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.5, Release Date: 2015-02-17 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: x=var('x');N(integrate(exp(x^3),x,1,2))
-138.557717219510 - 238.442320120796*I
sage:
mathhobbyistMon, 16 Mar 2015 16:59:03 -0500https://ask.sagemath.org/question/26212/How to upgrade a python package with pip?https://ask.sagemath.org/question/10978/how-to-upgrade-a-python-package-with-pip/I'm trying to set up QuantLib and PyQL on cloud.sagemath. QuantLib builds out of the box. For PyQL, I need Cython >0.18; installed version is 0.15. If I try a local install:
pip install --user --upgrade --ignore-installed cython
pip tries to uninstall the system version, which of course fails. Any idea how to proceed?phnSat, 01 Feb 2014 13:01:43 -0600https://ask.sagemath.org/question/10978/Sagetex : hyphen in filename forbidden ?https://ask.sagemath.org/question/25624/sagetex-hyphen-in-filename-forbidden/I want to cross-compile (pdflatex + sage + pdflatex) a TeX file : it's ok with the filename "a-b.tex", but not for a-n.tex, where i get the error message
CRITICAL:root:unknown notebook: None
Error, notebook must be one of default, ipython, sagenb but got None
It seems that the problem is with the "-n" part of a-n.tex
it's a bug or a feature ?
lg
macosX 10.10.1 + sage 6.4.1
laugWed, 28 Jan 2015 07:43:55 -0600https://ask.sagemath.org/question/25624/homology of simplicial complexeshttps://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/I am building a simplicial complex as follows:
sage: S = range(1,7)
sage: Z = SimplicialComplex([S])
sage: T = Z.n_skeleton(1)
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (2, 6), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (4, 5), (1, 5), (1, 6)]), -1: set([()])}
sage: T.homology()
{0: 0, 1: Z^10}
So far everything seems good. Then I try adding a face to T.
sage: T.add_face([1,2,6])
sage: T.faces()
{0: set([(4,), (5,), (3,), (1,), (6,), (2,)]), 1: set([(2, 4), (3, 6),
(5, 6), (1, 5), (1, 4), (3, 5), (3, 4), (2, 3), (4, 6), (2, 5), (1, 2),
(1, 3), (1, 6), (2, 6), (4, 5)]), 2: set([(1, 2, 6)]), -1: set([()])}
So the face seems to have been added.
But then:
sage: T.homology()
results in:
{0: 0, 1: Z^10, 2: 0}
But this doesn't make any sense --- it should say `0:0, 1:Z^9, 2:0`, since adding a 2-face kills a class in $H_1(T)$.
Can anyone tell what I'm doing wrong?
MattKahleSun, 24 Mar 2013 11:40:49 -0500https://ask.sagemath.org/question/9943/a bug in computing minimum distance, coding theoryhttps://ask.sagemath.org/question/24504/a-bug-in-computing-minimum-distance-coding-theory/ For anyone who is familiar with coding theory, we build codes as a subspace of the vector space F_q^n from generating matrices, with all linear combinations of rows of this matrix. For any generating matrix defined over a Finite Field, SAGE has spesific attributes "C =LinearCode(G)" which constructs the code from generating matrix and "C.minimum_distance()" which computes the minimum distance of the code.
However, there is probably a bug or something which I couldn't find out.
For example see this:
This code is a [7,3] linear code over the field GF(4,"a"), which has min. distance 3,(as computed with MAGMA), but SAGE computes its min. distance as 5, which is above upper bound!
This is the SAGE input-output:
K = GF(4,"a"); a = K.gen(); G = Matrix([[a, a + 1, 1, a + 1, 1, 0, 0], [0, a, a + 1, 1, a + 1, 1, 0], [0, 0, a, a + 1, 1, a + 1, 1], [a + 1, 0, 1, 0, a + 1, 1, a + 1], [a, a + 1, a + 1, 0, 0, a + 1, 1], [a + 1, a, a, 1, 0, 0, a + 1], [a, a + 1, 1, a + 1, 1, 0, 0]]); C=LinearCode(G); C; C.minimum_distance();
gives the output:
︡"Linear code of length 7, dimension 3 over Finite Field in a of size 2^2" "5"
However for the same conditions MAGMA says this:
︡> G6 := LinearCode <F,7|[[a, a + 1, 1, a + 1, 1, 0, 0], [0, a, a + 1, 1, a + 1, 1, 0], [0, 0, a, a + 1, 1, a + 1, 1], [a + 1, 0, 1, 0, a + 1, 1, a + 1], [a, a + 1, a + 1, 0, 0, a + 1, 1], [a + 1, a, a, 1, 0, 0, a + 1], [a, a + 1, 1, a + 1, 1, 0, 0]]>; G6;
[7, 3, 3] Linear Code over GF(2^2)
I don't understand where SAGE fails..
Do you have any idea?
algebraicallyclosedThu, 16 Oct 2014 12:14:26 -0500https://ask.sagemath.org/question/24504/Continued fraction of pi by handhttps://ask.sagemath.org/question/10702/continued-fraction-of-pi-by-hand/Hello, I'm a newbie in Sage.
I tried to compute (sagenb.org) the continued fraction of pi by hand with the following commands
<pre><code>n=15
x=range(n+1);a=range(n)
x[0]=pi
for i in range(n):
a[i] = int(x[i])
x[i+1]=1/(x[i]-a[i])
print(a[i])
</code></pre>
the answer (14 terms) is correct, but then I get
<pre><code>Traceback (click to the left of this block for traceback)
...
ValueError: Calling floor() on infinity or NaN</code></pre>
Am I doing something wrong?
CheersMarco CaliariTue, 05 Nov 2013 21:41:54 -0600https://ask.sagemath.org/question/10702/Introduction -- Sage Tutorial v6.2 -hyperlink to Dive is not workinghttps://ask.sagemath.org/question/23309/introduction-sage-tutorial-v62-hyperlink-to-dive-is-not-working/ Hi,
I just installed sage-mathematics on my ArchLinux operating system.
In Help / Introduction, the Dive hyperlink doesn't work.
There is not [http://diveintopython.org/](http://diveintopython.org/) address, but [http://diveintopython.net/](http://diveintopython.net/), so please correct this error.
--
Regards, from PalPal CsanyiWed, 09 Jul 2014 09:39:53 -0500https://ask.sagemath.org/question/23309/What are the differences between RealDoubleField() and RealField(53) ?https://ask.sagemath.org/question/9991/what-are-the-differences-between-realdoublefield-and-realfield53/Hi,
This question is related to
[question 2402](http://ask.sagemath.org/question/2402/what-are-the-different-real-numbers-in-sage)
(still open!) and tries to collect differences between RDF=RealDoubleField() and RR=RealField(53).
These are two floating point real number fields with both 53 bits of precision. The first one comes from the processor floating-point arithmetic, the second one is "emulated" by mpfr. They are assumed to follow the same rounding standards (to the nearest, according to the [sagebook](http://sagebook.gforge.inria.fr/), but i may be wrong).
However, we can see some differences between them:
sage: RDF(1/10)*10 == RDF(1)
False
sage: RDF(1/10)*10 - RDF(1)
-1.11022302463e-16
sage: RR(1/10)*10 == RR(1)
True
sage: sage: RR(1/10)*10 - RR(1)
0.000000000000000
Could you explain that ?
**EDIT: this was a bug and it is now fixed**, see [trac ticket 14416](http://trac.sagemath.org/ticket/14416).
There are also some specificities on which field should be used for some
methods.
- For example, it seems that the eignevalues are not well computed on RR, but are
correctly computed on RDF ([see trac #13660](http://trac.sagemath.org/sage_trac/ticket/13660)). What is the reason for that ?
- Also, it seems that when dealing with huge matrices, the fast atlas library in
only used when entries are in RDF, not in RR
([see trac #10815](http://trac.sagemath.org/sage_trac/ticket/10815)).
Are there other difference that should be known between both implementations of floating point numbers in Sage ?
ThierrytmonteilThu, 04 Apr 2013 13:34:40 -0500https://ask.sagemath.org/question/9991/simplify_full - is the mistake in the documentation or the source code?https://ask.sagemath.org/question/10939/simplify_full-is-the-mistake-in-the-documentation-or-the-source-code/Looking at the simplify_full documentation in Sage 6.0, it says that it
> Applies simplify_factorial,
> simplify_trig, simplify_rational,
> simplify_radical, simplify_log, and
> again simplify_rational to self (in
> that order).
However the source code is
def simplify_full(self):
x = self
x = x.simplify_factorial()
x = x.simplify_trig()
x = x.simplify_rational()
x = x.simplify_log('one')
x = x.simplify_rational()
return x
So where is the mistake? Should simplify_radical be added to the source code or removed from the documentation?brkirchFri, 17 Jan 2014 09:38:00 -0600https://ask.sagemath.org/question/10939/strange way to simplify square rootshttps://ask.sagemath.org/question/9534/strange-way-to-simplify-square-roots/Hi!
Let us consider the number
>a=1/sqrt(4-2*sqrt(3))-1/(sqrt(3)-1)
which is zero. If we simplify
>a.simplify_full().n()
we obtain
-2.73205080756888 - 8.36449319149292e-17*I,
which of course is false. I guess it is a problem handling complex roots of degree four, but still, it don't seems to me a reasonable computation. ¿Anybody knows how to fix it?
mathematicboyWed, 14 Nov 2012 06:48:49 -0600https://ask.sagemath.org/question/9534/simplification errors in simple expressionshttps://ask.sagemath.org/question/8324/simplification-errors-in-simple-expressions/I'm currently testing the possibilities of SAGE as a teaching aid in a high school math course (in Belgium). I stumbled upon this:
- When evaluating x/sqrt(x^2), SAGE answers $\frac{x}{|x|}$, as it should. Appending a ***.simpify()***-instruction to the input does not change anything.
- However, `((1-x^2)/sqrt(1-2*x^2+x^4)).simplify_full()` evaluates to $-1$, in stead of $\frac{1-x^2}{|1-x^2|}$.
As an aside, it's definitely baffling that a behemoth program like SAGE is outdone in this respect by a one-floppy-disk, antique program called DERIVE.
As another aside, I still have to find a meaningful use for the instruction ***simplify()***. Can someone provide me an expression that is actually simplified by simplify()?
***Note added:***
I'm not sure I'm satisfied with mr. Fateman's answer (and I definitely disagree that defining sqrt(x^2)=|x| - for real x - entails +1=-1). But what I really want to know is this: is there a SAGE object that represents (reliably) the positive square root of a positive real number x? (Surely a quantity that is not without interest.) And how do I define it in SAGE?Dirk DanckaertThu, 22 Sep 2011 10:53:33 -0500https://ask.sagemath.org/question/8324/Generate Maximal subsets based on mutual/subset propertyhttps://ask.sagemath.org/question/10316/generate-maximal-subsets-based-on-mutualsubset-property/Sorry for the imprecise language - I'm not a mathematician.
Given a list/set/dict/etc., is there a function/method available that will generate subsets, with the possibility of non-null intersections, based on some user defined mutual/subset property?
E.g., given a list [0,1,2,3,4,5], generate the maximal lists such that the maximum difference within each list is 3. For the given list, the function would produce [[0,1,2,3],[1,2,3,4],[2,3,4,5]]. For the list [0,3,9,10,17,30,33], this function would produce [[0,3],[9,10],[17],[30,33]].
This is different than the usual filtering operation in that the defining property is about the returned lists/sets/etc., not just about the individual elements.
Function should work with members of ZZ, QQ, RR, RDF, CC, CDF, and others if possible.rickhg12hsWed, 03 Jul 2013 21:54:17 -0500https://ask.sagemath.org/question/10316/boolean with numpyhttps://ask.sagemath.org/question/10580/boolean-with-numpy/Hello!
Please explain me why
numpy.array([1/5])[0] == 0.2
is False but
numpy.array([1/5.])[0] == 0.2
is True. At 2nd line of code there is point after 5. <br>
What should I do to get true at first line of code? <br>
Thanks a lot.AndreWinSun, 29 Sep 2013 01:28:25 -0500https://ask.sagemath.org/question/10580/Error while integrate using algorithm='sympy' (bug)https://ask.sagemath.org/question/10370/error-while-integrate-using-algorithmsympy-bug/Hello!
I found next bug:
var('x, y')
integrate(y, y, 0, 8*log(x))
RuntimeError: ECL says: Error executing code in Maxima: defint: upper
limit of integration must be real; found 8*log(x)
Then I decided to use sympy:
var('x, y')
integrate(y, y, 0, 8*log(x), algorithm='sympy')
32*log(x)^2
Nice! But when I replaced 0 --> 0.5 (int --> real):
var('x, y')
integrate(y, y, 0.5, 8*log(x), algorithm='sympy')
AttributeError: 'sage.rings.real_mpfr.RealLiteral' object has no
attribute '_sympy_'
M.... I opened real_mpfr.pyx and added:
1314 def _sympy_(self):
1315 """
1316 Return sympy object.
1317 AUTHORS: #########################
1318 """
1319 import sympy
1320 return(sympy.symplify(float(self)))
(I added line numbers in my code above and remove authors informations (that is about me))
Then I tryed to load:
load('/home/andrei/Programs/Sage/sage-5.10/devel/sage/sage/rings/real_mpfr.pyx')
And there are many-many errors while compilling... Help me please!
Thanks.
AndreWinSun, 21 Jul 2013 06:15:59 -0500https://ask.sagemath.org/question/10370/error computing homology of a simplicial complexhttps://ask.sagemath.org/question/10117/error-computing-homology-of-a-simplicial-complex/I'm running code to first generate a simplicial complex that is just a 3 dimensional lattice. I'm then adding square plaquettes. However, I get an error sometimes when I try to calculate homology. Specifically, when I run the code below I get the error:
> ValueError: The differentials d_{2} and d_{1} are not compatible: their
composition is not zero.
This seems strange since a simplicial complex should always have homology. The error persists even when I specify the homology function to use different algorithms.
def grid(n1, n2=None, n3=None):
if n2 == None:
n2 = n1
if n3 == None:
n3 = n1
edges = []
for i in range(n1+1):
for j in range(n2+1):
for k in range(n3+1):
if i < n:
edges.append(((i,j,k),(i+1,j,k)))
if j < n:
edges.append(((i,j,k),(i,j+1,k)))
if k < n:
edges.append(((i,j,k),(i,j,k+1)))
return edges
def add_plaquette(complex, address):
b = address[1]
a1 = address[2]
a2 = address[3]
if address[0] == 2:
complex.add_face(((a1,a2,b),(a1+1,a2,b),(a1,a2+1,b)))
complex.add_face(((a1+1,a2+1,b),(a1+1,a2,b),(a1,a2+1,b)))
if address[0] == 1:
complex.add_face(((a1,b,a2),(a1+1,b,a2),(a1,b,a2+1)))
complex.add_face(((a1+1,b,a2+1),(a1+1,b,a2),(a1,b,a2+1)))
if address[0] == 0:
complex.add_face(((b,a1,a2),(b,a1+1,a2),(b,a1,a2+1)))
complex.add_face(((b,a1+1,a2+1),(b,a1+1,a2),(b,a1,a2+1)))
t0 = SimplicialComplex(grid(2))
add_plaquette(t0, (0,0,1,0))
add_plaquette(t0, (0,0,1,1))
add_plaquette(t0, (2,2,0,1))
t0.homology()
The full text of the error is:
> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_8.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("I2dpdmVzIGVycm9yIHNhdmUhISEKdDAgPSBTaW1wbGljaWFsQ29tcGxleChncmlkKDIpKQphZGRfcGxhcXVldHRlKHQwLCAoMCwwLDEsMCkpCmFkZF9wbGFxdWV0dGUodDAsICgwLDAsMSwxKSkKYWRkX3BsYXF1ZXR0ZSh0MCwgKDIsMiwwLDEpKQp0MC5ob21vbG9neSgp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
> File "", line 1, in <module>
> File "/tmp/tmpBNPSQ1/___code___.py", line 7, in <module>
exec compile(u't0.homology()
> File "", line 1, in <module>
> File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/cell_complex.py", line 549, in homology
return self._homology_(dim, **kwds)
> File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/simplicial_complex.py", line 1925, in _homology_
cochain=cohomology, **kwds)
> File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/simplicial_complex.py", line 1788, in chain_complex
return ChainComplex(data=differentials, degree=-1, **kwds)
> File "/home/sage/sage-5.9/local/lib/python2.7/site-packages/sage/homology/chain_complex.py", line 462, in __init__
raise ValueError, "The differentials d_{%s} and d_{%s} are not compatible: their composition is not zero." % (n, n+degree)
>ValueError: The differentials d_{2} and d_{1} are not compatible: their composition is not zero.parsons.kyle.89Mon, 13 May 2013 15:48:01 -0500https://ask.sagemath.org/question/10117/