ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 07 Feb 2021 17:41:51 +0100multivariate polynomial ring over complex numbershttps://ask.sagemath.org/question/34692/multivariate-polynomial-ring-over-complex-numbers/ I want to factorize bivariate polynomials over C. For single variable case we do this as follow:
R=CC[x]
x=R.gen()
f=x^2+1
f.factor()
How to do this for multivariate case ?nebuckandazzerFri, 02 Sep 2016 19:33:45 +0200https://ask.sagemath.org/question/34692/i doesn't belong to QQbar ? Why ?https://ask.sagemath.org/question/39509/i-doesnt-belong-to-qqbar-why/I do not understand this :
sage: sqrt(1) in QQbar
True
sage: sqrt(-2) in QQbar
True
sage: sqrt(-1) in QQbar
False
Can someone explain ?
Note that, however :
sage: [t[0] in QQbar for t in (x^2+1).roots(ring=QQbar)]
[True, True]Emmanuel CharpentierSun, 12 Nov 2017 20:55:13 +0100https://ask.sagemath.org/question/39509/possible bug: kernel of ring homomorphismhttps://ask.sagemath.org/question/55618/possible-bug-kernel-of-ring-homomorphism/ The kernel of a ring homomorphism to a quotient ring gives unexpected results:
A.<t> = QQ[]
B.<x,y> = QQ[]
H = B.quotient(B.ideal([B.1]))
f = A.hom([H.0], H)
f
f.kernel()
outputs:
Ring morphism:
From: Univariate Polynomial Ring in t over Rational Field
To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (y)
Defn: t |--> xbar
Principal ideal (t) of Univariate Polynomial Ring in t over Rational Field
whereas the kernel of f:A[t]->B[x,y]->B[x,y]/(y), for f(t)=x should be (0).
Why?makosSun, 07 Feb 2021 17:41:51 +0100https://ask.sagemath.org/question/55618/where 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 21:51:00 +0200https://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 14:50:00 +0100https://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 08:04:49 +0200https://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 14:09:09 +0200https://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 19:12:44 +0200https://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 18:23:14 +0100https://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 15:57:50 +0200https://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 11:27:23 +0100https://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 10:15:35 +0100https://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)EmersonLFri, 16 Sep 2016 01:04:32 +0200https://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 20:46:22 +0200https://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 21:47:44 +0200https://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 12:52:52 +0200https://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︠
MickleMouseSat, 09 May 2015 02:08:34 +0200https://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 10:33:16 +0200https://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 22:59:03 +0100https://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 20:01:43 +0100https://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 14:43:55 +0100https://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 17:40:49 +0100https://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 19:14:26 +0200https://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 CaliariWed, 06 Nov 2013 04:41:54 +0100https://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 16:39:53 +0200https://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 20:34:40 +0200https://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 16:38:00 +0100https://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 13:48:49 +0100https://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 17:53:33 +0200https://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.rickhg12hsThu, 04 Jul 2013 04:54:17 +0200https://ask.sagemath.org/question/10316/