Ask Your Question

Dox's profile - activity

2022-10-17 17:21:19 +0100 answered a question How to add latex itemize environment in sagemath markdown cell.

With a single dash as first character in the line. More info:

2022-10-10 10:44:37 +0100 marked best answer Integrating an integral

Hi community.

I'm interested in manipulating a formal expression

$$\int \mathrm{d}t \; e^{- 2 \int \mathrm{d}t \; h(t)}.$$

My notebook contains the following code

h = function('h')(t)

but the result is +Infinity.


  • Why I am getting a result if the function h is not explicit?
  • Where does the +Infinity come from?
2022-10-10 10:34:52 +0100 answered a question Integrating an integral

Thanks to the comment by @fredericc I found the answer! The solution is to use the algorithm='maxima' flag, e.g. var('t

2022-10-09 17:40:21 +0100 received badge  Nice Question (source)
2022-10-09 10:34:55 +0100 asked a question Integrating an integral

Integrating an integral Hi community. I'm interested in manipulating a formal expression $$\int \mathrm{d}t \; e^{-

2022-05-16 12:36:44 +0100 received badge  Notable Question (source)
2022-01-26 04:06:53 +0100 received badge  Popular Question (source)
2022-01-02 20:55:01 +0100 received badge  Taxonomist
2021-10-22 10:27:39 +0100 received badge  Notable Question (source)
2021-10-15 17:12:09 +0100 received badge  Popular Question (source)
2021-05-29 13:30:09 +0100 received badge  Popular Question (source)
2021-05-18 03:35:09 +0100 received badge  Popular Question (source)
2021-01-15 20:07:10 +0100 received badge  Famous Question (source)
2020-12-16 22:03:13 +0100 received badge  Popular Question (source)
2020-09-07 21:31:12 +0100 received badge  Nice Question (source)
2020-05-20 05:37:53 +0100 received badge  Famous Question (source)
2019-07-30 10:47:49 +0100 marked best answer Differential forms and tensors

Dear all,

A long time ago I was trying to implement a SAGE code for working with Differential Forms with values in a certain Lie algebra, but due to my lack of programming knowledge, I couldn't.

This kind of objects are important for working with non-Abelin gauge theories.


Is it possible to define and work with those objects?

So far there is no reference of it in the manual.

Thank you!

2019-05-20 14:11:07 +0100 marked best answer Size of Labels on a Plot

dear all:

I'd like to know if there is any way to change the size of the font of labels (in a plot) without changing the size of the numbers on the ticks.

Thank you

2019-05-20 14:02:27 +0100 received badge  Famous Question (source)
2019-05-17 21:46:48 +0100 commented answer Restricting a variable to a (real) range

Thank you @dsejas Yes, your comment was incredible useful! It drove me to a nice solution. Since I had a lot of assumptions, I was trying to find a way to drop the last assumption (still don't know it possible), and looking for that I found the with assuming(condition): code statement, which execute the code assuming the condition without registering in the assumptions() list! Thank you very much!

2019-05-17 16:18:03 +0100 asked a question Restricting a variable to a (real) range

Hi. I'm solving a differential equation which depends on two parameters $c1$ and $c2$. They are both positive

assume(c1 > 0)
assume(c2 > 0)

but in order to solve the equation, maxima ask me whether c2-3 is positive, negative or zero. With the condition

assume(c2 - 3 > 0)

the equation is solved; But imposing c2 - 3 < 0 triggers and inconsistency... I believe that it is due to the initial assumption.


Is it possible to set a condition like assume(0 < c2 < 3)?

2019-05-14 09:41:24 +0100 asked a question Solving an ODE and simplifying the result

I'm interested in solving the differential equation $$3 h' + 3 h^2 = c_1,$$ where $c_1$ is a positive real number.

var('c1', latex_name=r'c_1')
h = function('h')(t)
eq = -3*h^2 + c1 - 3*diff(h, t)
eq_sol = desolve(eq, h, ivar=t, contrib_ode=True)

The above code works, but it's not solved explicitly for $h$, so

h_sol = solve(eq_sol, h)
h_sol = h_sol[0]

This gives something like $$h\left(t\right) = \frac{\sqrt{3} \sqrt{c_{1}} {\left(e^{\left(\frac{2}{3} \, \sqrt{3} C \sqrt{c_{1}} + \frac{2}{3} \, \sqrt{3} \sqrt{c_{1}} t\right)} + 1\right)}}{3 \, {\left(e^{\left(\frac{2}{3} \, \sqrt{3} C \sqrt{c_{1}} + \frac{2}{3} \, \sqrt{3} \sqrt{c_{1}} t\right)} - 1\right)}},$$

in sage notation (non-LaTeX) it starts like

h(t) == 1/3*sqrt(3)*sqrt(c1)* ...

Question 1: Is there a way to allocate to the solution (i.e. h_sol) the RHS of the above? without the h(t) == part.

I had to set by hand (it is ease, but it would be nice to automatize the allocation)

var('C')    # the integration constant introduced above
h_sol = 1/3*sqrt(3)*sqrt(c1)* ...

Then, by simply looking at the solution it is clear that it can be simplified. I tried things like

h_sol = h_sol.canonicalize_radical()
h_sol = h_sol.collect_common_factors()
h_sol = h_sol.simplify_rectform(complexity_measure = None)

but none of them returns the expected result, which could be obtained from Mathematica's kernel

mathematica("DSolve[3*h'[t] + 3*h[t]^2 == C[1], h[t], t]//FullSimplify")

$$ \sqrt{\frac{c_1}{3}} \tanh\left( \sqrt{\frac{c_1}{3}} (t - 3 c_2) \right) $$

Question 2: How could the expression h_sol be manipulated to obtain the hyperbolic tangent?

2019-02-08 13:26:30 +0100 received badge  Popular Question (source)
2018-12-04 09:18:37 +0100 asked a question Sagemanifold - Connection components from a tensor (not a metric)

Dear community.

This might sound dump, but I'm trying to determine whether a tensor satisfy the properties of a metric (under certain conditions). Of course it is a (0,2)-symmetric tensor, call it $S$, but I cannot (to my understanding) calculate the (Levi-Civita-like) connection components that would be associated to $S$... unless I declare it as a metric.

The way it is implemented makes sense... and it's solid!

What I did...?

I defined like a metric and calculate the associated connection (and curvatures)

Why should I do something else?

In the file src/sage/manifolds/differentiable/ the metric is defined (as it should) to be symmetric, but it does not allow to consider extensions of General Relativity like say Einstein--Strauss model. Thus, I need an instance to calculate the derived quantities of a tensor that is a generalization of a metric.


Is this possible?

2018-12-04 08:34:54 +0100 commented answer How to get the collection of all functions from X to Y in SageMath

Thanks for the theory!

2018-12-03 22:15:00 +0100 received badge  Nice Question (source)
2018-12-03 19:20:48 +0100 commented answer Subtitute functions - in a differential equation - Sagemanifold

hehehehe... Thank you again! I almost got it... but I tried .expression().

2018-12-03 19:18:05 +0100 commented answer Sagemanifold - `only_nonredundant = True` by default

Excellent! Thank you for the answer, and a wonderful use of the lambda function!

2018-12-03 18:37:06 +0100 asked a question Sagemanifold - `only_nonredundant = True` by default

Hi, I find the option only_nonredundant=True really helpful, but it is annoying to type over and over the option on the notebook. Is it possible to define the option globally (within a notebook)?

2018-12-03 18:33:37 +0100 asked a question Subtitute functions - in a differential equation - Sagemanifold

Dear community,

I have a differential equation that depends on a function $\xi(t)$, but is a component of a tensor (calculated with sagemanifold)

M = Manifold(4, 'M', latex_name=r"\mathcal{M}")
U.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
xi = function('xi')(t)
f = function('f')(t)
h = function('h')(t)
g = function('g')(t)
Ric = M.tensor_field(0,2, 'Ric')
Ric[0,0] = 3/2*f*h - 3/4*h^2 + 3/2*f*xi + 3/4*xi^2 - 3/2*diff(h, t) - 3/2*diff(xi, t)

I'd like to define the restriction to $\xi = 0$, and assign it to a new tensor

Ric0 = M.tensor_field(0,2, 'Ric0')
Ric0[0,0] = Ric[0,0].substitute_expression({xi:0, diff(xi, t):0})

but I get an AttributeError because the

AttributeError: 'ChartFunctionRing_with_category.element_class' object has no attribute 'substitute_expression'

I know that it works for functions

xi = function('xi')(t)
f = function('f')(t)
h = function('h')(t)
ode = 3/2*f*h - 3/4*h^2 + 3/2*f*xi + 3/4*xi^2 - 3/2*diff(h, t) - 3/2*diff(xi, t)
ode0 = ode.substitute_expression({xi:0, diff(xi, t):0})


Is there a way to substitute functions that are not 𝚜𝚊𝚐𝚎.𝚜𝚢𝚖𝚋𝚘𝚕𝚒𝚌.𝚎𝚡𝚙𝚛𝚎𝚜𝚜𝚒𝚘𝚗.𝙴𝚡𝚙𝚛𝚎𝚜𝚜𝚒𝚘𝚗 but ChartFunctionRing_with_category.element_class?

2018-11-28 22:16:13 +0100 commented question Sagemanifold: autoparallel curve equations

Currently I am not at work, I'll upload it tomorrow. Thanks for the interest.

2018-11-28 19:14:55 +0100 received badge  Organizer (source)
2018-11-28 19:13:43 +0100 asked a question Sagemanifold: autoparallel curve equations

Hello community.

I'm interested in calculating the autoparallel curves defined by an affine connection (it has torsion). Following the recipes from the documentation notebooks in the sagemanifold web page I've achieved the goal with ease. However, in the result there is a function $h$, which is related with the torsion of the connection, shows up in the definition of the curve.

I expected this function not to show... because one usually argue that the contribution of the antisymmetric part of the connection to the geodesic (or autoparallel in this case) vanishes, based in symmetry arguments (it is contracted with a symmetric tensor).

Is the fact that I'm getting a contribution of the torsion in the equations a mistake in the algorithm of the curve equation or is a personal misunderstanding?

2018-11-26 13:26:42 +0100 marked best answer Assignation of components of a differential form (or multivector field) in sagemanifold

Dear all. I've crossed with the task of assigning components to a multivector field, and it's tedious! (specially higher ranks)

Question: Is there an efficient way of assigning components to tensors with symmetries?