ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 Jul 2020 07:20:06 -0500- can incidence algebras over ring that is not number ring?http://ask.sagemath.org/question/52452/can-incidence-algebras-over-ring-that-is-not-number-ring/I try the following codes, but it does not work.
SF= SymmetricFunctions(QQ)
s=SF.s()
I=P.incidence_algebra(SF)
s([2,1])*I[1,1]
TypeError: unsupported operand parent(s) for *: 'Symmetric Functions over Rational Field in the Schur basis' and 'Incidence algebra of Finite lattice containing 4 elements over Symmetric Functions over Rational Field'
XieMon, 13 Jul 2020 07:20:06 -0500http://ask.sagemath.org/question/52452/
- simplify_full() does not simplifyhttp://ask.sagemath.org/question/52451/simplify_full-does-not-simplify/ Hi
var('a,b,z')
assume(z,'complex')
assume(a,'real') ;assume(b,'real')
f(a,b,r)=(a^2 + b^2 - sqrt(a^2 + b^2 - r^2) * sqrt(a^2 + b^2) * sqrt((a^2 + b^2 - r^2) / (a^2 + b^2))) / (a - I*b)
show(f)
show(f.simplify_full())
[discussion in relation](https://ask.sagemath.org/question/52435/substitute-complex-number-form-in-a-function/)ortolljMon, 13 Jul 2020 07:08:17 -0500http://ask.sagemath.org/question/52451/
- ipynb notebook for Beezer's Linear Algebra supplementhttp://ask.sagemath.org/question/52446/ipynb-notebook-for-beezers-linear-algebra-supplement/I'm reading Beezer's Sagemath workbook that accompanies his Linear Algebra book. He says there is a Sagemath format
workbook that is more usable than the pdf. I've searched Everywhere including his page and every referenced page, but can't find it to download. Anyone know where it is? I don't know why he'd mention there is an ipynb notebook but make it impossible to find πcybervigilanteSun, 12 Jul 2020 17:45:30 -0500http://ask.sagemath.org/question/52446/
- I installed Sage 9.1 but my terminal says I have Sage 9.0 installed.http://ask.sagemath.org/question/52379/i-installed-sage-91-but-my-terminal-says-i-have-sage-90-installed/Hello all, I just recently installed Sage 9.1 from a tar folder. It initially said I successfully installed Sage 9.1. After I closed the terminal and launched sage, the new terminal says it is sage 9.0. I tried installing Sage 9.0 before, but it never complied since I did not have the FORTRAN. I am not sure if that is creating a conflict. I am using Linux Mint 19.3 as my OS. I am relatively new to sage, so I might be wrong about the installation. Thank you for the help.
<pre>~$ sage
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SageMath version 9.0, Release Date: 2020-01-01 β
β Using Python 3.7.3. Type "help()" for help. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
<font color="#0000FF">sage: </font>help()
Welcome to Sage 9.0!
</pre>powerengineerWed, 08 Jul 2020 12:42:56 -0500http://ask.sagemath.org/question/52379/
- Built-in tools for fast extraction of tuples of a given grade with respect to grading on [1, 2, ..., n]http://ask.sagemath.org/question/52440/built-in-tools-for-fast-extraction-of-tuples-of-a-given-grade-with-respect-to-grading-on-1-2-n/Hi,
Note that I have just posted [the same question on Stack Overflow](https://stackoverflow.com/q/62864317/2886628).
I am in the process of coding 2 mathematical combinatorial operations that I want to iterate (as) many times (as possible), so speed is obviously crucial.
Here is an example of what I want to do as fast and efficiently as possible for any positive integer n and any grading (see example below).
**Remark:** This is a self-motivated question coming from mathematical experimentations with Sage.
Many thanks in advance for your help.
**Example:**
Let us take n = 6, and the set S = {1, 2, ..., n} = {1, 2, 3, 4, 5, 6}.
There are binomial(6, 2) = 15 couples
```
[(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6), (4, 5), (4, 6), (5, 6)]
```
in increasing order that we can extract from S.
The built-in tool I was advised to use in order to obtain the above list is the following:
```
from itertools import combinations
n = 6
iterable = list(range(1, n+1))
r = 2
print(list(combinations(iterable, r)))from itertools
```
**Question 0:** Is there anything faster in Python?
Now let me choose a grading on the set S in the form of a function from S to {1, 2, 3}
grading: 1, 2, 3 --> 1 and 4, 5 --> 2 and 6 --> 3
I have decided to store this function as a dictionary as follows:
```
grading = {1: 1, 2:1, 3: 1, 4: 2, 5: 2, 6: 3}
```
With respect to this grading, we can compute the grade of elements, couples, or tuples constructed from S.
Examples:
- grade(2) = 1
- grade(5) = 2
- grade((2, 5)) = grade(2) + grade(5) = 1 + 2 = 3
- grade((2, 3, 5)) = 1 + 1 + 2 = 5
1 - First Construction:
I want all the couples with grade equal to g0 = 4.
Here is an obvious way to do it, which is built naively on the previous lines of code:
```
g0 = 4
gradedList = []
for couple in list(combinations(iterable, 2)):
grade = grading[couple[0]] + grading[couple[1]]
if grade == g0:
gradedList.append(couple)
print(gradedList)
```
This yields
```
[(1, 6), (2, 6), (3, 6), (4, 5)]
```
as desired.
**Question 1:** Is there a built-in way to obtain gradedList and/or what is the fastest way to do this with Python?
2 - Second Construction:
Now I want to extract all the increasing 3-tuples (i, j, k) with grade equal to 4, and which starts with i = 1.
In other terms, I want the following list:
```
[(1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5)]
```
Of course, this can be obtained as follows:
```
newIterable = list(range(2, n+1))
secondGradedList = []
for couple in list(combinations(newIterable, 2)):
grade = grading[1] + grading[couple[0]] + grading[couple[1]]
if grade == g0:
secondGradedList.append((1,) + couple)
print(secondGradedList)
```
**Question 2:** Is there a built-in way to obtain secondGradedList and/or what is the fastest way to do this with Python?
Thanks,
JulienBostonSun, 12 Jul 2020 12:37:33 -0500http://ask.sagemath.org/question/52440/
- substitute complex number form in a functionhttp://ask.sagemath.org/question/52435/substitute-complex-number-form-in-a-function/Hi
how can i do so that there is no more $x_0$ nor $y_0$ in f
but that $ f (z, \bar z)$ , with $ z=x_0+y_0*I$?
var('Z,z,x_0,y_0,r,rho,theta')
assume(Z,'complex') ;assume(z,'complex')
assume(x_0,'real') ;assume(y_0,'real')
Zr(x_0,y_0,r) = -sqrt(((r^2/(x_0^2 + y_0^2) - 1)*x_0 + r*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*y_0/sqrt(x_0^2 + y_0^2))^2 + (r*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*x_0/sqrt(x_0^2 + y_0^2) - (r^2/(x_0^2 + y_0^2) - 1)*y_0)^2)*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*x_0/sqrt(x_0^2 + y_0^2) + x_0
Zi(x_0,y_0,r)=-I*sqrt(((r^2/(x_0^2 + y_0^2) - 1)*x_0 + r*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*y_0/sqrt(x_0^2 + y_0^2))^2 + (r*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*x_0/sqrt(x_0^2 + y_0^2) - (r^2/(x_0^2 + y_0^2) - 1)*y_0)^2)*sqrt(-r^2/(x_0^2 + y_0^2) + 1)*y_0/sqrt(x_0^2 + y_0^2) + I*y_0
show("Zr",(Zr).simplify_full())
show("Zi",(Zi).simplify_full())
Zr0=(Zr).subs(x_0 + I*y_0==z,x_0^2+y_0^2==z*(z.conjugate()))
#show("Zr0",(Zr0).simplify_full())
Zi0=(Zi).subs(x_0 + I*y_0==z,x_0^2+y_0^2==z*(z.conjugate()))
#show("Zi0",(Zi0).simplify_full())
f=Zr0+Zi0
show("f : ",f.simplify_full())ortolljSun, 12 Jul 2020 03:21:08 -0500http://ask.sagemath.org/question/52435/
- Combination under constrained situation with a conditionhttp://ask.sagemath.org/question/52345/combination-under-constrained-situation-with-a-condition/Step 1: I want to take a number `n` as input from user
Step 2: We form the set `S` consisting of elements from `0` to `n*(2^{n-1})`
Step 3: Now I pick each possible two-element subsets of `S` and store it in `P`.
Step 4: Now I need to pick `n*(2^{n-1})` two-element subsets from `P`
such that each number that occurs in that set occurs exactly `n` times
neither less nor more and put them all in a list.
Example
n = 2
n*(2^{n-1}) = 2*(2^{2-1}) = 4
S = {0,1,2,3,4}
p = {(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}
Step 4 One element which satisfies condition of step 4; HERE `n = 2`.
`{(0,1),(1,2),(2,3),(0,3)}` which has `2*(2^{n-1}) = 2*(2^{2-1}) = 4` elements.
Now see in the above set
- `0` occurred `n=2` times only in `(0,1)` and `(0,3)` only
- `1` occurred `n=2` times only in `(0,1)` and `(1,2)` only
- `2` occurred `n=2` times only in `(1,2)` and `(2,3)` only
- `3` occurred `n=2` times only in `(2,3)` and `(0,3)` only
Similarly we may get for `{(0,1),(1,4),(4,2),(2,0)}` we can easily verify like above.
Now based on `n` the number of elements size etc will vary.
Kindly help if possible any one.sriramSun, 05 Jul 2020 13:36:40 -0500http://ask.sagemath.org/question/52345/
- exact computations with algebraic numbershttp://ask.sagemath.org/question/52362/exact-computations-with-algebraic-numbers/I'm trying to do exact computations with algebraic numbers. In particular, I know to expect integer answers like `1`, `0`, and `3` at the end of my computations, but I'm getting something slightly off.
I noticed that if I run
sage: r = sqrt(2)
sage: a = AA(r)
sage: b = AA(1/r)
sage: c = a*b
Then I get:
sage: c
1.000000000000000?
Is this being handled in the computer as exactly `1`? Otherwise, how can I do exact computations with algebraic numbers in Sage? I obtain the algebraic numbers I'm working with using `algdep()` to find a polynomial and `.roots(QQbar)` to find the roots of that polynomial.b897069Mon, 06 Jul 2020 14:18:17 -0500http://ask.sagemath.org/question/52362/
- how to render a latex string in a notebook cellhttp://ask.sagemath.org/question/52357/how-to-render-a-latex-string-in-a-notebook-cell/Say we have a string variable `s = "some context: $x = 3$"`. The string s is rather simple latex, but is not just an equation. I would like to display the typeset version of `s` in a notebook cell, without having to retype the string by hand in the cell. Thanks for any help.jbaxterMon, 06 Jul 2020 10:03:24 -0500http://ask.sagemath.org/question/52357/
- Make program act on itself by entering certain areas of code (as a string) which it must itself executehttp://ask.sagemath.org/question/52412/make-program-act-on-itself-by-entering-certain-areas-of-code-as-a-string-which-it-must-itself-execute/My program must act on itself by entering certain areas of code (in the form of a string) which it must itself execute.
Take the ring `K` of polynomials with four unknowns `x_00`, `x_10`, `x_01` and `x_11`.
K.<x_00, x_10, x_01, x_11> = QQ []
g = K.random_element()
for i in range(1):
for j in range(1):
2 + g.monomial_coefficient(x_ij)
The last command tries to add to 2 the coefficient of the monomial `x_ij`. This is where it blocks.PΓ©rez BroonFri, 10 Jul 2020 20:52:51 -0500http://ask.sagemath.org/question/52412/
- Edge isoperimetric numberhttp://ask.sagemath.org/question/52410/edge-isoperimetric-number/This is probably a very silly question. How does one get the edge isoperimetric number of a graph?
As seen under [here](https://trac.sagemath.org/ticket/21942) there should be an algorithm for it, but when I define a graph (say H), then
<code>
edge_isoperimetric_number(H)
</code>
returns "name 'edge_isoperimetric_number' is not defined"
and
<code>
H.edge_isoperimetric_number()
</code>
returns "'Graph' object has no attribute 'edge_isoperimetric_number'"
(while
<code>
edge_isoperimetric_number?
</code>
returns "Object `edge_isoperimetric_number` not found."
So how do I load said algorithm for use?ARGFri, 10 Jul 2020 15:04:04 -0500http://ask.sagemath.org/question/52410/
- Spline interpolation varies hugely when variables are rescalled in 3d-lists ?http://ask.sagemath.org/question/52429/spline-interpolation-varies-hugely-when-variables-are-rescalled-in-3d-lists/Dear all,
Here is a short script:
----------
(nbx, nby) = (74, 90)
def fx(x):
return (0.5 + x/2.5)
def fy(y):
return (40*y)
zetaPlot = list_plot3d([(30 * (fx(x/nbx)-1/2)+1/2 , fy(y/nby), 5 * abs(zeta(fx(x/nbx) + I*fy(y/nby))))
for x in range(-nbx, nbx+1) for y in range(-nby, nby+1)],
interpolation_type = 'spline')
zetaPlot.show()
----------
Now modify the z-coordinate: replace "5 * abs(zeta...)" by "abs(zeta...)"
The resulting graph is essentially flat. Can anyone tell me what is happening there?
Also, I would like to get rid of my scaling parameters 30 and 5 by using frame_aspect_ratio, to get cleaner code and a better annoted frame, but I don't seem to understand how to do it.
A great many thanks for anyone who would take the time to teach me that, it is some hours that I'm struggling with some docs and examples without having reached much --
Best, OlivierOlivier R.Sat, 11 Jul 2020 08:05:32 -0500http://ask.sagemath.org/question/52429/
- How to wrap a sympy function as a sage function ?http://ask.sagemath.org/question/52407/how-to-wrap-a-sympy-function-as-a-sage-function/ Inspired by a [recent question](https://ask.sagemath.org/question/52397/isympysympy-sagemath-integration/) :
`import`ing a function from sympy allows *apparently* to use a sympy function in sage:
sage: import sympy
sage: from sympy import sympify, sin as ssin
sage: ssin(sympify(a+b))
sin(a + b)
But this is purely cosmetic : this result does not have the methods of a Sage symbolic expression:
sage: ssin(sympify(a+b)).trig_expand()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-15-859c8e851702> in <module>()
----> 1 ssin(sympify(a+b)).trig_expand()
AttributeError: 'sin' object has no attribute 'trig_expand'
sage: ssin(sympify(a+b)).operator()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-d52ecf6bce28> in <module>()
----> 1 ssin(sympify(a+b)).operator()
AttributeError: 'sin' object has no attribute 'operator'
In fact, this is a sympy object :
sage: type(ssin(sympify(a+b)))
sin
whereas:
sage: type(sin(a+b))
<class 'sage.symbolic.expression.Expression'>
So, my question is :how toi create a Sage function that :
- translates all its argument to the relevant sympy types
- calls somehow the sympy functin on these arguments
- translates back the result to Sage ?
This is done for some Sage functions, implemented by Maxima or sympy, in the Sage library. Is it possible to make this "lightly" *at run time* in some Sage source code without having to recompile the Sage library ?
Emmanuel CharpentierFri, 10 Jul 2020 12:21:22 -0500http://ask.sagemath.org/question/52407/
- Why doesn't '==' or '!=' work for mixed forms?http://ask.sagemath.org/question/52409/why-doesnt-or-work-for-mixed-forms/ I have the following setup
M = Manifold((4), 'M', field='complex')
U = M.open_subset('U')
x = U.chart(names=tuple('x_%d' % i for i in range(4)))
eU = x.frame()
Form0 = M.mixed_form(comp=([0,0,0,0,0]))
Form1 = M.mixed_form(comp=([1,0,0,0,0]))
Clearly Form0 and Form1 are distinct mixed forms of M, but when I run
if Form0 != Form1:
print('Not Equal')
else:
print('Equal')
I get 'Equal' as the output, what's going wrong?sum8tionFri, 10 Jul 2020 14:02:22 -0500http://ask.sagemath.org/question/52409/
- Defining $S^1$ with four chartshttp://ask.sagemath.org/question/52400/defining-s1-with-four-charts/Hello,
I am trying to implement the construction of the manifold $S^1$ using the four charts, as described at en.wikipedia.org/wiki/Manifold#Circle . It's not clear to me how to define the charts in terms of the projection operators within SageMath. I'm also not sure how to isolate open sets that I would like to define the charts over. The circle is parameterized using polar coordinates, and the four charts have the form:
$
\begin{align*}
\varphi_1(r, \theta) &= \theta Β && \theta \in (-\frac{\pi}{3}, \frac{\pi}{3}) \\
\tag{1}
\end{align*}
$
$
\begin{align*}
\varphi_2(r, \theta) &= \theta Β && \theta \in (\frac{\pi}{6}, \frac{5\pi}{6}) \\
\tag{2}
\end{align*}
$
$
\begin{align*}
\varphi_3(r, \theta) &= \theta Β && \theta \in (\frac{2\pi}{3}, \frac{4\pi}{3}) \\
\tag{3}
\end{align*}
$
$
\begin{align*}
\varphi_4(r, \theta) &= \theta Β && \theta \in (\frac{7\pi}{6}, \frac{11\pi}{6}) \\
\tag{4}
\end{align*}
$
Once we have these charts, how would I define the four transition functions to complete the description?
Thank you for your help!wintermuteThu, 09 Jul 2020 23:13:31 -0500http://ask.sagemath.org/question/52400/
- isympy/sympy sagemath integration ?http://ask.sagemath.org/question/52397/isympysympy-sagemath-integration/ I'm trying to integrate
integrate((1/x**a)*(1/(1-x)),x)
With sympy; which succeeds in isympy.
But I need to separately import sympy
from sympy import *
x, a = symbols('x a')
integrate(1/(1-x)*1/(x^a),x)
Works, whereas simple
integrate(1/(1-x)*1/(x^a),x, algorithm="sympy")
fails when the import is missing. It also fails (differently) after the import :) only
integrate(1/(1-x)*1/(x^a),x)
works. I didn't see that mentioned.
No big problem, after I spent some time going down the subprocess error rabbit hole.
Is this a documentation error that should be reported?
rrogersThu, 09 Jul 2020 15:06:01 -0500http://ask.sagemath.org/question/52397/
- Memory problem: splitting large conjugacy class into partshttp://ask.sagemath.org/question/52398/memory-problem-splitting-large-conjugacy-class-into-parts/I'm trying to do a calculation on certain conjugacy classes in a large (Weyl) group, let's say:
W = WeylGroup(["E",8])
w = W.an_element()
for v in W.conjugacy_class(w):
if v.length() < 12:
if v.reduced_word()[0] == 1:
print v.reduced_word()
A typical conjugacy class of such W has a size in the millions. When I run this on my computer, then after about 100000 iterations it stops and prints
Error, reached the pre-set memory limit
(change it with the -o command line option)
(I'm not sure where to enter this -o command, but it wouldn't suffice anyway.)
I don't know exactly how these conjugacy classes are implemented (via GAP I think), but I was hoping that I could simply resume the calculation by using islice or e.g.
for v in W.conjugacy_class(w)[100000:200000]:
if v.length() < 12:
if v.reduced_word()[0] == 1:
print v.reduced_word()
However this doesn't seem to work - I'm guessing that it's first trying to create the entire list W.conjugacy_class(w)[100000:200000] (after crunching through the first 100000), in a less efficient way than before, taking up more memory than before.
Is there a way around this? Perhaps this can somehow be set up as a queue (in GAP!?) so that it takes up little memory?bksadieThu, 09 Jul 2020 15:34:03 -0500http://ask.sagemath.org/question/52398/
- Sage brokenhttp://ask.sagemath.org/question/52394/sage-broken/Since yesterday, I have the following problem : my notebooks cannot be connected to Sage. I have completely erased Sage and Python of my computer and then reinstalled them. So I work, under Windows 10, with the last version of both of it. For a short moment it seems to work but the the problem reappears. Has any body experimented such a weird comportment which may be due to windows ?
Here is an image of the error prompted by the notebook Server
![image description](/upfiles/1594304284310490.png)
I would add that, when I click on the icone Sagemath, a consol opens and closes ilmmediately and that Python is perfectly installed and works.CyrilleThu, 09 Jul 2020 09:13:58 -0500http://ask.sagemath.org/question/52394/
- I cannot seem to figure out what's wrong with the following Sage / Pari-GP codehttp://ask.sagemath.org/question/52390/i-cannot-seem-to-figure-out-whats-wrong-with-the-following-sage-pari-gp-code/ Basically, I would like to search for primes $p$, and positive integers $y, z$ satisfying
$$y < z$$
and
$$1 + p^y < 2p^{2y-z}.$$
for(p=1, 10000, for(y=1, 10000, for(z=1, 10000, if(isprime(p) && y<z && 1+p^y<2p^(2y-z),print(p," ",y," ",z)))))
When I try to compile the above code using [Sage Cell Server](https://sagecell.sagemath.org/), it gives me the following error:
*** syntax error, unexpected ')': ...int(p," ",y," ",z)))))
*** ^-
Help | Powered by SageMath
I did already check and verified that all the parentheses are in their proper places.
Please help!Jose Arnaldo Bebita-DrisThu, 09 Jul 2020 08:13:09 -0500http://ask.sagemath.org/question/52390/
- Jupyter notebook_extensionhttp://ask.sagemath.org/question/52387/jupyter-notebook_extension/I want to install jupyter `notebook_extension` to use it under Sage and Windows 10. But unfortunately at the end of the installation I have the error
`Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xnoo625h/lxml/`
Could some one help ? Secondly I have a similar (not identical) problem `hide_code`
`with ipython 5.8.0 has requirement prompt_toolkit<2.0.0,>=1.0.4, but you'll have prompt-toolkit 3.0.5 which is incompatible`. What is stranger in both case is that my installation Python + Sagemath uses the last distributions either Python or Sagemath.CyrilleThu, 09 Jul 2020 04:59:04 -0500http://ask.sagemath.org/question/52387/
- legendre_P(6,0) different evaluationshttp://ask.sagemath.org/question/52385/legendre_p60-different-evaluations/I tried to evaluate
legendre_P(6,0)
and
legendre_P(6,x).subs(x=0)
in the sagecell. The first one gives 5/16 but the second one gives -5/16.
Why are these two results different?MathMechThu, 09 Jul 2020 03:30:08 -0500http://ask.sagemath.org/question/52385/
- Assumption seems to break integrate(); is this a bug?http://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)
Asked also at Math.StackExchange (sorry, can't post links yet, but the question was essentially the same), but did not receive an answer there. Apologies if this kind of cross-posting is frowned upon.mathmandanWed, 08 Jul 2020 20:26:26 -0500http://ask.sagemath.org/question/52382/
- Problem on advanced plottinghttp://ask.sagemath.org/question/52380/problem-on-advanced-plotting/How can I resolvve this:
> Create a plot for the following problem. Find the area that is inside the circle r=2, but outside the cardioid 2+2cos(ΞΈ).
My code:
`var('a')`
`polar_plot([2,2+2*cos(a)],(a,0,2*pi))`
When I add the parameter fill=RealNumber, the area is filled, but I can't control what the area; what means this parameter?gabrielromao5Wed, 08 Jul 2020 14:16:04 -0500http://ask.sagemath.org/question/52380/
- How to change the unreadable dark blue colour in the SageMath command line window under Windows-10?http://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 05:59:10 -0500http://ask.sagemath.org/question/47136/
- How do I solve cos(2*t)==sin(t)http://ask.sagemath.org/question/52344/how-do-i-solve-cos2tsint/I tried solving
> solve(cos(2*t)==sin(t),t)
I got
> [cos(2*t) == sin(t)]
But this shouldn't be the value. I know from the graphs that the value is numeric.
I have also noticed that sagemath is not good for solving trig identities. Is this true?loloraSun, 05 Jul 2020 13:22:18 -0500http://ask.sagemath.org/question/52344/
- convert a string in float but not a list of string in list of floathttp://ask.sagemath.org/question/52367/convert-a-string-in-float-but-not-a-list-of-string-in-list-of-float/ This is a very weird behaviour.
Suppose I have a list such
A=['1.2', '2.565', '3.45']
If I I create the command `A[1]=float(A[1])` the result is
A=[1.2, '2.565', '3.45']
Now if I ask
for i in range(len(A)):
A[i]=float(A[i])
the result is `ValueError: could not convert string to float:`
Do I do something forbiden ?CyrilleTue, 07 Jul 2020 04:00:26 -0500http://ask.sagemath.org/question/52367/
- How to define an integral to not be evaluatedhttp://ask.sagemath.org/question/52359/how-to-define-an-integral-to-not-be-evaluated/I'm trying to write the following script:
var('alpha beta x')
num = x**(alpha-1) * (1-x)**(beta-1)
denom = integral(x**(alpha-1) * (1-x)**(beta-1), x)
gammadist = num / denom
diff(gammadist, x)
So it is mich easier if the integral on `denom` does not get evaluated. However, I cannot find a way to do that on Sage and Sage always tries to evaluate it (without success). Is there a way to tell Sage to keep it as an integral?
ThankstomchoMon, 06 Jul 2020 12:22:40 -0500http://ask.sagemath.org/question/52359/
- How do I install the plantri package ? Is there a guide how to do this ?http://ask.sagemath.org/question/52358/how-do-i-install-the-plantri-package-is-there-a-guide-how-to-do-this/This is a copy of the message that I get when I use the command "sage -i plantri"
sage: sage -i plantri
File "<ipython-input-2-8b0f8d4e79c0>", line 1
sage -i plantri
^
SyntaxError: invalid syntax
Simon888Mon, 06 Jul 2020 10:52:29 -0500http://ask.sagemath.org/question/52358/
- Metric of EuclideanSpace(3) in spherical framehttp://ask.sagemath.org/question/52348/metric-of-euclideanspace3-in-spherical-frame/ I may have some conceptual misunderstandings, but here is the code
E=EuclideanSpace(3)
c_spher.<r,th,ph>=E.spherical_coordinates()
f_spher=E.spherical_frame()
E.set_default_chart(c_spher)
E.set_default_frame(f_spher)
g=E.metric()
show(g[:])
I was expecting the diagonal elements of the metric to be `[1,r^2,r^4*sin(th)^2]`, but I get `[1,1,1]`
What I am doing wrong?curios_mindSun, 05 Jul 2020 15:47:56 -0500http://ask.sagemath.org/question/52348/
- Masking a markdown cellhttp://ask.sagemath.org/question/52341/masking-a-markdown-cell/ I there a way to mask a markdown cell --- it's a technical one, mainly html stuff --- to change some parameters of the notebook without any interest for the reader ? But it should be computed at the opening ofCyrilleSun, 05 Jul 2020 10:32:38 -0500http://ask.sagemath.org/question/52341/