Ask Your Question

Paul Bryan's profile - activity

2020-11-29 17:10:39 +0200 received badge  Notable Question (source)
2019-09-08 23:51:37 +0200 commented answer Error computing curvature of graph submanifold

Awesome! Thanks for pointing out the error in my code too.

2019-09-08 06:15:18 +0200 asked a question Error computing curvature of graph submanifold

The following appears to be a bug in sagemanifolds curvature. I see the error running it in Other things like computing the induced_metric() and normal() and fine. Am I doing something wrong?

sage: P = Manifold(3, 'P', structure='Riemannian', metric_name='g', start_index=0)
sage: Q = Manifold(2, 'Q', ambient=P, structure='Riemannian', metric_name='k', start_index=1)

sage: CP.<x,y,z> = P.chart()
sage: CQ.<u,v> = Q.chart()

sage: g = P.metric()
sage: c = 2/(sum(y^2 for y in CP[1:]) + 1)
sage: g[0,0], g[1,1], g[2,2] = 1, c^2, c^2

sage: f = sum(CQ[:])
sage: f = u + v
sage: phi = Q.diff_map(P,{(CQ, CP):[f] + list(CQ[:])})
sage: phi_inv = P.diff_map(Q, {(CP, CQ) : list(CQ[:])})

sage: Q.set_embedding(phi, inverse=phi_inv)

sage: K = Q.extrinsic_curvature()

Error in lines 13-13

Traceback (most recent call last):

File "/cocalc/lib/python2.7/site-packages/smc_sagews/", line 1188, in execute flags=compile_flags), namespace, locals)

File "", line 1, in <module>

File "/ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/manifolds/differentiable/", line 1067, in second_fundamental_form range(self._dim + 1))

File "sage/matrix/matrix0.pyx", line 1424, in sage.matrix.matrix0.Matrix.__setitem__ (build/cythonized/sage/matrix/matrix0.c:8796) self.set_unsafe(row, col, self._coerce_element(value))

File "sage/matrix/matrix0.pyx", line 1529, in sage.matrix.matrix0.Matrix._coerce_element (build/cythonized/sage/matrix/matrix0.c:10273) return self._base_ring(x)

File "sage/structure/parent.pyx", line 900, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9197) return mor._call_(x)

File "sage/structure/coerce_maps.pyx", line 288, in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:5942) cdef Element e = method(C)

File "sage/symbolic/expression.pyx", line 1087, in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8689) raise TypeError("unable to convert %r to an integer" % self)

TypeError: unable to convert 1/2sqrt(2)(u^4 + v^4 + 2(u^2 + 1)v^2 + 2u^2 + 1)y/(sqrt(u^4 + v^4 + 2(u^2 + 1)v^2 + 2u^2 + 3)(y^2 + z^2 + 1)) + 1/2sqrt(2)(u^4 + v^4 + 2(u^2 + 1)v^2 + 2u^2 + 1)z/(sqrt(u^4 + v^4 + 2(u^2 + 1)v^2 + 2u^2 + 3)(y^2 + z^2 + 1)) to an integer

2019-07-30 09:05:42 +0200 received badge  Popular Question (source)
2019-01-21 23:03:27 +0200 received badge  Famous Question (source)
2018-05-30 08:30:45 +0200 asked a question LaTeX macros in Markdown on Cocalc

I'm trying to use some custom macros in sage worksheets and Markdown files. How do I include my own custom macros in a Markdown file? I thought the markdown conversion used pandoc so I tried adding YAML front matter:

header-includes: |

but cocalc just tries to render it rather than treating it as YAML front matter.

I would also like to do something similar in Sage worksheets. It works okay with LaTeX. I have a cell like this


Then I can access my macros (such as "\Rm") in LaTeX cells:


Everything works fine there.

If I try to use my macros in Markdown cells however, they do not render properly.


# My heading


just produces "\Rm" in red.

Does anyone know how I can use my own custom macros in Markdown?

2018-02-26 12:46:03 +0200 received badge  Notable Question (source)
2017-11-06 09:25:20 +0200 commented answer Programmatically setting ticks

Okay. thanks. Seems like a thorny issue.

2017-11-06 09:23:43 +0200 commented answer Best practice SageMath workflow?

Absolutely git is the way, or at least some version control software. I personally use github but I don't think that matters much. I think to pull into a CoCalc project, you'll need to use a terminal with internet access and so it won't work on a free plan. But I could be wrong.

2017-10-30 16:22:03 +0200 received badge  Nice Question (source)
2017-10-30 09:59:18 +0200 asked a question Programmatically setting ticks

I currently generate an array of plots by something like:

u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(p, (u, 0, 2*pi)) for p in array]

Then I can set the axes of individual plots by


I plot it via

g = graphics_array(P)

This produces a plot with three graphs where the second graph has no axes. Great.

I can set ticks when showing a plot:

p = P[1][[0, 2*pi], [p.ymin(), p.ymax()]], tick_formatter=[pi,None])

But I can't seem to find how to set them programmatically as with the axes above. I have tried accessing the underlying matplotlib object by

