Ask Your Question

rrogers's profile - activity

2020-11-18 10:43:58 -0600 received badge  Popular Question (source)
2020-11-12 07:27:12 -0600 commented answer assignment vs. subs()

I should add that Jordan_form transforms of polynomials are not Taylor/polynomial representable. Which, to me, is still a mystery.

2020-11-12 07:21:44 -0600 received badge  Enthusiast
2020-11-11 16:22:14 -0600 commented answer assignment vs. subs()

Okay, but I am doing things that I don't know will fit in QQ. For instance:


Where H is lower triangular singular; (i.e.) the creation matrix. Substituting H for t in a variety of formulas; in particular "Scheffer sequence" generating functions.

2020-11-11 09:49:34 -0600 asked a question assignment vs. subs()

What am I missing? I can assign "t=H" but subs(t=H) errors out.

t2 = t^2  #random formula example
2020-10-17 17:00:38 -0600 asked a question %display latex vs. ipywidgets

This is part informational and part a question of style In Sage Manifolds, %display latex is set to produce "pretty" output like thus

%display plain
var('a, g')
display(sqrt(a + g))
%display latex
sqrt(a + g)

which everybody knows, but a more insidious thing is that it breaks ipywidgets.Hbox() "display". I did a hack in this code below; but does anybody know of a more elegant (re. automatic) means. This is a little long but illustrates what is lost. Try changing %display lines at the bottom.

%display latex  # Just to copy the problem in
import matplotlib.pyplot as plt
from IPython.display import display, HTML
import ipywidgets

# Save
file_name = 'rings.html'
save_desc = 'save as' + file_name
save_box = ipywidgets.Checkbox(False, description=save_desc)

# Red ring
red_ring = Horizon()'red ring')
red_ring.color = 'red'
red_ring.radius =2

# Black ring
black_ring = Horizon()
black_box ='black ring')
black_ring.color = 'black'
black_ring.radius = 3

# Green ring
green_ring = Horizon()
green_box ='green ring')
green_ring.color = 'green'
green_ring.radius = 4

ui = ipywidgets.HBox([red_box, black_box, green_box, save_box])

def f(red, black, green, save_f):
    global plt_obj
    plt_obj = sphere((1, 0, 0), .6)
    if red:
        plt_obj += red_ring.gobject()
    if black:
        plt_obj += black_ring.gobject()
    if green:
        plt_obj += green_ring.gobject()
    if save_f:
    show(plt_obj, viewer='threejs')

out_show = ipywidgets.interactive_output(f, {'red': red_box,
                                             'black': black_box,
                                             'green': green_box,
                                             'save_f' : save_box})

%display plain
%display latex
2020-10-09 08:05:06 -0600 received badge  Self-Learner (source)
2020-10-09 08:05:06 -0600 received badge  Teacher (source)
2020-10-08 15:40:27 -0600 answered a question row of multiple selection checkboxes

This format works but I am having a small problem with "f()" argument passing, I can't seem to make it a dummy argument. The ipywidgets page that has instructions and examples is:

import ipywidgets
red_ring =ipywidgets.Checkbox(True,description='red ring')
black_ring =ipywidgets.Checkbox(True,description='black ring')
green_ring =ipywidgets.Checkbox(True,description='green ring')
ui = ipywidgets.HBox([red_ring,black_ring,green_ring])
def f(red_ring,black_ring,green_ring): 
    a = sphere((1,0,0),0.2)
    if red_ring:
         a += circle((0,0,0), 2, color='red', thickness=6)
    if black_ring:
         a += circle((0,0,0), .4, color='black', thickness=6)
    if green_ring:
         a += circle((0,0,0), .7, color='green', thickness=6)
out = ipywidgets.interactive_output(f, {'red_ring': red_ring,
                                    'black_ring': black_ring,
                                    'green_ring': green_ring})
display(ui, out)
2020-09-26 09:08:36 -0600 asked a question row of multiple selection checkboxes

