Ask Your Question

sagenotdead's profile - activity

2023-02-04 00:51:32 +0200 received badge  Popular Question (source)
2020-05-27 17:16:56 +0200 received badge  Famous Question (source)
2020-01-05 23:14:49 +0200 received badge  Notable Question (source)
2019-11-09 21:36:45 +0200 received badge  Popular Question (source)
2019-05-24 19:10:20 +0200 asked a question From numerical variables to symbolic variables

I would like to define an Hamiltonian dynamics that I will integrate later using scipy.integrate. The Hamiltonian is computed with a symbolic expression and then I need to make substitution from the symbolic variables to the numerical variables.

N=2
var('q1 q2')
var('p1 p2')

zs = [q1,q2,p1,p2]

def dynq(t,z):
    H = p1*(q1^2+1/3*q2^2) + p2*(cos(q1)-2*sin(q2*q1)^2)
    jacHp = jacobian(H,tuple(ps))
    dqdt = list(jacHp[0])
    dqdt[0].subs({zs[i]:z[i] for i in range(0,2*N)})
    dqdt[1].subs({zs[i]:z[i] for i in range(0,2*N)})
    print(dqdt)
    return dqdt

I call dynq(0.,[1.,0.5,4.,2.]) and the output is

[q1^2, -2*sin(q1*q2)^2 + cos(q1)]

so q1,q2,p1,p2 are still in the expression and are not replaced by the numerical values of the list $z$.

2019-05-16 16:47:53 +0200 asked a question Rational power of a negative real

I read here https://ask.sagemath.org/question/107... that

(-8)^(1/3) is supposed to be complex. You cannot have real cube root for -8.

Yet in mathematics, you can define the function $x\mapsto x^{1/q}$ for $x<0$ as soon as $q$ is odd.

In matlab, you can compute with nthroot(-8,3) which yields -2. Is it possible to have such computations in Sage ?

I defined this function:

def nroot(x,q):
    return x.sign()*(abs(x)**(1/q));
2019-03-17 15:54:09 +0200 asked a question Upgrade sagemath to the latest stable version

I am running a debian distribution. I downloaded a precompiled and preconfigured sage math archive available here:

http://sage.mirror.garr.it/mirrors/sa...

The installation is a success and sagemath works perfectly.

What if I need to upgrade this version to the latest stable version in the future ? Can I avoid to do the same process and download the complete new archive or can I use "git pull" inside my installation directory (which is a git repository) ?

I tried "git pull" but I was about to install the unstable version of sagemath 8.7.beta7 which I don't want to use.

2019-03-17 15:07:52 +0200 asked a question Git Pull stable version

I am running debian strech linux distribution and I installed sagemath from source of this git repository: https://github.com/sagemath

I upgraded it after a "git pull" and install it again from the source.

Problem: I have an unstable version: SageMath 8.7.beta7

I would like to know if it's safe to pull the latest stable version and how to get it using "git pull".

More generally, how do you update automatically your sagemath ?

2019-01-19 14:42:20 +0200 asked a question Redefine Method in Sage class

I am using the a class to manipulate vector fields of $\mathbb{R}^n$. I am using an other convention on the lie brackets : to compute $XY=[X,Y]$ I have to enter $XY=-X.bracket(Y)$.

I would like to redefine the method "bracket()" so that I include this minus sign in the redefinition.

Of course I can each time put a minus sign in front all my definition or call Y.bracket(X) to compute [X,Y] but I don't want to use them (the display is then not adapted ...).

Here is my code

 from sage import *
   reset()

   def mybracket(A,B):
     return B.bracket(A)

   M.<x,y> = EuclideanSpace()
   X = M.vector_field(0,1-y*x^2, name='X')
   Y = M.vector_field(-(y-1),x, name='Y')

   YX = Y.mybracket(X)

AttributeError: 'VectorFieldFreeModule_with_category.element_class' object has no attribute 'mybracket'

Thanks

2019-01-03 16:09:29 +0200 received badge  Scholar (source)
2019-01-03 16:09:28 +0200 received badge  Supporter (source)
2019-01-03 15:50:48 +0200 received badge  Student (source)
2019-01-03 15:40:20 +0200 received badge  Editor (source)
2019-01-03 15:22:42 +0200 asked a question plot parametric curve from symbolic expressions

I would like to get the plot of the parametric curve $(x1(t),x2(t)$ for $t$ in $[0,1]$.

var('ts')

x1sol=vector([-cos(ts),sin(ts)])*exp(ts/2)

x11 = x1sol[0]

show(plot(x11(ts),x12(ts),(ts,0,1)))

I get the error: TypeError: unable to simplify to float approximation

I would like to avoid formulation as :

def x1(t): ....

2019-01-03 14:13:51 +0200 commented answer Documentation erratum

Ok it is. It seems very strange to have such alias (⊙_⊙')

2019-01-03 14:13:14 +0200 answered a question Documentation erratum

Ok it is. It seems very weird to have such alias (⊙_⊙')

2019-01-03 13:32:59 +0200 asked a question Documentation erratum

In the official documentation: doc.sagemath.org/html/en/reference/calculus/sage/symbolic/expression.html

the section related to the command "full_simplify()" should be renamed as "simplify_full()".