m = p.matplotlib

I don't see how to set the ticks there.

Does anyone know how I can set the ticks for plots individually?

2017-10-27 08:25:54 +0200 received badge  Popular Question (source)
2017-09-07 13:42:11 +0200 commented answer Infinite initial conditions in ODE and arbitrary constant

Excellent. That does the job, thank you.

2017-02-09 02:38:50 +0200 received badge  Editor (source)
2017-02-09 02:37:45 +0200 asked a question Infinite initial conditions in ODE and arbitrary constant

Is it possible to include infinite initial conditions in an ODE? For example,

ode_soln = desolve(ode, q, ics[0, -Infity])

throws and error.

Alternatively, I can leave the initial condition blank:

ode_soln = desolve(ode, q)
soln = solve(ode_soln, q)

Then output Includes an arbitrary constant written C $$ q\left(t\right) = -\frac{p}{C {\left(p + 1\right)} + {\left(p + 1\right)} t} $$

I tried to set a value for $C$ via,

show(soln[0].substitute(C = 0))

but it made no difference. Here $p$ I declared as a variable, and I can do things like

show(soln[0].substitute(p = 1))

to produce the expected output

$$ q\left(t\right) = -\frac{1}{2 {\left(C + t\right)}} $$

So it seems that I need to refer to the arbitrary constant by some other name than $C$. How can I do this?

2016-11-19 21:50:35 +0200 commented answer Rotate a 2d plot

cool, thanks :)

2016-11-18 15:24:00 +0200 commented answer Rotate a 2d plot

Actually, although this solution answers the example in the question, it does not seem to solve my general problem. I have other kinds of graphics objects such as lines, polygons, text labels etc. and some of the vectors will not be based at the same point. I want to be able to rotate the entire scene including such objects. So I essentially need to be able to rotate the entire viewport about a point. At this stage, my solution is to save the image and rotate it using an external editor, but it would certainly by preferable to be able to perform transformations on entire plots from within sage. I think matplotlib has this kind of functionality, but I don't yet know how to achieve it.

2016-11-18 14:56:20 +0200 received badge  Supporter (source)
2016-11-16 15:15:37 +0200 received badge  Popular Question (source)
2016-11-16 15:15:02 +0200 received badge  Scholar (source)
2016-11-16 15:14:59 +0200 commented answer Rotate a 2d plot

Thanks! That's effectively what I have done - rotate each object, and it's not so bad if you do it the way you have.

2016-11-16 14:35:41 +0200 asked a question Rotate a 2d plot

I have a 2d plot with multiple arrows, lines etc. and I would like to rotate the entire thing. Here's a simple example without rotation. The real example has more objects on it so I'd rather rotate the entire plot than each individual object.

O = vector((0, 0))
Tp = vector((1, 0))
Np = vector((0, 1))

p = plot([])

p += arrow2d(O, Tp, color="blue")
p += arrow2d(O, Np, color="blue"), aspect_ratio=1)

How can I go about rotating the entire plot by a fixed angle? I have only been able to find information about rotations for 3d plots.

2013-03-15 17:18:37 +0200 received badge  Taxonomist
2010-12-04 05:10:14 +0200 answered a question New Project Looking for Help: Plotting great circles

I don't know if you can do it using plot3d via a spherical transform, but you can just do a 3 dimensional parametric plot directly providing the transformation as follows:

r = 1
theta = 0
parametric_plot3d((r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)), (phi, 0, 2*pi))

Then as above, you can create a function and show many circles

cp = lambda theta: parametric_plot3d((r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)), (phi, 0, 2*pi))
many_circles = cp(0) + sum(cp(pi/(2^n)) for n in range(1,7)) + sum(cp(-pi/(2^n)) for n in range(1,7))

image description

2010-11-15 15:27:03 +0200 received badge  Student (source)
2010-11-11 19:45:56 +0200 asked a question multi-symmetric functions and multi-partitions

Does sage support manipulating multi-symmetric functions/polynomials and/or multi-partitions? Multi-symmetric functions are like the usual symmetric ones, except the symmetric group acts by permuting "vectors" of variables simultaneously, e.g. for an two vectors $x=(x_1,x_2\dotsc), y=(y_1,y_2,\dotsc)$, $\Sigma_2$, acts by permuting $x,y$. A multi-partition of a $n$-tuple $B=(b_1,\dotsc,b_n)$ of natural numbers is a unordered set of $n$-tuples $A_1,\dotsc,A_l$ with $A_1 + \dotsm + A_l = B$.

I'd like to have a combinatorial class of multi-partitions with similar functionality as partitions, e.g. .first(), .last() methods and iter(). I'd also like to have a class like SymmetricFunctionAlgebra, but with multi-symmetric functions instead. I've had a bit of a poke around and there's some functionality in Maxima (in the Sym) package that might help, but not quite like what I want (that I can find). So, before writing code, I'm asking here.

If the code needs to be written, I'm quite keen to make it my first (hopefully of many) contribution to sage...