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, 23 Nov 2021 15:27:58 +0100complex numbers and paramétric numbershttps://ask.sagemath.org/question/59914/complex-numbers-and-parametric-numbers/ hi
this program works well for me, i want the critical points but only if real
but my condition if(x.imag()!=0) doesnt work properly if x is a "r_something"
and, of cours, a solution like (x,y)=(r12,r37) interests me, i want it to be displayed
but as maybe Sagemath consider r12 and r37 aspossibly being complex, is does not display it
how can i test if a number is a parametric number ?
f(x,y)=(x+y)^2
# calculs généraux
from sage.manifolds.operators import *
E.<x,y> = EuclideanSpace()
F = E.scalar_field(f)
H=f(x,y).hessian()
show(html("<h5>paramètres généraux</h5>"))
T=table([["f",f],["grad f=",grad(F)[:]],["H=",H]],frame=True,align='center')
show(T)
# calcul des points critiques
Cr= solve([grad(f)[0]==0,grad(f)[1]==0],[x,y],solution_dict=True)
#liste=[["x","y","H"]]
liste=[]
for critique in Cr:
show("tttt",critique)
if(x(critique).imag()==0 and y(critique).imag()==0):
liste.append(["(","x=",x(critique),";","y=",y(critique),")",H(critique)])
show(html("<h5>points critiques</h5>"))
if (len(liste)!=0):
show(table(liste))
else :
show("pas de points critiques")ErWinzTue, 23 Nov 2021 15:27:58 +0100https://ask.sagemath.org/question/59914/Testing the codehttps://ask.sagemath.org/question/56214/testing-the-code/I was told that one can use `sage -t namefile.py` to test some code.
When I used the code, I got the following thing that is not what I want
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
File "/usr/share/sagemath/bin/sage-runtests", line 178, in <module>
DC = DocTestController(options, args)
File "/usr/lib/python3/dist-packages/sage/doctest/control.py", line 358, in __init__
for pkg in list_packages('optional', local=True).values():
File "/usr/lib/python3/dist-packages/sage/misc/package.py", line 236, in list_packages
for p in os.listdir(SAGE_PKGS):
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/sagemath/build/pkgs'Blue skyWed, 17 Mar 2021 19:23:57 +0100https://ask.sagemath.org/question/56214/How I can test this equality with sage?https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/How I can test this equality?
$$\sum_{n=0}^\infty\frac{(-1)^{n+1}}{3 n+6 (-1)^n}=\frac{\log(2)-1}{3}$$
Im interested in symbolic tests and numerical tests. My knowledge about the way to do this with sage (in general in any CAS, not only sage) is near to zero. Any help, link, etc. will be appreciated, thank you.
---------------------------
**EDIT:** I tried to use this code (what is a slight simplification of the above equality)
var("n")
sum(1/(n*(-1)^n+2),n,0,oo) == -log(2)+1
but, as expected, it dont work.MasacrosoSun, 30 Oct 2016 19:26:31 +0100https://ask.sagemath.org/question/35305/Testing if a result n is an Integer, for large n.https://ask.sagemath.org/question/34406/testing-if-a-result-n-is-an-integer-for-large-n/ I have a number x of size 2^160, and I perform the operation n = x*(x+1.5) and want to test if the result is an integer.
In python I would normally try, n.is_integer() or use an isinstance(), but this doesn't work in sage, I assume due to the fact sage integers are set up quite differently.
Upon scouring this site, I found someone recommend n is in ZZ, but this doesn't work (sage seems to loose accuracy at this level)
Example:
n = 2^160
n in ZZ
Result: False
The only (terribly inefficient) way I can get this to work is to call n.divisors() and if I get the error
"AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'divisors' "
I know it was indeed not an integer.
There must be a better way?
jbeatzWed, 10 Aug 2016 14:03:46 +0200https://ask.sagemath.org/question/34406/Account is read only. You may download or delete worksheets or data.https://ask.sagemath.org/question/10479/account-is-read-only-you-may-download-or-delete-worksheets-or-data/Hi, everyone. I have a problem with Sage Test where my accounts keep turning read-only seemingly at random while I am working.
I get the message **'Account is read only. You may download or delete worksheets or data.'** appearing at the top of each page, and then I can't run any computations and have to get a new account.
Is there any way I can stop this happening?
EDIT: I am using test.sagenb.org and logging in with a Google account on a low-end machine running Windows 7/Chrome browser and sometimes Linux Mint/Firefox, but can only remember the problem occurring in Windows.eilsWed, 28 Aug 2013 08:03:25 +0200https://ask.sagemath.org/question/10479/Submitting a module to Sage trac with supporting test code and documentationhttps://ask.sagemath.org/question/9097/submitting-a-module-to-sage-trac-with-supporting-test-code-and-documentation/Hi all:
I recently wrote
1. a new Python module for Sage
2. a Python module that tests (1) using the unittest module
3. a PDF document describing the mathematical background for the algorithms in (1)
I want to submit all three of these to the Sage trac server for reviewers to refer to. Is that a good idea? If so, what's the best way to do that? I know how to submit (1) as a patch, but what about (2) and (3)?
Thanks.araichevWed, 20 Jun 2012 01:38:05 +0200https://ask.sagemath.org/question/9097/check if symbolic expression contains a variablehttps://ask.sagemath.org/question/8951/check-if-symbolic-expression-contains-a-variable/check if symbolic expression contains a given variable
Is there a function or method that tests a symbolic expression
<type 'sage.symbolic.expression.Expression'>
to see if it contains a particular variable?
For example to test
y(x) == -3/(x^3 + 3*c + 3*x)
to see if it contains the variable c.
(I'm trying to write a a program to automatically plot the return value of the differential equation function desolve(), and it would help to be able to detect if the return expression contains the 'arbitrary constant' c.)
leonardoFri, 04 May 2012 14:38:37 +0200https://ask.sagemath.org/question/8951/What is the best choice of test unit library for SAGEhttps://ask.sagemath.org/question/8412/what-is-the-best-choice-of-test-unit-library-for-sage/Now I'm using
import unittest
But I'm not sure that it is the best choice in SAGE context.
Something like this
import unittest
class Test(unittest.TestCase):
def test_CheckLocalTestForI123(self):
group = gap.GenerateG(2,5,3)
generators = gap.GeneratorsOfGroup(group);
subgroups = map(lambda gen: gap.Group(gen), generators);
subgroups.reverse()
self.assertNotEqual(CheckLocalTestForI123(group, subgroups, 1621, 1947, 1521), -1)
What are you using and why?petRUShkaMon, 24 Oct 2011 10:17:51 +0200https://ask.sagemath.org/question/8412/How to test all but a couple fileshttps://ask.sagemath.org/question/8000/how-to-test-all-but-a-couple-files/It's fun and easy to test the Sage library by directory.
./sage -t devel/sage/sage/module_1/
The same is true if you only need to test a couple files.
./sage -t devel/sage/sage/module_1/foo.py devel/sage/sage/module_1/bar.py
But it's not so fun and easy to test all but a couple files in a module. Here, I test all but the last file in a module. Imagine $n>4$, and the names not being so easy to write down.
./sage -t devel/sage/sage/module_1/file_1.py devel/sage/sage/module_1/file_2.py <snip> devel/sage/sage/module_1/file_n-1.py
What I want to know is whether there is an easy way to do the above, along the lines of
./sage -t devel/sage/sage/module_1/ -not devel/sage/sage/module_1/file_n.py
Probably one can write some script asking not to test that, or whatever, but that is too much work, because I'd constantly be writing scripts. Is there any way to massage the arguments to `./sage -t` to do this easily?kcrismanTue, 15 Mar 2011 10:10:03 +0100https://ask.sagemath.org/question/8000/