I would like to have the multiple selection checkboxes below in a row instead of a column. I did search around and didn't come up with anything obvious. As well as knowing how to do it; what resource should I have looked at?
I am putting together anatomical diagrams of the Kerr_Schild metric.

@interact def _(red_ring =('red ring', True),
  black_ring =('black ring',False),
  green_ring = ('green ring',False)
  a = sphere((1,0,0),0.2)
  if red_ring:
    a += circle((0,0,0), 2, color='red', thickness=6)
  if black_ring:
    a += circle((0,0,0), .4, color='black', thickness=6)
  if green_ring:
    a += circle((0,0,0), .7, color='green', thickness=6)
2020-09-07 07:34:26 -0600 commented answer Typo in Sagemanifolds worksheet ?

Okay, I see

2020-09-04 08:59:16 -0600 asked a question Typo in Sagemanifolds worksheet ?

Sorry to bother the group but I don't know how to report a technical (but inconsequential) typo in Kerr_Schild.ipynb Where should I report it? After In[33] or so, "Check of the Identity"
\frac{x^2 + y^2}{r^2 + a^2} + \frac{z^2}{r^2} = 1
Should be:
\frac{x^2 + y^2}{R^2 + a^2} + \frac{z^2}{R^2} = 1
It seems to be too trivial for a 'Ticket' on the Sagemanifolds forum. I am just reading the program in detail; checking my understanding.

2020-09-04 07:05:53 -0600 received badge  Commentator
2020-09-04 07:05:53 -0600 commented answer Latex (?)--Riemann tensor overflow

Thanks, I was just wondering if this was a bad sign of a coding error :) Turns out I can always drop it into Lyx; although it does run off the "page" :)

2020-09-03 16:45:04 -0600 asked a question Latex (?)--Riemann tensor overflow

While running Kerr_Schild.ipynb

I get a bad output; not necessarily incorrect. I copied the TeX to a LaTeX GUI editor and it looks right. When the last expression is evaluated it outputs TeX instead of LaTeX image. It is very long so it might just be a converter problem; that I can ignore. After the leadin the expression:


Well I can't attach a trimmed file but I can provide a Dropbox link if needed. The above expression was added just after the "Kerr Metric" paragraph; about line 13. Is this my machine or LaTeX or Jupyter ?

2020-07-11 07:22:51 -0600 commented answer isympy/sympy sagemath integration ?

Thanks I am trying the answer(s) to your question!

2020-07-11 07:10:51 -0600 commented answer How to wrap a sympy function as a sage function ?

This is what I have asked elsewhere. Apparently the sympy "integrate()" function has functionality that Sagemath hasn't implemented; even with 'algorithm = "sympy" ' . In addition, "from sympy import * " changes the syntax of Sagemath "integrate" including limit formatting.
I will try your wrapper as a way to access this functionality although it would be more consistent to go through "algorithm='sympy' " for integration; and have the limit formatting done automatically; the same for mathematica expressions.

2020-07-10 07:20:56 -0600 commented answer isympy/sympy sagemath integration ?

Why should I reimplement lerchphi() when I can just import sympy? Originally I was just wondering if there was a documentation error in Sagemath. And now, I don't understand the naming crosstalk!
I am not writing general purpose programs; just trying to generate and apply "fractional derivatives" to some Generalized Hypergeometric functions. Which you can recognize from the formula, everything seems to be running fine (for now). Sympy is the only program that recognizes this integral as far as I can see. But I have to go off script to use it in Jupyter.

2020-07-10 07:11:45 -0600 commented answer isympy/sympy sagemath integration ?

Well this is interesting and getting more complicated. I was running in Jupyter Sagemath 9.1 and after

from sympy import *                                                       
 x, a = symbols('x a')

works fine; expected symbol and answer. So I brought up a shell and typed Sage. (to get the Sage: prompt. ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 9.0, Release Date: 2020-01-01 │ │ Using Python 3.8.2. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘

And using your code and import sympy , all I get is NameError: name 'sympy' is not defined BTW: running Jupyter in a new notebook with Python also fails :)

2020-07-09 15:06:01 -0600 asked a question isympy/sympy sagemath integration ?

