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.Sat, 21 Apr 2018 22:50:45 -0500Sagecell with code hosted in GitHubhttp://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/I would like to embed a Sage Cell in a webpage whose content comes from a GitHub `.py` file, so that changes in this file are immediately shown in the webpage. I have tried to use `javascript` / `jquery` like this (with the standard scripts in the head) and with some variations:
<div class="sage"><script type="text/x-sage" id="sage1"></script></div>
<script>$('#sage1').load("https://rawgit.com/path_to_the_file.py");</script>
and it sometimes work, but not always. I guess it has to do with the order of all the scripts involved in the process. Which would be the most appropiate and clean way to inject such code in a Sage Cell?
**EDIT:** I would like to show the input cell together with the input code, for educational purposes. So the content of the input cell has to be replaced with the content of the `.py` file.jepstraSat, 21 Apr 2018 10:51:40 -0500http://ask.sagemath.org/question/42115/sagemath-8.1 windowshttp://ask.sagemath.org/question/42120/sagemath-81-windows/ In sagemath-8.1 windows native installation . Help files are poorly formatted, particularly in the Reference Documentation. They appear to not be accessing a .css file.
Do I have a faulty installation file, and if so how can I get a copy a non-faulty one?NormekSat, 21 Apr 2018 22:50:45 -0500http://ask.sagemath.org/question/42120/Solve a differential equation using series expansions.http://ask.sagemath.org/question/42110/solve-a-differential-equation-using-series-expansions/Given an ODE such as $$y''+x^2y'+y=0$$ Is it possible to get sage to display the solution in the from (at least the first few terms of the expansion) $$y=a_o\left(c_0+c_1x+c_2x^2+\dots\right) + a_1\left(d_0+d_1x+d_2x^2+\dots\right) $$
[my attempts:](https://sagecell.sagemath.org/?z=eJxtzc2OwiAUhuG9iffwxS4EJcQ242rCFczW3UQNthCIHUgAK9z90C7mJ3FxNm-ec84kA9lkVlhiH9euTruh7-tVgYB-uD5Z78i2bCnJcx5U7YPVmhSWWUexR750u5_S0n0R4lBl84Ie_8G33ULRRKW-ImxCLx2iHyeFZGyEd4pzrFfR-CcZ1PzfzDfVYmphKAx2kqHWzNB7l4K9Xf2gxCk8loXGiM87DyYSypMsow-kypbhSKF9wB3WwZzRaGnHyH__mT_8MHP6DYNqVi0=&lang=sage)
EDIT:
I have made some progress, functional but it is not pretty.
[second attempt](https://sagecell.sagemath.org/?z=eJx1U9FumzAUfa_Uf7gqD7UTj2G6SlM6P-5pfpiUvUSIVU4ww8KxESYpaOq_z0BI6ZLKwrq6nHOur8_1UdToriUdaciP59h_lIiICHqHn25vOmCQH8yuUdag--4eo7ZPZ9LnM5XnqCMtiTEsIVq0v-PFOUfxsmMs8lhX2BeUyZ7GWTJIpz6Wlf8Lwfe2EiYDsbWHBn5aZRrwlDnQ8VBUlTQZclYfpZcis8o4idKwLhzCfYGSPfj9pVBaQvnt6-r2Bt7oA8vx5BNNhwP2BChZuaTTKR3HkwZnjo8n3ofusHXo76y1laAE2pWsCHSoZbLymYjADDFlKbxiyG0Ne1AGePqBZDwReBKnFwzNHqam9NjUNQ39pqEvNUAzPTS6ZglPyvRzLnaNrZXQqByxZY-thfkjkZYGcYzTJ_BmbFiy9gRvb_khzqMoQ-6wRxt8OpegK38lIlrRV-xzal9plXfIX_AmvoTSARr9Dx1c4VOwnoLNOaDnKPZRvwLvcJSyYT_pT05FvU2v-Crmvbsj6DwS0wquzP3ju5n_shimHgIn5d6BamAnDAyDC02hHFgjwxAm9fFZBKc2-7DoC8jzpENHQB1F7bMtgZ01Ta22zzaT7Fd9GMkFS8rxBYSN6LStkUf6-3yc2VqkEORCaRfOihczfNTj8T-h4CgD&lang=sage)userXFri, 20 Apr 2018 23:36:53 -0500http://ask.sagemath.org/question/42110/Pairs of graphs with same spectral radius but with different diameter and different number of edgeshttp://ask.sagemath.org/question/41990/pairs-of-graphs-with-same-spectral-radius-but-with-different-diameter-and-different-number-of-edges/ I know that graphs.cospectral_graphs() gives all pairs of graphs with same eigenvalues. But I need graphs with same spectral radius i.e. largest eigenvalue (the other eigenvalues may be different) and differing in diameter and number of edges.
What to do for this? Thank you in advance.Deepak SarmaThu, 12 Apr 2018 00:47:21 -0500http://ask.sagemath.org/question/41990/Sage updates on ppa?http://ask.sagemath.org/question/42111/sage-updates-on-ppa/ Hi,
I have been using sage on my ubuntu for at least 3 years now. Up to february of last year, I have been keeping it up to date thanks to the ppa: https://launchpad.net/~aims/+archive/ubuntu/sagemath
But it is now sage 8.0+, and the ppa is still at version 7.5. I really wonder why it is not kept updated anymore.
I tried to use some prebuilt binaries proposed for downloading on sagemath.org, however these solutions do not seem to be as simple and integrated to the system as the classic way to install sage.
Thanks for answers.Romuald_314Sat, 21 Apr 2018 07:45:26 -0500http://ask.sagemath.org/question/42111/What causes sage to crash as it starts?http://ask.sagemath.org/question/42109/what-causes-sage-to-crash-as-it-starts/ Installed sage 7.6 on Ubuntu 16.04 LTS to work with a colleague who is also on 7.X release (they are on Fedora). It all seemed to go OK but consistently get a crash message as soon as it starts. A crash report text file is created - can supply that for someone to look at.
Here is the terminal output:
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.6, Release Date: 2017-03-25 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
**********************************************************************
Oops, Sage crashed. We do our best to make it stable, but...
A crash report was automatically generated with the following information:
- A verbatim copy of the crash traceback.
- A copy of your input history during this session.
- Data on your current Sage configuration.
It was left in the file named:
'/home/davelautzenheiser/.sage/ipython-5.0.0/Sage_crash_report.txt'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.
You can mail it to: sage-support at sage-support@googlegroups.com
with the subject 'Sage Crash Report'.
If you want to do it now, the following command will work (under Unix):
mail -s 'Sage Crash Report' sage-support@googlegroups.com < /home/davelautzenheiser/.sage/ipython-5.0.0/Sage_crash_report.txt
BCWDaveFri, 20 Apr 2018 22:54:09 -0500http://ask.sagemath.org/question/42109/Display a graphics object with multiple primativeshttp://ask.sagemath.org/question/42106/display-a-graphics-object-with-multiple-primatives/ I'm trying to show how a set of lines changes with a matrix transformation. The part i am having trouble with is:
g=Graphics()
for c in range(10):
g.add_primitive(parametric_plot(B*vector([x,c]) , (x, 0, 2*pi)))
show(g)
Because it doesn't plott the lines like i wanted but instead gives me
> 'Graphics' object has no attribute 'options'ionsmeFri, 20 Apr 2018 15:02:29 -0500http://ask.sagemath.org/question/42106/Basic work on tensor componentshttp://ask.sagemath.org/question/42107/basic-work-on-tensor-components/My SageManifolds notebooks typically start with a bunch of home made function designed to access components of tensors. But they are based on a common hacky function relying on very shallow understanding of the internals of SageManifolds. Am I missing some builtin equivalent? What is the proper way of doing this?
def maps(fun, tensor):
""" Applies fun to all components of a copy of tensor """
res = tensor.copy()
if tensor.tensor_type() == (0, 0):
for k, v in res._express.items():
res._express[k] = k.function(fun(v.expr()))
else:
for k, v in res.comp()._comp.items():
res.comp()._comp[k] = res.domain().scalar_field(fun(v.expr()))
return res
def simp(tensor):
return maps(lambda f: simplify(f), tensor)
def dev(tensor):
return maps(lambda f: expand(f), tensor)
def factorize(tensor):
return maps(lambda f: factor(f), tensor)
def subs(tensor, d):
return maps(lambda f: f.subs(d), tensor)
```PatrickFri, 20 Apr 2018 15:26:41 -0500http://ask.sagemath.org/question/42107/Variable 't' not foundhttp://ask.sagemath.org/question/42098/variable-t-not-found/ Hi there,
I was trying to simply plot some fonctions defined as integrals like this one:
var('t')
plot( integrate(cos(x*t),t,0,sin(a)), x, 0, 10)
# a is an angle such that 0 < a < pi/2 defined beforehand
to do some brief visual checks on what I'm working on. That one works perfectly.
Then, just adding a "/sqrt(1-t^2)" :
var('t')
plot( integrate(cos(x*t)/sqrt(1-t^2),t,0,sin(a)), x, 0, 10)
ruins everything: gives me the error message : "... ValueError: Variable 't' not found"
And in fact I also tried with "/(1-t^2)" instead or even "/(1-t)", same result.
I'm very surprised, and I can't understand that. Thanks for any help.
----------
Here is the full report:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_91.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCd0JykKcGxvdCggaW50ZWdyYXRlKGNvcyh4KnQpL3QsdCwwLHNpbihhKSksIHgsIDAsIDEwKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpW3H_J9/___code___.py", line 4, in <module>
exec compile(u'plot( integrate(cos(x*t)/t,t,_sage_const_0 ,sin(a)), x, _sage_const_0 , _sage_const_10 )
File "", line 1, in <module>
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 554, in wrapper
return func(*args, **options)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1931, in plot
G = funcs.plot(*args, **original_opts)
File "sage/symbolic/expression.pyx", line 11383, in sage.symbolic.expression.Expression.plot (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:63333)
File "sage/symbolic/expression.pyx", line 11424, in sage.symbolic.expression.Expression._plot_fast_callable (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:63626)
File "sage/ext/fast_callable.pyx", line 456, in sage.ext.fast_callable.fast_callable (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:4485)
File "sage/symbolic/expression.pyx", line 11261, in sage.symbolic.expression.Expression._fast_callable_ (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:62248)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1579, in fast_callable
return FastCallableConverter(ex, etb)()
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 226, in __call__
return self.composition(ex, operator)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1545, in composition
return self.etb.call(function, *ex.operands())
File "sage/ext/fast_callable.pyx", line 734, in sage.ext.fast_callable.ExpressionTreeBuilder.call (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:6980)
File "sage/ext/fast_callable.pyx", line 609, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:5984)
File "sage/symbolic/expression.pyx", line 11261, in sage.symbolic.expression.Expression._fast_callable_ (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:62248)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1579, in fast_callable
return FastCallableConverter(ex, etb)()
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(div, div.operator())
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1507, in arithmetic
return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1507, in <lambda>
return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
File "sage/ext/fast_callable.pyx", line 734, in sage.ext.fast_callable.ExpressionTreeBuilder.call (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:6980)
File "sage/ext/fast_callable.pyx", line 609, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:5984)
File "sage/symbolic/expression.pyx", line 11261, in sage.symbolic.expression.Expression._fast_callable_ (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:62248)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1579, in fast_callable
return FastCallableConverter(ex, etb)()
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 226, in __call__
return self.composition(ex, operator)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1545, in composition
return self.etb.call(function, *ex.operands())
File "sage/ext/fast_callable.pyx", line 734, in sage.ext.fast_callable.ExpressionTreeBuilder.call (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:6980)
File "sage/ext/fast_callable.pyx", line 609, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:5984)
File "sage/symbolic/expression.pyx", line 11261, in sage.symbolic.expression.Expression._fast_callable_ (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:62248)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1579, in fast_callable
return FastCallableConverter(ex, etb)()
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(div, div.operator())
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1507, in arithmetic
return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1507, in <lambda>
return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
File "sage/ext/fast_callable.pyx", line 734, in sage.ext.fast_callable.ExpressionTreeBuilder.call (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:6980)
File "sage/ext/fast_callable.pyx", line 609, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:5984)
File "sage/symbolic/expression.pyx", line 11261, in sage.symbolic.expression.Expression._fast_callable_ (/usr/lib/sagemath//src/build/cythonized/sage/symbolic/expression.cpp:62248)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1579, in fast_callable
return FastCallableConverter(ex, etb)()
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 212, in __call__
return self.symbol(ex)
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1528, in symbol
return self.etb.var(SR(ex))
File "sage/ext/fast_callable.pyx", line 681, in sage.ext.fast_callable.ExpressionTreeBuilder.var (/usr/lib/sagemath//src/build/cythonized/sage/ext/fast_callable.c:6561)
ValueError: Variable 't' not foundRomuald_314Thu, 19 Apr 2018 16:06:04 -0500http://ask.sagemath.org/question/42098/How does list_plot3d interpret nxn matrices?http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/ From the [documentation](http://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/list_plot3d.html) of `list_plot3d`
>INPUT:
>v - something that defines a set of points in 3 space, for example:
> - a matrix
> - a list of 3-tuples
> - a list of lists (all of the same length) - this is treated the same as a matrix.
Intuitively I would guess that the function would only accept $3 \times n$ matrices and/or their transposes, but the first example on the document page is a plot of a five by five matrix
n = 5
m = matrix(RDF, n, [(i+j)%n for i in [1..n] for j in [1..n]])
p = list_plot3d(m)
p
**Question**: How does `list_plot3d` interpret this $5 \times 5$ matrix as a set of points in 3-space?
One might suspect that `list_plot3d` handles matrices the same was as, for example, `point3d` but this is not the case. For example, the points visualized by `point3d` do not lie on the surface given by `list_plot3d` in the above example as witnessed by
p + point3d(m, size=33)
amdallWed, 18 Apr 2018 13:34:16 -0500http://ask.sagemath.org/question/42091/I want convert laplace function into partial fractions like k1/(s+s1) + k2/(s+s2)http://ask.sagemath.org/question/42063/i-want-convert-laplace-function-into-partial-fractions-like-k1ss1-k2ss2/ I have a expression in 's' domain: I(s)= Ip.(s-A)/(s^2+Bs+C)
I want to convert to partial fractions like: I(s)= k1/(s-s1) + k2/(s-s2)
and finally use in time domain as: i(t)=k1.exp(s1.t-t0) + k2.exp(s2t-t0)
thank you for your attentionMSalvinoTue, 17 Apr 2018 10:17:39 -0500http://ask.sagemath.org/question/42063/Support for arbitrarily large numbers?http://ask.sagemath.org/question/42070/support-for-arbitrarily-large-numbers/ Hi, I'm trying to compute the Juggler Sequence for relatively large numbers. Standard python doesn't calculate these correctly; I've discovered that Mathematica does, but I'm more familiar with Python and someone suggested I try out Sage.
I've tried this a couple ways using SageCell, and haven't yet succeeded. Here's the simplest possible implementation:
def juggle(n):
if n % 2:
return floor(sqrt(n)**3)
return floor(sqrt(n))
When I run this on 37, it works perfectly:
x = 37
print x,
while x > 1:
x = juggle(x)
print u"\u2192 {}".format(x),
produces
37 → 225 → 3375 → 196069 → 86818724 → 9317 → 899319 → 852846071 → 24906114455136 → 4990602 → 2233 → 105519 → 34276462 → 5854 → 76 → 8 → 2 → 1
which standard python fails (it finds 3374 instead of 3375). However, if I try a hard one, say, x = 48443, it times out after a few iterations:
48443 → 10662193 → 34815273349 → 6496130099313865 → 523578821252958052233532 → 723587466207 → 615512041010804067 → 482897358660562651148793788 → 21974925680433 → 103012783516625098121 → 1045530445028727953685811220915
I can improve this by using logarithms:
def juggle(n):
if n % 2:
return floor(exp(1.5*log(n)))
return floor(sqrt(n))
This implementation is much faster and gets much farther; however, it ends with an error:
TypeError: ECL says: #<a FLOATING-POINT-OVERFLOW>
I'd like to attach the full output as a text file, because it involves some very large numbers, but I don't have the karma yet. The number which causes the code to crash is about 3300 characters long. Here's the traceback, at least:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-a9218cbdcf1b> in <module>()
8
9 while x > Integer(1):
---> 10 x = juggle(x)
11 print u"\u2192 {}".format(x),
<ipython-input-1-a9218cbdcf1b> in juggle(n)
1 def juggle(n):
2 if n % Integer(2):
----> 3 return floor(exp(RealNumber('1.5')*log(n)))
4 return floor(sqrt(n))
5
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/functions/other.pyc in __call__(self, x, **kwds)
412
413 try:
--> 414 return floor(SR(x).full_simplify().canonicalize_radical())
415 except ValueError:
416 pass
/home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.simplify_full (build/cythonized/sage/symbolic/expression.cpp:53709)()
9698 x = self
9699 x = x.simplify_factorial()
-> 9700 x = x.simplify_rectform()
9701 x = x.simplify_trig()
9702 x = x.simplify_rational()
/home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.simplify_rectform (build/cythonized/sage/symbolic/expression.cpp:55646)()
9846
9847 """
-> 9848 simplified_expr = self.rectform()
9849
9850 if complexity_measure is None:
/home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.rectform (build/cythonized/sage/symbolic/expression.cpp:53186)()
9530
9531 """
-> 9532 return self.maxima_methods().rectform()
9533
9534 def unhold(self, exclude=None):
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/symbolic/maxima_wrapper.pyc in __call__(self, *args, **kwds)
30 """
31 return super(MaximaFunctionElementWrapper, self).__call__(*args,
---> 32 **kwds).sage()
33
34 class MaximaWrapper(SageObject):
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, *args, **kwds)
655
656 def __call__(self, *args, **kwds):
--> 657 return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
658
659 def help(self):
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in function_call(self, function, args, kwds)
576 [s.name() for s in args],
577 ['%s=%s'%(key,value.name()) for key, value in kwds.items()])
--> 578 return self.new(s)
579
580 def _function_call_string(self, function, args, kwds):
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in new(self, code)
345
346 def new(self, code):
--> 347 return self(code)
348
349 ###################################################################
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
280
281 if isinstance(x, string_types):
--> 282 return cls(self, x, name=name)
283 try:
284 return self._coerce_from_special_method(x)
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __init__(self, parent, value, is_name, name)
695 self._name = parent._create(value, name=name)
696 except (TypeError, RuntimeError, ValueError) as x:
--> 697 raise TypeError(x)
698
699 def _latex_(self):
TypeError: ECL says: #<a FLOATING-POINT-OVERFLOW>
Does anyone have any suggestions for me? Thanks in advance!gkanarekTue, 17 Apr 2018 10:36:02 -0500http://ask.sagemath.org/question/42070/How to put Sage in Env Path in Windowshttp://ask.sagemath.org/question/42035/how-to-put-sage-in-env-path-in-windows/I have installed Sage in windows 10 but for some reasons it's not in path. Running sage in cmd outputs: `'sage' is not recognized as an internal or external command, operable program or batch file.`.
I can't find sage.exe either to manually put it in path. What can I do?
The reason I need to have the path to sage.exe is because I want to use sagetex and it needs sage to be in path.
Currently, I' only able to produce .sout from sage by running sage manually and loading in the file manually. The sage that I'm loading has this full path:
`"C:\Program Files\SageMath 8.1\runtime\bin\mintty.exe" -t 'SageMath 8.1 Console' -i sagemath.ico /bin/bash --login -c '/opt/sagemath-8.1/sage'`
So I am not able to find sage.exe anywhere to automate this process possibly with latexmkrc.o6pSun, 15 Apr 2018 19:15:08 -0500http://ask.sagemath.org/question/42035/Subset functionhttp://ask.sagemath.org/question/42033/subset-function/I am new to Sage and trying to define a recursive function that returns the subsets for a given set. I get some sort of memory error for even the smallest sets and I don't know why:
def MySubsets(L):
if L == []:
return [[]]
TheSubsets = MySubsets(L[1:len(L)])
for subset in TheSubsets:
newSubset = copy(subset)
newSubset.append(L[0])
TheSubsets.append(newSubset)
return TheSubsets
...and while MySubsets([]) works, MySubsets([1]) already yields a memory error.amadeo_Sun, 15 Apr 2018 18:46:21 -0500http://ask.sagemath.org/question/42033/Sage needs updated GUI capabilities and fresh exampleshttp://ask.sagemath.org/question/42047/sage-needs-updated-gui-capabilities-and-fresh-examples/ A while back I was offered https://wiki.sagemath.org/interact/ for some examples of user interfaces. Specifically I was interested in the "Web application" section, as that is most attuned to what I am trying to do. I have two issues with this page.
1. Most (if not all) of the web application examples are broken (or easily broken) when one tries to run them on their own machine or just within the web browser. It makes it difficult to learn by example and/or use the examples to build upon.
2. The examples are outdated. If there is more capability and/or beauty than what is shown (and I hope there is) it should be offered as an example there. With robust GUI capabilities in R, Python, Java, etc., one would really hope that Sage, with all of its great mathematical capabilities, could offer some GUI options that are more modern.
Just to offer a couple examples of what I'm talking about, GUI's made with wxPython in Python, or Shiny in R, are much more attractive than what is shown of the Sage examples. ajmullinsMon, 16 Apr 2018 08:51:22 -0500http://ask.sagemath.org/question/42047/Correct input for list_plot3d(..., interpolation='spline')http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/I'm trying to construct smooth surfaces from lists of points in 3-space using `list_plot3d` and the `spline` option, but without success. For example, the input
> list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)], interpolation_type='spline')
returns the error
>TypeError: m >= (kx+1)(ky+1) must hold
The following returns the expected piecewise linear surface suggesting that there is a special restriction on the input when using the `spline` option.
> list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)])
**Question**: What is the correct input to obtain a best fit polynomial surface going through the six points in $\mathbb{R}^3$?
**Edit**: As pointed out by @slelievre, since these six points lie in a common plane, the corresponding surface should be the plane containing the points. So why does `Sage` throw an error instead of this plane?amdallSun, 15 Apr 2018 13:05:24 -0500http://ask.sagemath.org/question/42020/Element to sequence in field extensionhttp://ask.sagemath.org/question/42039/element-to-sequence-in-field-extension/I have constructed a big prime field:
p = 68235916425158872634653027
F = GF(p)
And then I make two extension fields
E1 = GF(p^2)
E2 = GF(p^6)
It is obvious that `E2` is a field extension of `E1`.
Now how can I express the element in `E2` with the basis in `E1`.FanxuejunMon, 16 Apr 2018 02:02:26 -0500http://ask.sagemath.org/question/42039/Square root of polynomial modulo another irreducible polynomialhttp://ask.sagemath.org/question/42042/square-root-of-polynomial-modulo-another-irreducible-polynomial/Hello,
If I'm not wrong, it is always possible to compute the square root of a polynomial $P$ modulo an irreducible polynomial $g$ when the base field is in $GF(2^m)$, i.e. find $Q \in GF(2^m)$ such that $Q^2 \equiv P \mod g$. Indeed, the operation $Q \rightarrow Q^2 \pmod g$ should be linear (because we are in $GF(2^m)$) so an idea would be to compute the matrix $T$ that perform this operation, and then invert it, but I'd like to find an embedded operation in sage. I tried the sagemath $P.sqrt()$ method, but the problem is that because it does not take into account the modulo, it fails most of the time when the polynomial has some terms with odd power of $X$.
Any idea?
Thanks!tobiasBoraMon, 16 Apr 2018 02:57:45 -0500http://ask.sagemath.org/question/42042/Plotting life history vectors in sagehttp://ask.sagemath.org/question/42023/plotting-life-history-vectors-in-sage/I'm teaching a math bio class where I need to plot a life history graph. The matrix equation is `new=A*old`, where `A` is a square matrix. I want to create a matrix of the population at each iteration (for say 10 iterations) and plot each column separately. I'm having trouble figuring it out and would appreciate some help.maeve.mccarthySun, 15 Apr 2018 13:08:56 -0500http://ask.sagemath.org/question/42023/Performance Issues [slow/commands not working]http://ask.sagemath.org/question/42006/performance-issues-slowcommands-not-working/I love sage and I think it's the best but I'm having some serious performance issues. Sometimes it takes like up to 15 seconds to compute trivial expressions. Most of the time, after some period of usage or invocation of specific commands (I haven't observed what causes this) the clear command becomes dysfunctional and I attach the logs:
0 [main] python2.7 14516 child_info_fork::abort: address space needed by 'eclucve31.dll' (0x400000) is already occupied
---------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-50-b74f34915750> in <module>()
----> 1 get_ipython().magic(u'clear ')
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(*args,**kwargs)
2080 return result
2081
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/alias.py in __call__(self, rest)
185 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
186
--> 187 self.shell.system(cmd)
188
189 #-----------------------------------------------------------------------------
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in system_raw(self, cmd)
2245 try:
2246 # Use env shell instead of default /bin/sh
-> 2247 ec = subprocess.call(cmd, shell=True, executable=executable)
2248 except KeyboardInterrupt:
2249 # intercept control-C; a long traceback is not useful here
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in call(*popenargs, **kwargs)
166 retcode = call(["ls", "-l"])
167 """
--> 168 return Popen(*popenargs, **kwargs).wait()
169
170
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
388 p2cread, p2cwrite,
389 c2pread, c2pwrite,
--> 390 errread, errwrite)
391 except Exception:
392 # Preserve original exception in case os.close raises.
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
915 gc.disable()
916 try:
--> 917 self.pid = os.fork()
918 except:
919 if gc_was_enabled:
OSError: [Errno 11] Resource temporarily unavailable
sage: clear
0 [main] python2.7 20456 child_info_fork::abort: address space needed by 'eclucve31.dll' (0x400000) is already occupied
---------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-51-b74f34915750> in <module>()
----> 1 get_ipython().magic(u'clear ')
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(*args,**kwargs)
2080 return result
2081
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/alias.py in __call__(self, rest)
185 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
186
--> 187 self.shell.system(cmd)
188
189 #-----------------------------------------------------------------------------
/opt/sagemath-8.1/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py in system_raw(self, cmd)
2245 try:
2246 # Use env shell instead of default /bin/sh
-> 2247 ec = subprocess.call(cmd, shell=True, executable=executable)
2248 except KeyboardInterrupt:
2249 # intercept control-C; a long traceback is not useful here
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in call(*popenargs, **kwargs)
166 retcode = call(["ls", "-l"])
167 """
--> 168 return Popen(*popenargs, **kwargs).wait()
169
170
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
388 p2cread, p2cwrite,
389 c2pread, c2pwrite,
--> 390 errread, errwrite)
391 except Exception:
392 # Preserve original exception in case os.close raises.
/opt/sagemath-8.1/local/lib/python2.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
915 gc.disable()
916 try:
--> 917 self.pid = os.fork()
918 except:
919 if gc_was_enabled:
OSError: [Errno 11] Resource temporarily unavailable
o6pFri, 13 Apr 2018 12:18:59 -0500http://ask.sagemath.org/question/42006/How to plot implicit3d plot with level sets in SageMath?http://ask.sagemath.org/question/41972/how-to-plot-implicit3d-plot-with-level-sets-in-sagemath/I want to plot a quadratic form with its level sets in SageMath. How to do that?
plot = Graphics()
plot+=plot3d(1/4*x^2+1/9*y^2,(x,-2,2),(y,-2,2))
for h in [0..5]:
plot+=contour_plot(f,(x,-4,4),(y,-4,4), fill=false, labels=true, contours=10,colorbar=true,cmap=matplotlib.cm.gist_rainbow).show(aspect_ratio=1)
show(plot)
How to achieve this?daviddglmathTue, 10 Apr 2018 13:11:52 -0500http://ask.sagemath.org/question/41972/Posets(10) freezinghttp://ask.sagemath.org/question/41912/posets10-freezing/For some reason in SageMath 8.1 the following code leads to a freeze:
p10 = Posets(10)
p10[18]
I have tried different indices, and everything works fine for i<=17, but starting from 18 I can not access to p10[i] without an immediate freeze.
The bug does not depend on system: I tried macOS and Windows 10, both lead to the same result.artem.kSun, 08 Apr 2018 13:36:48 -0500http://ask.sagemath.org/question/41912/Mapping between isomorphic NumberFieldshttp://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/ If I set up two NumberFields that differ only in the variable used in their defining polynomials, they don't report equal:
<pre>
sage: a=QQ['a'].0
sage: aRing = NumberField(a^2 + 1, 'a')
sage:
sage: b=QQ['b'].0
sage: bRing = NumberField(b^2 + 1, 'a')
sage:
sage: aRing is bRing
False
</pre>
This I can live with. But shouldn't I be able to convert elements between them?
<pre>
sage: aa=aRing.0
sage: bb=bRing.0
sage: bRing(aa)
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial b^2 + 1 and Number Field in a with defining polynomial a^2 + 1
</pre>
I can convert like this:
<pre>
sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True
</pre>
...but this seems awkward, and requires defining an auxilary function if you want to pass it to map or map_coefficients.
Is this a bug? Should I report it on Sage's Trac, or is there a good reason for this?BrentBaccalaFri, 13 Apr 2018 15:35:18 -0500http://ask.sagemath.org/question/42011/temp22.sobj is not UTF-8 encodedhttp://ask.sagemath.org/question/41890/temp22sobj-is-not-utf-8-encoded/I get a temp22.sobj is not UTF-8 encoded after trying to open this file
I saved by using save(G.allsimplecycles, 'temp22') what am I doing wrong?
standardtrickynessFri, 06 Apr 2018 12:33:52 -0500http://ask.sagemath.org/question/41890/Strange Solutionshttp://ask.sagemath.org/question/41996/strange-solutions/Sometimes the solutions given by Sage are weird. For example, the
equation below has only one solution, yet sage gives this output.
sage: solve(0.1*1==1*e^(-0.38*t),t)
[t == 50*log(10^(1/19)*e^(2/19*I*pi)),
t == 50*log(10^(1/19)*e^(4/19*I*pi)),
t == 50*log(10^(1/19)*e^(6/19*I*pi)),
t == 50*log(10^(1/19)*e^(8/19*I*pi)),
t == 50*log(10^(1/19)*e^(10/19*I*pi)),
t == 50*log(10^(1/19)*e^(12/19*I*pi)),
t == 50*log(10^(1/19)*e^(14/19*I*pi)),
t == 50*log(10^(1/19)*e^(16/19*I*pi)),
t == 50*log(10^(1/19)*e^(18/19*I*pi)),
t == -900/19*I*pi + 50/19*log(10),
t == -800/19*I*pi + 50/19*log(10),
t == -700/19*I*pi + 50/19*log(10),
t == -600/19*I*pi + 50/19*log(10),
t == -500/19*I*pi + 50/19*log(10),
t == -400/19*I*pi + 50/19*log(10),
t == -300/19*I*pi + 50/19*log(10),
t == -200/19*I*pi + 50/19*log(10),
t == -100/19*I*pi + 50/19*log(10),
t == 50/19*log(10)]o6pThu, 12 Apr 2018 14:21:12 -0500http://ask.sagemath.org/question/41996/Why do I need the inverse transition_map?http://ask.sagemath.org/question/42013/why-do-i-need-the-inverse-transition_map/ I have the following code that works fine:
reset()
R3 = Manifold(3, 'R3', start_index=1, latex_name=r'\mathbb{R}^3')
Cartesian3d.<x,y,z> = R3.chart()
lg = R3.metric('lg')
lg[:] = identity_matrix(R3.dim())
F = R3.vector_field()
F[:] = [x*z, y*z, x^2+y^2]
omega = F.down(lg).hodge_dual(lg)
omega.set_name('omega', r'\omega')
domega = omega.exterior_derivative()
domega.set_name('domega', r'\mathrm{d}\omega')
# Change of coordinates
Spherical.<rho,phi,theta> = R3.chart(r'rho:(0,+oo):\rho phi:(0,pi):\varphi theta:(0,2*pi):\theta')
g = Spherical.transition_map(Cartesian3d, [rho*sin(phi)*cos(theta), rho*sin(phi)*sin(theta), rho*cos(phi)])
g.set_inverse(sqrt(x^2+y^2+z^2), atan2(sqrt(x^2+y^2), z), atan2(y, x))
domega.display()
domega.display(Spherical.frame(), Spherical)
Except that all breaks loose if I comment out the definition of the inverse transition_map in the above code and run all the code again. In this case the last command issues a KeyError with an incomprehensible message:
KeyError: (Chart (R3, (x, y, z)), Chart (R3, (rho, phi, theta)))
Why do I need to define the inverse transition_map? Where is this inverse transition_map used?
I have an equivalent code in Maxima that calculates the same, but I don't need to defined the inverse map.
Daniel
danielvolinskiSat, 14 Apr 2018 13:40:08 -0500http://ask.sagemath.org/question/42013/connected sum of knotshttp://ask.sagemath.org/question/41985/connected-sum-of-knots/ Hi! I was trying to recursively construct connected sums of knots, but I seem to run in to some problems when connect summing a knot to itself more than two times:
>B = BraidGroup(2)
>trefoil = Knot(B([1,1,1]))
>K = trefoil.connected_sum(trefoil)
>L = K.connected_sum(trefoil)
This does not work:
> ValueError Traceback (most recent call last)
> ipython-input-1-7b977cf99468 in module()
> 2 trefoil = Knot(B([Integer(1),Integer(1),Integer(1)]))
> 3 K = trefoil.connected_sum(trefoil)
> --> 4 L = K.connected_sum(trefoil)
> /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/knots/knot.pyc in connected_sum(self, other)
> 294 return Knot(B(list(b1.Tietze())
> 295 + [(abs(i) + b2s) * Integer(i).sign() for i in b2.Tietze()]
> --> 296 + [b1s]))
> 297
> /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/knots/knot.pyc in __init__(self, data, check)
> 104 if check:
> 105 if self.number_of_components() != 1:
> --> 106 raise ValueError("the input has more than 1 connected component")
> 107
> 108 def __repr__(self):
> ValueError: the input has more than 1 connected component
Am I doing something wrong here?
Thanks in advance!danieleCWed, 11 Apr 2018 06:14:13 -0500http://ask.sagemath.org/question/41985/Non-linear regression with arbitrary precision arithmetichttp://ask.sagemath.org/question/41988/non-linear-regression-with-arbitrary-precision-arithmetic/I'm looking to do something like this:
R = RealField(1000)
data = [[R(1),R(5)],[R(5),sqrt(R(6))],[R(8),R(9)]]
var('a, b, c, x')
model(x) = a*x*x + b*x + c
find_fit(data, model)
However when I run this a,b and c seem to have been truncated to a double. How would I get arbitrary precision out of find_fit?
pircksWed, 11 Apr 2018 12:19:51 -0500http://ask.sagemath.org/question/41988/evaluate (simplify) trigonometric expressionhttp://ask.sagemath.org/question/41993/evaluate-simplify-trigonometric-expression/
t = var('t')
R = vector ((3*cos(t), 3*sin(t), 4*t))
dRdt = R.diff(t)
show(dRdt)
ds = dRdt.norm()
show(ds)
when I try to show ds it gives mi a trigonometric expression which is actually is equal to 5.
I tried simplify() and trig_simplify but it didn't help...
Any tips are welcome.
Thanks in advancewatty_Thu, 12 Apr 2018 12:13:32 -0500http://ask.sagemath.org/question/41993/What is the significance of "." other than in a file name?http://ask.sagemath.org/question/41937/what-is-the-significance-of-other-than-in-a-file-name/ I continue to stumble over the "." in structures other than in filenames. For example,
Dr(t) = sol[0].rhs
where D is the first derivative of r and "sol" has been defined as the Sagemath function "solve" in lines before this one.wxman112Sun, 08 Apr 2018 21:36:59 -0500http://ask.sagemath.org/question/41937/