Ask Your Question

rrogers's profile - activity

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):  
    var('k')  
    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

fn2ref(a,b,c,z):=hypergeometric([a,b],[c],z);  
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);  
fn1l(a,b,c,z,m):=  
sum((pochhammer(a,k)*pochhammer(b,k)/(pochhammer(c,k))*z^k/factorial(k)),k,0,m);  

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: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: https://math.stackexchange.com/questi... 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
v.display()
∂/∂x+2∂/∂y+3∂/∂z
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?
Ray

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]]);
m=1-2M/r
G =matrix([[-m,0],[0,1/m]])
k = T.transpose()
GT
eq1=k[0,0];
eq2=k[0,1];
eq3=k[1,0];
eq4=k[1,1];
eqd=A
D-BC-1
eqd
sol=solve([eq1+m==0,eq3-sqrt(2
M/r)==0,eq4-1==0,eqd==0],[A,B,C,D]);
sol

-comment---solve([eq1+m==0,eq3-sqrt(2*M/r)==0],[A,B])


Produces:
$\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 doc.sagemath.org/html/en/reference/quadratic_forms/sage/quadratic_forms/quadratic_form.html#sage.quadratic_forms.quadratic_form.QuadraticForm.rational_diagonal_form

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

but

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().**

Ray

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 ??

2016-11-29 20:12:50 -0600 asked a question "mesh=" juypter vs. -notebook

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

sage -notebook

Comes up and executes:

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

Correctly.

Whereas:

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)
    148 
    149         """
--> 150         return self.shell.display_formatter.format(result)
    151 
    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 = self.dm.displayhook(obj)
    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)
    767 
    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/jsmol_iframe.py 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/jsmol_iframe.py 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/jsmol_iframe.py 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
   2403 

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/jsmol_iframe.py 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 += [

AssertionError: