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.Tue, 31 Aug 2021 21:41:52 +0200"SignalError: Illegal instruction" on calling .right_kernel()https://ask.sagemath.org/question/58775/signalerror-illegal-instruction-on-calling-right_kernel/**UPDATE.** I see the same problem in both Sage 9.3 and Sage 9.4 (but not in Sage 9.2), the screenlog below is for Sage 9.4.
I have a particular matrix on which computing `.right_kernel()` by Sage 9.4 results in `SignalError: Illegal instruction`.
How to deal with such an error?
sage: load("bug_illegal_kernel.sage")
---------------------------------------------------------------------------
SignalError Traceback (most recent call last)
<ipython-input-1-5e05d00e2706> in <module>
----> 1 load("bug_illegal_kernel.sage")
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2563)()
171
172 if sage.repl.load.is_loadable_filename(filename):
--> 173 sage.repl.load.load(filename, globals())
174 return
175
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/repl/load.py in load(filename, globals, attach)
270 add_attached_file(fpath)
271 with open(fpath) as f:
--> 272 exec(preparse_file(f.read()) + "\n", globals)
273 elif ext == '.spyx' or ext == '.pyx':
274 if attach:
<string> in <module>
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix.right_kernel (build/cythonized/sage/matrix/matrix2.c:31019)()
4715
4716 # Go get the kernel matrix, this is where it all happens
-> 4717 M = self.right_kernel_matrix(*args, **kwds)
4718
4719 ambient = R**self.ncols()
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix.right_kernel_matrix (build/cythonized/sage/matrix/matrix2.c:29656)()
4316 if M is None:
4317 try:
-> 4318 format, M = self._right_kernel_matrix(algorithm=algorithm, proof=proof)
4319 except AttributeError:
4320 pass
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense._right_kernel_matrix (build/cythonized/sage/matrix/matrix_integer_dense.cpp:22522)()
2694 proof = kwds.pop('proof', None)
2695 proof = get_proof_flag(proof, "linear_algebra")
-> 2696 K = self._rational_kernel_iml().transpose().saturation(proof=proof)
2697 format = 'computed-iml-int'
2698 else:
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/matrix/matrix_integer_dense.pyx in sage.matrix.matrix_integer_dense.Matrix_integer_dense._rational_kernel_iml (build/cythonized/sage/matrix/matrix_integer_dense.cpp:32421)()
3882 time = verbose('computing null space of %s x %s matrix using IML'%(self._nrows, self._ncols))
3883 cdef mpz_t * m = fmpz_mat_to_mpz_array(self._matrix)
-> 3884 sig_on()
3885 dim = nullspaceMP(self._nrows, self._ncols, m, &mp_N)
3886 sig_off()
SignalError: Illegal instruction
----
`lscpu` output:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 40
On-line CPU(s) list: 0-39
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Model name: Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
Stepping: 4
CPU MHz: 2892.940
CPU max MHz: 3300.0000
CPU min MHz: 1200.0000
BogoMIPS: 4987.83
Virtualization: VT-x
L1d cache: 640 KiB
L1i cache: 640 KiB
L2 cache: 5 MiB
L3 cache: 50 MiB
NUMA node0 CPU(s): 0-9,20-29
NUMA node1 CPU(s): 10-19,30-39
Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1dMax AlekseyevTue, 31 Aug 2021 21:41:52 +0200https://ask.sagemath.org/question/58775/system eqs + eq with abs() then solve() kills the Kernelhttps://ask.sagemath.org/question/58202/system-eqs-eq-with-abs-then-solve-kills-the-kernel/ Hi
W10 ,SageMath 9.2
if I uncomment line 3 below, it kills the Kernel.
varL=var('a,b,c,d',domain='real')
eqL=[a == -d, b*c == 0, a*(b + c) == 0]
#eqL.append((abs(a)+abs(b)+abs(c))!=0)
show("so we need : \t ",eqL)
S=solve(eqL,varL)
show(S)
ortolljMon, 02 Aug 2021 10:28:54 +0200https://ask.sagemath.org/question/58202/Calculation with arbitrary precisionhttps://ask.sagemath.org/question/58144/calculation-with-arbitrary-precision/I know I can ask Sage to display the digits of Pi with arbitrary precision with `n(pi, digits= 202)` for example. Is it possible to ask it to perform an operation -- like a numerical integral -- to an arbitrary precision? That is, by specifying the number of significative digits.
I tried:
```
n(numerical_integral(exp(-1/x)/x, 0, 1 ),digits=200)
```
but that obviously produce the wrong answer.
I also know I can do:
```
integrate(e * exp(-1/x)/x,x, 0, 1 ).n(300)
```
but that integral seems to be computed symbolically.ApprenticeThu, 29 Jul 2021 02:21:07 +0200https://ask.sagemath.org/question/58144/Several charts at top create trouble with submanifoldshttps://ask.sagemath.org/question/57431/several-charts-at-top-create-trouble-with-submanifolds/My issue seems pretty trivial, however, I cannot find a way.
I create a manifold, with 2 frames/charts, and create transition_map between them.
Create a metric. I create then a submanifold, create `diff_map` to the first manifold,
and make an embedding. Then I try to get the `induced_metric`.
It works only if the `diff_map` is referenced to the first created frame/chart at top level.
In my example:
- top manifold with cartesian and cylindrical charts
- sub manifold is a cylinder. I cannot base it on the cylindrical top chart.
My purpose would be to have a top manifold series of charts
at top and natural embeddings of lower dimension manifolds.
Any idea?
My code:
E = Manifold(3, 'E', structure='Riemannian')
cartesian.<x,y,z> = E.chart()
cartesian_frame = cartesian.frame()
cylindrical.<r,ph,z> = E.chart(r'r:(0,+oo) ph:(0,2*pi):\phi z')
cylindrical_frame = cylindrical.frame()
cyl2cart = cylindrical.transition_map(cartesian , [r*cos(ph), r*sin(ph), z])
cart2cyl = cyl2cart.set_inverse(sqrt(x^2 + y^2), atan2(y, x), z)
ecc = E.coord_changes()
for cc in ecc:
display(ecc[cc].display())
g = E.metric()
g[cartesian_frame, 0, 0], g[cartesian_frame, 1, 1], g[cartesian_frame, 2, 2] = 1, 1, 1
display(g.display(cartesian))
display(g.display(cylindrical))
C2 = Manifold(2, 'C2', ambient=E, structure='Riemannian')
Cyl2.<ph,z> = C2.chart(r'ph:\phi z')
Cyl2_frame = Cyl2.frame()
if True: # True shows issue
E.set_default_frame(cylindrical_frame)
E.set_default_chart(cylindrical)
Cyl2tocylindrical = C2.diff_map(E, {(Cyl2, cylindrical): [1, ph, z]})
cylindricaltoCyl2 = E.diff_map(C2, {(cylindrical, Cyl2): [ph, z]})
C2.set_embedding(Cyl2tocylindrical)
else:
Cyl2tocartesian = C2.diff_map(E, {(Cyl2, cartesian): [cos(ph), sin(ph), z]})
cartesiantoCyl2 = E.diff_map(C2, {(cartesian, Cyl2): [arctan2(y, x), z]})
C2.set_embedding(Cyl2tocartesian)
C2g = C2.induced_metric() # never an error message here
display(C2g.display()) # exhibits the issueLPsFRThu, 03 Jun 2021 09:45:18 +0200https://ask.sagemath.org/question/57431/Bug? Polynomial variable name mattershttps://ask.sagemath.org/question/57796/bug-polynomial-variable-name-matters/The following calculation of an intersection of curves over `QQbar` raises an error within Singular on Sage v9.2.
P.<a, y, z> = ProjectiveSpace(QQbar, 2)
f = a^3 + z^3
C = Curve(f)
g = (a + y)^3 + z^3
D = Curve(g)
print(C.intersection_points(D))
It does work when replacing the variable name `a` by `x`.
I assume this is a bug but could not trace it down to the internals of `rational_points` and the Singular interface. The variables `b`and `d` work, whereas `c` raises a different error. Does anyone know more about that? Is it already fixed in the newer versions? Should I post this as a ticket on [https://trac.sagemath.org](https://trac.sagemath.org)?FabianGMon, 28 Jun 2021 13:13:57 +0200https://ask.sagemath.org/question/57796/Quotient of polynomial ring over integers not workinghttps://ask.sagemath.org/question/56734/quotient-of-polynomial-ring-over-integers-not-working/I have a problem. I want Sage to calculate in $\mathbb Z[x]/\langle4,2x,x^2\rangle$ but none of the relations are being calculated/recognized properly:
sage: R.<x> = ZZ[]
sage: I = R.ideal(4,2*x,x^2)
sage: S.<a> = R.quotient(I)
sage: a^2 # the output should be 0
a^2
sage: 2*a # the output should be 0
2*a
sage: S(2)+S(2) # the output should be 0
4
When I introduce a superfluous variable $y$ and consider $\mathbb Z[x,y]/\langle4,2x,x^2,y\rangle$ instead, which is practically the same ring (i.e. isomorphic), then it seems to work:
sage: R.<x,y> = ZZ[]
sage: I = R.ideal(4,2*x,x^2,y)
sage: S.<a,b> = R.quotient(I)
sage: a^2
0
sage: 2*a
0
sage: S(2)+S(2)
0
But now look at this:
sage: S(2)+S(3) # the output should be 1
5
How can I solve this problem?ThrashMon, 19 Apr 2021 22:33:39 +0200https://ask.sagemath.org/question/56734/Computing the factored multiplicative order of an extension field tries to solve an unnecessarily hard factoring problemhttps://ask.sagemath.org/question/56710/computing-the-factored-multiplicative-order-of-an-extension-field-tries-to-solve-an-unnecessarily-hard-factoring-problem/There seems to be a unnecessary performance problem with constructing large extension fields:
sage: p = 0x24000000000024000130e0000d7f70e4a803ca76f439266f443f9a5cda8a6c7be4a7a5fe8fadffd6a2a7e8c30006b9459ffffcd300000001
sage: GF(p^2)
This hangs trying to factor the 891-bit integer $p^2 - 1$, which is longer than the longest solved RSA Challenge number. (As it happens, the hard part of this factorization is a 675-bit integer which is still impractical.)
It is not unreasonable that constructing the extension field requires knowing the factorization of the multiplicative order. (You can get around this by constructing it with a specific modulus, but then many operations, e.g. taking roots, require this factorization anyway.)
However, we know that $p^2 - 1$ splits as $(p-1)(p+1)$, and factoring those may be much more feasible:
sage: factor(p-1)
2^32 * 3^4 * 17 * 67 * 293 * 349 * 1997 * 19556633 * 44179799701097 * 1461985442088199434216480729118540833655826472878315075486478169293801719414121837587283877
sage: factor(p+1)
2 * 313 * 751 * 2003 * 2671 * 738231097 * 55047696457335561580180364861378466840614260303507426009866606293225963076275651294902969015038913167956483928299
(this takes less than a second on my desktop).
In general, computing the multiplicative order of an extension field should take advantage of the factorization of $p^k - 1$ as a polynomial. There might also be other cases where we know the factorization by construction, and should be able to provide it.dairaSun, 18 Apr 2021 12:48:15 +0200https://ask.sagemath.org/question/56710/Finite Field Extensionhttps://ask.sagemath.org/question/56220/finite-field-extension/I am using SageMath version 9.2. I was trying the example in the documentation:
`sage: k = GF(2)`
`sage: k.extension(x^1000 + x^5 + x^4 + x^3 + 1, 'a')`
However, this gives the error: `UnboundLocalError: local variable 'E' referenced before assignment`
How do I fix this?
cathreyaThu, 18 Mar 2021 15:59:04 +0100https://ask.sagemath.org/question/56220/Plot "color_by_label" produces SQUARED number of lines in digraphhttps://ask.sagemath.org/question/56324/plot-color_by_label-produces-squared-number-of-lines-in-digraph/I bumped into this unusual behavior and am not sure how to fix it.
When I add `color_by_label` for plotting a digraph I get the correct
number SQUARED of lines appearing in the digraph. Is this an error
in SageMath or is there a workaround? All monochrome lines
do not work for my application.
This is my code sample:
stnc = 'ABCCCCDABCDABCDA'
g = DiGraph({}, loops=True, multiedges=True)
for a, b in [(stnc[i], stnc[i + 1]) for i in range(len(stnc) - 1)]:
g.add_edge(a, b, b)
sage: g.edges()
[('A', 'B', 'B'), ('A', 'B', 'B'), ('A', 'B', 'B'),
('B', 'C', 'C'), ('B', 'C', 'C'), ('B', 'C', 'C'),
('C', 'C', 'C'), ('C', 'C', 'C'), ('C', 'C', 'C'),
('C', 'D', 'D'), ('C', 'D', 'D'), ('C', 'D', 'D'),
('D', 'A', 'A'), ('D', 'A', 'A'), ('D', 'A', 'A')]
# This produces the correct number of lines SQUARED
g.plot(color_by_label=True, edge_style='solid', layout='circular').show(figsize=(8, 8))
# Correct number of lines but monochrome
g.plot(layout='circular').show(figsize=(8, 8))
![Incorrect edge multiplicity for multidigraph with color_by_label](/upfiles/16164608644236614.png)
Each edge should have multiplicity 3.
In the plot with color edges, each has multiplicity 9.
The plot with no colors has correct multiplicity 3 for each edge.JJTue, 23 Mar 2021 00:17:54 +0100https://ask.sagemath.org/question/56324/Function composition not workinghttps://ask.sagemath.org/question/56217/function-composition-not-working/I'm experiencing some strange behavior when composing two basic functions. My OS is Windows 10. Here is an example:
sage: r=var('r')
sage: s=var('s')
sage: f(r)=r**2
sage: g(r)=r**(1/2)
sage: f(g(r))
sqrt(r)
sage: f(g(s))
s
Whenever I evaluate the functions at the variable they were defined with (or even if just the outer function was defined with it), Sage returns the inner function as the result. This seems to happen only when the two functions are inverses of each other, since it behaves as expected with $f(r)=r^2$ and $g(r)=r^{1/3}$, returning $r^{2/3}$.
Is this a known issue? Is this somehow expected behavior? Thanks for any help.tarix29Thu, 18 Mar 2021 03:32:41 +0100https://ask.sagemath.org/question/56217/when I must declare f= or f(x,y)= ?https://ask.sagemath.org/question/55417/when-i-must-declare-f-or-fxy/HI
Sorry for this really basic SageMath question ;-( :
Does anyone know the reason why an error is generated when I uncomment the 3rd line?
and is it possible when a function was declared (f(x)=) object to return to (f=) object ?
and when I must declare f(x)= , or simply f= ?
despite the reading of [Some Common Issues with Functions](https://doc.sagemath.org/html/en/tutorial/tour_functions.html)
var('x')
SGN=(x+2)*(x+1)*(x-1)*(x+1)
#SGN(x)=(x+2)*(x+1)*(x-1)*(x+1)
show(SGN.parent())
f(x)=1/x*sin(x)
plt=plot(f,(x,-3,3),color='blue')
plt+=plot(SGN,(x,-3,3),color='black',linestyle='dashed')
plt+=plot(sgn(SGN),(x,-5,5),color='gray',linestyle='dashed')
show(plt,xmin=-2,xmax=2,ymin=-3,ymax=3, aspect_ratio=1)
show(numerical_integral(f,0,2)[0])
show(numerical_integral(-sgn(SGN)*f,0,1)[0]+numerical_integral(sgn(SGN)*f,1,2)[0])ortolljFri, 22 Jan 2021 11:32:00 +0100https://ask.sagemath.org/question/55417/How do I understand the result of symbolic integralshttps://ask.sagemath.org/question/7574/how-do-i-understand-the-result-of-symbolic-integrals/So now I know how to integrate, but when I type in
sage: deriv=diff((exp(x)-1)/x,x); deriv
e^x/x - (e^x - 1)/x^2
sage: deriv.integrate(x)
-1/x + Ei(x) - gamma(-1, -x)
why don't I get back `(exp(x)-1)/x +C `?
Philipp SchneiderWed, 18 Aug 2010 20:04:12 +0200https://ask.sagemath.org/question/7574/Possible inconsistency in symbolic limitshttps://ask.sagemath.org/question/55370/possible-inconsistency-in-symbolic-limits/I was trying to manipulate some symbolic expressions and got an unexpected error.
Here is a minimal example,
u=integrate(x**3/(exp(x)-1),(x,0,oo))
The expression is quite messy, but the result is known. When I try to use any simplification routine, like
u.simplify()
sage displays the error message
RuntimeError: ECL says: Error executing code in Maxima: limit: direction must be either 'plus' or 'minus'; found: _SAGE_VAR_minus
As far I understood, the expression is defining lateral limits by symbolic variables, while maxima handle such limits as strings. If it is the case there is an internal conflict here. Is it the case?cav_rtWed, 20 Jan 2021 02:58:40 +0100https://ask.sagemath.org/question/55370/inverse image under ring homomorphismhttps://ask.sagemath.org/question/55099/inverse-image-under-ring-homomorphism/Hi there!
Just starting to learn Sage and can't get why both `inverse_image` calls
below give an error saying the given element does not have a preimage,
while `y^2` clearly has `xbar` as preimage.
Referring to the generators of `R1` and `R2` explicitly doesn't help either.
sage: R.<x, y> = QQ[]
sage: R1 = R.quotient(R.ideal(y^2 - x^3))
sage: R2 = R.quotient(R.ideal(x))
sage: h = R1.hom([y^2, y^3], R2)
sage: h
Ring morphism:
From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (-x^3 + y^2)
To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x)
Defn: xbar |--> y^2
ybar |--> y^3
sage: h.inverse_image(y)
Traceback (most recent call last)
...
ValueError: element y does not have preimage
sage: h.inverse_image(y^2)
Traceback (most recent call last)
...
ValueError: element y^2 does not have preimage
Thanks!KarinaMon, 04 Jan 2021 15:12:56 +0100https://ask.sagemath.org/question/55099/tensor_product of matrices over cyclotomic fieldhttps://ask.sagemath.org/question/54762/tensor_product-of-matrices-over-cyclotomic-field/Beginner question: I have created some matrices over a cyclotomic field and attempted to compute some of their tensor products:
N = 3
k.<w> = CyclotomicField(N)
Z = diagonal_matrix(k,N,[w^j for j in range(0,N)])
X = matrix(k,N,N,[1 if (i%N - floor(i/N)) % N == N-1 else 0 for i in range(0,N*N)])
I = identity_matrix(k,N)
I.tensor_product(X)
X.tensor_product(I)
Z.tensor_product(I)
Z.tensor_product(X)
#I.tensor_product(Z)
#X.tensor_product(Z)
If I uncomment either of the last two lines I get
> AttributeError: 'sage.matrix.matrix_generic_sparse.Matrix_generic_sparse' object has no attribute '_rational_matrix'
It seems my code is working when both matrices in the tensor product are rational or when self is non-rational, but not when self is rational and the argument is non-rational. Should I be somehow instructing sagemath to regard self as a matrix over the cyclotomic field?Will OrrickSat, 19 Dec 2020 20:38:38 +0100https://ask.sagemath.org/question/54762/Assumption seems to break integrate(); is this a bug?https://ask.sagemath.org/question/52382/assumption-seems-to-break-integrate-is-this-a-bug/Consider the following Sage code (tested using Sage 8.6):
var('t')
var('a')
t.integrate(t, 0, a) # \int_{0}^{a} t dt
Output (as expected):
t
a
1/2*a^2
Next:
t.integrate(t, 0, 4*a - a^2) # 4*a - a^2 could be positive, negative, non-real(?)
Output (again, no problem):
1/2*a^4 - 4*a^3 + 8*a^2
Now suppose we give Sage a little more information. The following assumptions should guarantee that we're integrating over a real interval, and that the second (or "top") endpoint is strictly greater than the first ("bottom") endpoint. (Though as we have seen, Sage does not really need this information.)
assume(a, 'real')
assume(a > 1)
assume(a < 3) # now 0 < a < 4, so 4*a - a^2 > 0
t.integrate(t, 0, 4*a - a^2) # hangs, eventually produces RuntimeError
So, `.integrate()` succeeds when nothing is known about the endpoint, but then fails when given more information.
**My Question: Is this desired/expected behavior, or would it be considered a bug?**
Personally, I found it surprising: I expected that, if a command worked with no assumptions, then it should still work after adding assumptions (consistent assumptions that only narrow the scope of the problem).
*What follows is purely my own speculation; feel free to ignore.*
I also get a similar kind of problem if I do the following:
forget()
var('t'); var('a');
assume(a, 'real')
assume(a > 1)
assume(a < 3)
bool(4*a - a^2 > 0) # hangs, RuntimeError
It seems to me that $1 < a < 3$ implies $0 < a < 4$, which implies that $-a^2 + 4a > 0$. (The graph of the quadratic is a downward-opening parabola, with roots at $0$ and $4$.) I am not surprised that Sage has trouble constructing this argument, so I am not surprised that the `bool()` command hangs. But unfortunately this also seems to break `.integrate()`, which was working otherwise.
So, I speculate that maybe the `.integrate()` method, when faced with an integral whose endpoints are known to be real, first tries to figure out which endpoint is greater? But sometimes this process hangs, so the `.integrate()` process never terminates?
In our case, I think Sage assumes by default that `a` is complex-valued(?), and then it has no problem with the integral. So it seems like it should still work when `a` is in the real interval $(1, 3)$, which after all is a subset of $\mathbb{C}$.
By the way, the following works just fine:
forget()
var('t'); var('a');
assume(4*a - a^2 > 0)
print(bool(4*a - a^2 > 0))
t.integrate(t, 0, 4*a - a^2)
Or, this also works:
t.integrate(t, 0, 2*a - a^2, algorithm='sympy')
Asked also at [Math Stackexchange](https://math.stackexchange.com/questions/3739105/assumption-seems-to-break-sages-integrate-function-is-this-a-bug), but did not receive an answer there. Apologies if this kind of cross-posting is frowned upon.mathmandanThu, 09 Jul 2020 03:26:26 +0200https://ask.sagemath.org/question/52382/minimize_constrained works for f(x,y)=x+y but not for f(x,y)=xhttps://ask.sagemath.org/question/54720/minimize_constrained-works-for-fxyxy-but-not-for-fxyx/Hi, need help to understand why `minimize_constrained`
works for `f(x, y) = x + y` but does not work for `f(x, y) = x`.
Example:
var('x, y')
f(x, y) = x + y
c(x, y) = 1 - x^2 - y^2
minimize_constrained(f(x, y), [c(x, y)], [0, 0])gpiresThu, 17 Dec 2020 01:53:54 +0100https://ask.sagemath.org/question/54720/Generators of simplicial homologyhttps://ask.sagemath.org/question/54070/generators-of-simplicial-homology/ I have this code to compute the homology of a simplicial complex
S = SimplicialComplex([[5, 2], [5, 2, 1], [5, 0], [5, 1], [4, 3], [4, 3, 0], [4, 2], [4, 0], [3, 0], [3, 1], [2, 1],])
S.homology(generators = True)
The output only consists of the homology, and does not contain the generators. Am I missing something?
springfieldgionThu, 29 Oct 2020 12:49:00 +0100https://ask.sagemath.org/question/54070/Crash with polynomial over "Givaro" finite fieldhttps://ask.sagemath.org/question/53696/crash-with-polynomial-over-givaro-finite-field/I would like to solve a system of equations
in a finite field of prime order $p$
(illustrated below with $p = 229$).
The system consists in four equations and has four unknowns
$a_0$, $a_1$, $a_2$, $a_3$.
It depends on parameters $\alpha_i$, $b_i$, all in $F(p)$,
for $i = 1, 2, 3, 4$.
The four equations are
$$a_0 + a_1 \alpha_1 + a_2 \alpha_1^2 + a_3 \alpha_1^3 = b_1$$
$$a_0 + a_1 \alpha_2 + a_2 \alpha_2^2 + a_3 \alpha_2^3 = b_2$$
$$a_0 + a_1 \alpha_3 + a_2 \alpha_3^2 + a_3 \alpha_3^3 = b_3$$
$$a_0 + a_1 \alpha_4 + a_2 \alpha_4^2 + a_3 \alpha_4^3 = b_4$$
To do this I have tried with the following examples:
pm = 229
bp = 229
F.<x> = GF(pm, impl='givaro')
R.<a0, a1, a2, a3> = PolynomialRing(F)
def NP(a):
return F(ZZ(a).digits(bp)) # integer to polynomial
eqns = [a0 + a1*NP(2) + a2*NP(2)^2 + a3*NP(2)^3 - NP(78),
a0 + a1*NP(3) + a2*NP(3)^2 + a3*NP(3)^3 - NP(136),
a0 + a1*NP(4) + a2*NP(4)^2 + a3*NP(4)^3 - NP(179),
a0 + a1*NP(5) + a2*NP(5)^2 + a3*NP(5)^3 - NP(166)]
A = matrix(F, [[eqn.coefficient(b) for b in R.gens()] for eqn in eqns])
b = vector(F, [-eqn.constant_coefficient() for eqn in eqns])
X = A.solve_right(b)
print(X)
But it shows erros:
Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------
/usr/share/sagemath/bin/sage-python: line 2: 7655 Segmentation fault (core dumped) sage -python "$@"
How can I fix this?MKSFri, 02 Oct 2020 01:48:21 +0200https://ask.sagemath.org/question/53696/Bug with newton polygons of Puiseux series in 9.1?https://ask.sagemath.org/question/53628/bug-with-newton-polygons-of-puiseux-series-in-91/I've been playing with Puiseux series and noticed that zero coefficients are not being assigned the correct valuation of infinity, so that the Newton polygon is not always correct. A minimal example follows: the two newton polygons should be the same, but they are not. The polygon for f2 is correct, while that of f1 is in error.
R.<x> = PuiseuxSeriesRing(QQ)
S.<y> = PolynomialRing(R)
f1 = y^2+x
f2 = y^2+x*y+x
X1=f1.newton_polygon().plot()
X2=f2.newton_polygon().plot()
show(X1)
show(X2)
If you do the same thing with Laurent series as opposed to Puiseux series, there is no problem and the polygons are equal (as expected):
R.<x> = LaurentSeriesRing(QQ)
S.<y> = PolynomialRing(R)
f1 = y^2+x
f2 = y^2+x*y+x
X1=f1.newton_polygon().plot()
X2=f2.newton_polygon().plot()
show(X1)
show(X2)
Similarly if you work over a p-adic field, there is no problem:
K=pAdicField(2)
S.<y> = PolynomialRing(K)
f1 = y^2+2
f2 = y^2+2*y+2
X1=f1.newton_polygon().plot()
X2=f2.newton_polygon().plot()
show(X1)
show(X2)
So this does seem to be a problem specific to Puiseux series. I'm not sure how to post a bug report, so I'm documenting this here in the hope that someone can help. Thanks!cfrancSun, 27 Sep 2020 23:32:57 +0200https://ask.sagemath.org/question/53628/Sage symbolic math simplification errorhttps://ask.sagemath.org/question/53345/sage-symbolic-math-simplification-error/In sagemath version 9.1, the code
product(1-q^x, x, 1, N)
returned
-(-1)^N*product(q^x - 1, x, 1, N)
while the correct result ought to be
(-1)^N*product(q^x - 1, x, 1, N)
What went wrong? Where did this sign change come from?ShoutOutAndCalculateMon, 07 Sep 2020 03:21:09 +0200https://ask.sagemath.org/question/53345/Combinations(range(100), 100).list() takes foreverhttps://ask.sagemath.org/question/53225/combinationsrange100-100list-takes-forever/ As title suggests,
`Combinations( range(100), 100 ).list()` takes forever.
On the other hand, `Combinations( range(100), 0 ).list()` is pretty fast.
Is there anything I can do to improve the performance?Symbol 1Mon, 31 Aug 2020 04:28:20 +0200https://ask.sagemath.org/question/53225/unavailable linkhttps://ask.sagemath.org/question/53190/unavailable-link/In the section "Geometry and Topology" on the page
- [https://doc.sagemath.org/pdf/en/reference/](https://doc.sagemath.org/pdf/en/reference/)
the first link is
:doc:`Euclidean Spaces and Vector Calculus`
which does not link to any file. Please fix this.danielvolinskiWed, 26 Aug 2020 20:13:12 +0200https://ask.sagemath.org/question/53190/Stack overflow during symbolic manipulationshttps://ask.sagemath.org/question/52986/stack-overflow-during-symbolic-manipulations/I'm trying to evaluate this cursed integral (finite for $ 0 < a < 1 $):
$$\int_0^1 \frac{x}{\log{\left(ax+(1-x)^2\right)}}{\rm d}x$$
using Sagemath 9.0 and 9.1:
sage: a = var('a')
sage: assume(a>0)
sage: assume(a<1)
sage: f = integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1)
leads to
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
Sympy gives a result even without the assumptions (which is odd by itself):
sage: f = integrate(x*log(1/(a*x+(1-x)*(1-x))), x, 0, 1, algorithm='sympy')
$$\frac{1}{4} \{\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) + \frac{1}{4} \{\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) - \frac{1}{2} a + \frac{1}{2} \log\left(\frac{1}{a}\right) + \frac{3}{2}$$
But then problems continue:
sage: f.simplify_full()
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
But:
sage: f.expand().simplify_full()
$$
-\frac{1}{2} {\left(2 \pi - {\left(\pi - \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} a - 2 \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + 2 \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} \sqrt{a} \sqrt{-a + 4} + \frac{1}{4} {\left(a^{2} - 4 a\right)} \log\left(a\right) - \frac{1}{2} a + \frac{3}{2}
$$
If I want to find the limit when $a\to 0$:
sage: f.limit(a=0)
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
and once again
sage: f.limit(a=0, algorithm="sympy")
$$-i \pi + \frac{3}{2}$$
Which is only true for $a<0$.
I previously found [this strange bug](https://ask.sagemath.org/question/48058/stack-overflow-in-boolean-test/) a while ago (fixed upstream, still present in Sagemath 9.1), this makes me think the assumption `assume(a>0)` is the root of it all, unfortunately it cannot be skipped to evaluate the integral properly.
Do you know when the updated version of Maxima will be included with Sagemath?
Do you think all these issues are linked to this old ticket or should it be investigated independently?
Florentin JaffredoThu, 13 Aug 2020 18:13:05 +0200https://ask.sagemath.org/question/52986/Unexpected intersection between parallel polygons.https://ask.sagemath.org/question/52910/unexpected-intersection-between-parallel-polygons/The `intersection` function returns a non-empty intersection for two polygons that are separated in space.
The following is a reproducible example:
# Define parallel polygons.
a = Polyhedron([[0, -1, 1], [1, -1, 1], [1, 1, -1]])
b = Polyhedron([[0.0, -0.5, 1.5], [1.0, -0.5, 1.5], [1.0, 1.5, -0.5]])
# Intersection.
c = a.intersection(b)
# c ->
# `A 2-dimensional polyhedron in RDF^3 defined as the convex hull of 3
# vertices (use the .plot() method to plot)`
a.plot(fill='green') + b.plot(fill='red') + c.plot(fill='orange')
noahytFri, 07 Aug 2020 22:00:13 +0200https://ask.sagemath.org/question/52910/Zero Matrix has an Inverse over Finite Field?https://ask.sagemath.org/question/52487/zero-matrix-has-an-inverse-over-finite-field/The following code
M = Matrix([0], ring=GF(4))
M
Prints "[0]" as expected. The inverse of M clearly does not exist. Even so, running
M.inverse()
does not throw an error, and instead prints "[1]". What's going on here?
I am running Sage 8.1. Thanks for the help.brantmvThu, 16 Jul 2020 04:15:30 +0200https://ask.sagemath.org/question/52487/How to change the unreadable dark blue colour in the SageMath command line window under Windows-10?https://ask.sagemath.org/question/47136/how-to-change-the-unreadable-dark-blue-colour-in-the-sagemath-command-line-window-under-windows-10/ I have just installed SageMath 8.7 on my Windows-10 laptop and want to learn it. The font colour of the prompt and of the typed numbers is dark blue on the black background, totally unreadable. Google search delivers tons of such complaints about bash/pythin/mintty/cygwin command lines. All suggest to edit some configuration files, which are hardly possible to locate in SageMath, neither in the SageMath installation directory, nor in my user home directory. There is a file ".sage\profile_default\ipython_config.py" in my Windows home, containing the line
c.TerminalInteractiveShell.colors = 'Linux'
Changing this line has no effect.SevasFri, 12 Jul 2019 12:59:10 +0200https://ask.sagemath.org/question/47136/assume gives false for a<oohttps://ask.sagemath.org/question/52135/assume-gives-false-for-aoo/ Hello
reset()
var('a')
assume(a<99)
print(bool(a<+Infinity)) # or print(bool(a<oo))
Why does this code print `False`. curios_mindSun, 21 Jun 2020 18:42:01 +0200https://ask.sagemath.org/question/52135/Error with rational input in IntegerVectorshttps://ask.sagemath.org/question/50814/error-with-rational-input-in-integervectors/ I discovered the following unexpected behavior of `IntegerVectors`:
sage: IntegerVectors(2,3).list()
[[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]]
sage: IntegerVectors(2,3/1).list()
[[2, 0, 0], [1, 1, 0]]
The relevant code block in the implementation of `IntegerVectors` seems to be the following:
try:
return IntegerVectors_nnondescents(n, tuple(k))
except TypeError:
pass
return IntegerVectors_nk(n, k)
For `k=3/1` one has that `tuple(k)` does not give a `TypeError` (as opposed to `tuple(3)`) and thus the code never tries to interpret `k` as an integer.Johannes SchmittFri, 17 Apr 2020 18:26:59 +0200https://ask.sagemath.org/question/50814/Rational parametrization of plane curves. Is this a bug?https://ask.sagemath.org/question/50815/rational-parametrization-of-plane-curves-is-this-a-bug/ I am trying to compute the rational parametrization of a plane curve. According to sage is irreducible and has genus 0, hence it should be possible.
B.<u,v> = AffineSpace(QQ,2)
p=Curve([2*u^2 + 2*u*v + 2*v^2 - 1],B)
p.rational_parameterization()
However, i get the following error
Singular crashed -- automatically restarting.
---------------------------------------------------------------------------
SingularError Traceback (most recent call last)
<ipython-input-10-db30bbca0c11> in <module>()
1 B = AffineSpace(QQ,Integer(2), names=('u', 'v',)); (u, v,) = B. _first_ngens(2)
2 p=Curve([Integer(2)*u**Integer(2) + Integer(2)*u*v + Integer(2) *v**Integer(2) - Integer(1)],B)
----> 3 p.rational_parameterization()
/home/mlainz/.local/SageMath/local/lib/python3.7/site-packages/sage/schemes/ curves/affine_curve.py in rational_parameterization(self)
1451 ((-7*t^2 + 7)/((-a)*t^2 + (-a)), 14*t/((-a)*t^2 + (-a)))
1452 """
-> 1453 para = self.projective_closure(i=0).rational_parameterization(). defining_polynomials()
1454 # these polynomials are homogeneous in two indeterminants, so dehomogenize wrt one of the variables
1455 R = para[0].parent()
/home/mlainz/.local/SageMath/local/lib/python3.7/site-packages/sage/schemes/ curves/projective_curve.py in rational_parameterization(self)
1569 singular.lib("paraplanecurves.lib")
1570 R = singular.paraPlaneCurve(self.defining_polynomial())
-> 1571 singular.setring(R)
1572 param = singular('PARA').sage().gens()
1573 R = R.sage()
/home/mlainz/.local/SageMath/local/lib/python3.7/site-packages/sage/interfaces/ singular.py in set_ring(self, R)
1097 if not isinstance(R, SingularElement):
1098 raise TypeError("R must be a singular ring")
-> 1099 self.eval("setring %s; short=0"%R.name(), allow_semicolon=True)
1100
1101 setring = set_ring
/home/mlainz/.local/SageMath/local/lib/python3.7/site-packages/sage/interfaces/ singular.py in eval(self, x, allow_semicolon, strip, **kwds)
657 # Singular actually does use that string
658 if s.find("error occurred") != -1 or s.find("Segment fault") != -1:
--> 659 raise SingularError('Singular error:\n%s'%s)
660
661 if get_verbose() > 0:
SingularError: Singular error:
? sage19 is no name of a ring/qring
? error occurred in or before STDIN line 11: `setring sage19; short=0;`
Is this a SAGE or a Singular bug or am I missing something?MLainzFri, 17 Apr 2020 19:07:14 +0200https://ask.sagemath.org/question/50815/