I'm trying to integrate


With sympy; which succeeds in isympy. But I need to separately import sympy

from sympy import *
x, a = symbols('x a')

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


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?

2019-10-14 06:44:09 -0600 received badge  Editor (source)
2019-10-12 12:21:10 -0600 commented answer Hypergeometric Bug?

Really?? (sigh) this type of thing is why I always double-check symbolic/numeric algebra packages (:(: and have to write "shells" (incidently it's wrong).

2019-10-07 01:31:17 -0600 received badge  Popular Question (source)
2019-10-06 09:16:19 -0600 asked a question Hypergeometric Bug?

The following code shows a (typical ?) failure. F([m,a,b;m,c;z) should and does for positive m; cancel m. but when m is negative "0" is declared prematurely

--Juptyter code

def pochhammer(x,a):   
    return rising_factorial(x,a)  

def fn2ref(a,b,c,z,m): return hypergeometric([a,b],[c],z)  

def fn2lm(a,b,c,z,m):  
    return hypergeometric([m,a,b],[c,m],z)  

def fn2l(a,b,c,z,m):  
    return hypergeometric([-m,a,b],[c,-m],z)   

def fn1l(a,b,c,z,m):  
    return sum((pochhammer(a,k)*pochhammer(b,k)/pochhammer(c,k))*(z^k/factorial(k)),k,0,m)  

print "2F1(a,b;c;z,5) = ", fn2ref(1,2,3,.5,5)  
print "3F2(m,a,b;m,c;z) = ", fn2lm(1,2,3,.5,5)    
print "3F2(-m,a,b;-m,c;z) = ", fn2l(1,2,3,.5,5)  
print "m terms of 2F1(a,b;c;z) = ", fn1l(1,2,3,.5,5)

-- produces
2F1(a,b;c;z,5) = 1.54517744447956
3F2(m,a,b;m,c;z) = 1.54517744447956
3F2(-m,a,b;-m,c;z) = 1.53809523809524
m terms of 2F1(a,b;c;z) = 1.538095238095238

--Whereas Maxima code

fn2lm(a,b,c,z,m)      :=hypergeometric([a,b,m],[c,m],z);  
fn2l(a,b,c,z,m)      :=hypergeometric([a,b,-m],[c,-m],z);  

print ("2F1(a,b;c;z) = ",fn2ref(1,2,3,.5))$  

print("3F2(m,a,b;m,c;z) = ",fn2lm(1,2,3,.5,5))$  

print("3F2(-m,a,b;-m,c;z) = ",fn2l(1,2,3,.5,5))$  

print("m terms of 2F1(a,b;c;z) = ",fn1l(1,2,3,.5,5))$

-- Produces
2F1(a,b;c;z) = 1.545177444479563
3F2(m,a,b;m,c;z) = 1.545177444479563
3F2(-m,a,b;-m,c;z) = 1.545177444479563
m terms of 2F1(a,b;c;z) = 1.538095238095238

Which accords with the definition and Luke "The Special Functions and their Approximations" which is a pretty standard.

2019-07-12 10:16:33 -0600 marked best answer "mesh=" juypter vs. -notebook

Perhaps I should send this to some devel or support group ?
Starting command line:

sage -notebook

Comes up and executes:

plot3d(sin(x-y)*y*cos(x),(x,-3,3),(y,-3,3), mesh=True)



sage -n jupyter

Fails with miscellaneous assertion type errors. sagemath 7.3 in both cases.
A friend also point out the option "color='yellow' " also fails in jupyter.

Edit (slelievre): I confirm I can observe this also with Sage 7.4. Here is the error message I get:

AssertionError                            Traceback (most recent call last)
<ipython-input-3-44b2387a145a> in <module>()
----> 1 plot3d(sin(x-y)*y*cos(x),(x,-Integer(3),Integer(3)),(y,-Integer(3),Integer(3)), mesh=True)

/opt/s/sage-7.4/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
    244             self.start_displayhook()
    245             self.write_output_prompt()
--> 246             format_dict, md_dict = self.compute_format_data(result)
    247             self.update_user_ns(result)
    248             self.fill_exec_result(result)

/opt/s/sage-7.4/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
    149         """
--> 150         return
    152     # This can be set to True by the write_output_prompt method in a subclass

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/formatter.pyc in format(self, obj, include, exclude)
    158         # First, use Sage rich output if there is any
    159         PLAIN_TEXT = u'text/plain'
--> 160         sage_format, sage_metadata =
    161         assert PLAIN_TEXT in sage_format, 'plain text is always present'
    162         if sage_format.keys() != [PLAIN_TEXT]:

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.pyc in displayhook(self, obj)
    764         self._backend.set_underscore_variable(obj)
    765         plain_text, rich_output = self._rich_output_formatter(obj, dict())
--> 766         return self._backend.displayhook(plain_text, rich_output)
    768     def display_immediately(self, obj, **rich_repr_kwds):

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_ipython.pyc in displayhook(self, plain_text, rich_output)
    525             from sage.repl.display.jsmol_iframe import JSMolHtml
    526             jsmol = JSMolHtml(rich_output, height=500)
--> 527             return ({u'text/html':  jsmol.iframe(),
    528                      u'text/plain': plain_text.text.get_unicode(),
    529             }, {})            

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/ in iframe(self)
    259             </iframe>
    260         """
--> 261         escaped_inner_html = self.inner_html().replace('"', '&quot;')
    262         iframe = IFRAME_TEMPLATE.format(
    263             script=self.js_script(),

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/ in inner_html(self)
    235         """
    236         return INNER_HTML_TEMPLATE.format(
--> 237             script=self.js_script(),
    238             width=self._width,
    239             height=self._height,

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/ in js_script(self)
    193         """
    194         script = [r"["]
--> 195         for line in self.script().splitlines():
    196             script += [r"  '{0}',".format(line)]
    197         script += [r"].join('\n');"]

/opt/s/sage-7.4/src/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (/opt/s/sage-7.4/src/build/cythonized/sage/misc/cachefunc.c:12716)()
   2399         if self.cache is None:
   2400             f = self.f
-> 2401             self.cache = f(self._instance)
   2402         return self.cache

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/ in script(self)
    156                     command, obj, meshfile = line.split(' ', 3)
    157                     assert command == 'pmesh'
--> 158                     assert meshfile.startswith('"') and meshfile.endswith('"\n')
    159                     meshfile = meshfile[1:-2]    # strip quotes
    160                     script += [

2019-07-12 10:14:08 -0600 received badge  Notable Question (source)
2019-07-01 11:25:06 -0600 commented question Can SAGE generate embedded Kerr spacetime dynamic diagrams?

I am also interested in a similar thing. I posted a question at: My take is slightly different but if an answer is not forthcoming, are you interested in a joint project?

2019-05-21 18:57:30 -0600 commented answer tangent space vector mapping

Great! and thanks :) That in fact corresponds to usage/pullback of T_p vector I remember. I have looked around on the web in the last day and there seem's to be some obstacles to just yanking in down in general. One place has a greater than 1-page proof that it can sometimes be done. Yet another preconception too examine (:

2019-05-21 17:57:09 -0600 received badge  Scholar (source)
2019-05-21 17:56:56 -0600 received badge  Supporter (source)
2019-05-21 17:00:48 -0600 received badge  Nice Question (source)
2019-05-20 10:47:33 -0600 asked a question tangent space vector mapping

Very simple question.
I am going through the SM_tutorial and branched off into a sidestream; trying to understand and put things in a context that I already know.
The tutorial defines a function f() on 3 space and defines the associated tangent_space. I have a couple of questions
1) How do I take a vector in the tangent_space
Say: v = Tp.an_element(); print(v)
"Tangent vector at Point p on the 3-dimensional differentiable manifold M"
or vxx = Tp((-2,1,5), name='vxx')
and apply it to f() (or f(p) although the TM is only defined at p so far)?
If I define a vector in the base space it works::
v = U.vector_field(name='v')
s = v(f)
I know in standard texts the mapping of vectors in TM_p to the base is defined, but couldn't find it in the Sage Manifold documentation.

2) Taking : v = Tp.an_element(); print(v)
I get something that looks like a vector (with a different ancestry) but has a value
Where did this value come from? In one of the documentation it (sort of) implies it's an example; is this true?
Why isn't it left undefined?

2018-02-20 04:26:42 -0600 received badge  Popular Question (source)
2017-01-07 17:03:28 -0600 commented answer solve maxima?

You are saying that sagemath can't give multiple solutions? Or is maxima wrong? In other words: what is the semantic difference between solve in sagemath and maxima? I know that maxima doesn't always find all the answers but I haven't had it give me a wrong one. I do know that underdetermined equation sets yield parametric or multiple solutions.

2016-12-24 09:28:49 -0600 asked a question solve maxima?

The following in Jupyter (and sage cloud) produces the wrong output. I do have an (extremely similar) maxima batch file that works fine. I sort of presume that maxima "solve" is not really called. If needed I can provide all files and stuff; either link or inline. Or if the correct way to use maxima/solve isn't obvious I can shorten up the generation of the solve argument by direct assignment. The last commented line is to prove that simpler problems yield the correct same answers in sagemath and maxima; when sagemath feels like. jupyter:

%display latex
var('A B C D M r')
T =matrix([[A,B],[C,D]]);
G =matrix([[-m,0],[0,1/m]])
k = T.transpose()


$\newcommand{\Bold}[1]{\mathbf{#1}}\left[-B C + A D - 1 = 0, A^{2} {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C^{2}}{\frac{2 \cdot M}{r} - 1} - \frac{2 \, M}{r} + 1 = 0, A B {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C D}{\frac{2 \cdot M}{r} - 1} - \sqrt{2} \sqrt{\frac{M}{r}} = 0, B^{2} {\left(\frac{2 \, M}{r} - 1\right)} - \frac{D^{2}}{\frac{2 \, M}{r} - 1} - 1 = 0\right]$

Whereas : a maxima script produces

${\left[ \left[ A=-1 , B={{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}} , C=0 , D=-1 \right] , \left[ A=1 , B=-{{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}}, C=0 , D=1 \right] \right] }$

2016-12-12 10:01:39 -0600 answered a question quadraticform rational_diagonal_form?

Q.matrix() ( i.e. the .matrix() operation) returns
matrix() Returns the Hessian matrix A for which Q(X) = (1/2)∗Xt∗A∗X(1/2)∗Xt∗A∗X.
I can understand where the two comes from if your doing differentiation.
What I don't understand is why .matrix() gives this form. Ray

2016-12-12 09:34:50 -0600 asked a question quadraticform rational_diagonal_form?

I don't understand the factor of "2" ; which also appears in my real problem. Here is the sample code from

Q = QuadraticForm(ZZ, 4, range(10))  
D, T = Q.rational_diagonal_form(return_matrix=True)  
[ -1/16 0 0 0 ]  
[ * 4 0 0 ]  
[ * * 13 0 ]  
[ * * * 563/52 ]


T.transpose() * Q.matrix() * T  
[  -1/8      0      0      0]  
[     0      8      0      0]  
[     0      0     26      0]  
[     0      0      0 563/26]

Off by a factor of 2?

The description says.

OUTPUT: either D (if return_matrix is false) or (D,T) (if return_matrix is true) where  
D – the diagonalized form of this quadratic form.  
T – transformation matrix. This is such that T.transpose() * self.matrix() * T gives D.matrix().**


2016-11-30 10:10:06 -0600 received badge  Student (source)
2016-11-30 09:07:13 -0600 commented question "mesh=" juypter vs. -notebook

Ignoring some installation differences and using strace: the "sage -notebook" path is ".../repl/rich_output/" whereas "sage -n jupyter" , like above and on my installation, is ".../repl/display/" although I haven't run strace in this case and just looked at the debug output. If it would help, I can make some straces available in dropbox; they are tediously long though. Or some way to control the /repl/xxx routing/option ??