Ask Your Question
0

interfaces of SageMaths

asked 2022-03-01 09:01:31 +0200

ErWinz gravatar image

hi

as i can not use SageMaths with jupyter (my other post) i am searching something else

here : link text

it is written :

Pour utiliser ce script, votre répertoire SAGE_ROOT doit apparaître dans la variable d’environnement PATH.

i see how to modify $PATH within the temrinal but what is SAGE_ROOT

in the same page i have typed SAGE_ROOT in the "quick research" field but it gave no result

my aim is to run a python/sage script like this one :

#!/usr/bin/env sage

import sys
from sage.all import *


f(x,y)=(-x)/(1+y)+2*x
show(html("<h4>*************</h4>"))    

# calculs généraux
from sage.manifolds.operators import *
E.<x,y> = EuclideanSpace()
F = E.scalar_field(f)
H=f(x,y).hessian()
show(html("<h5>paramètres généraux</h5>"))
T=table([["f",f],["grad f=",grad(F)[:]],["H=",H]],frame=True,align='center')
show(T)

# calcul des points critiques
Cr= solve([grad(f)[0]==0,grad(f)[1]==0],[x,y],solution_dict=True)
liste=[]
for critique in Cr:
    x_et_y_reels=(x(critique).imag()==0 and y(critique).imag()==0)
    x_et_y_avec_parametre=(len(x(critique).variables())>0 or len(y(critique).variables())>0)
    if(x_et_y_reels or x_et_y_avec_parametre): 
        liste.append(["(","x","=",x(critique),";","y","=",y(critique),")",H(critique)])        
show(html("<h5>points critiques</h5>"))
if (len(liste)!=0):
    show(table(liste))
else :
    show("pas de points critiques")

# graphique
h(x,y,z)=f(x,y)-z
implicit_plot3d(h, (x, -1,4), (y, -4, 4), (z, -4, 3),color="green",adaptive=True,mesh=True,region=lambda x,y,z: y<=-1.1 or y>=-0.96)
edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
0

answered 2022-03-01 13:33:20 +0200

ErWinz gravatar image

updated 2022-03-01 14:09:26 +0200

hi and thanks for your answers i made this :

(--) sage -sh -c 'echo $SAGE_ROOT'
/Applications/SageMath-9-5.app/Contents/Frameworks/Sage.framework/Versions/9.5
(--) export PATH=/Applications/SageMath-9-5.app/Contents/Frameworks/Sage.framework/Versions/9.5:$PATH

now, the programm as typed below gives this error :

    f(x,y)=(-x)/(1+y)+2*x
    ^
    SyntaxError: cannot assign to function call

my interpretation is that this syntax is not recognized as sage syntax ; indeed it is not a python syntax ; i guess that the sage interpretor is not called ; what shall i do ?

for info, the which command gives :

   (--) which sage
   /usr/local/bin/sage
edit flag offensive delete link more

Comments

This is a different problem, please have a look at the Sage preparser : https://doc.sagemath.org/html/en/refe...

tmonteil gravatar imagetmonteil ( 2022-03-01 14:56:27 +0200 )edit

Quand on télécharge Sage-macOS, l'image disque .dmg contient

  • l'application à faire glisser dans /Applications, mais aussi
  • un paquet "recommended.pkg" qui permet entre autres de
    • mettre un lien symbolique sage dans le PATH (plus besoin de export PATH=...)
    • installer le noyau Jupyter de Sage

Je recommande de double-cliquer l'installeur "recommended.pkg".

slelievre gravatar imageslelievre ( 2022-03-01 22:55:13 +0200 )edit
1

answered 2022-03-01 13:15:14 +0200

slelievre gravatar image

L'indication

Pour utiliser ce script, votre répertoire SAGE_ROOT doit apparaître dans la variable d’environnement PATH.

pourrait être remplacée par

Pour utiliser ce script, il faut que l'exécutable sage soit quelque part dans votre PATH.

Pour le vérifier, ouvrir un terminal et lancer la commande

$ which sage

Si rien ne s'affiche, changer de dossier de travail vers celui où est installé Sage, et lancer cette commande:

$ ln -sf $(pwd)/sage /usr/local/bin
edit flag offensive delete link more
1

answered 2022-03-01 09:39:21 +0200

tmonteil gravatar image

SAGE_ROOT stands for the base directory of your Sage installation. If you do not know where it is, you can do:

in a shell:

sage -sh -c 'echo $SAGE_ROOT'

in a Sage session:

sage: import os
sage: os.environ['SAGE_ROOT']
edit flag offensive delete link more

Comments

In a Sage session you can just do

sage: print(SAGE_ROOT)

In a shell you can also do

$ sage -c 'print(SAGE_ROOT)'

but that starts Sage, so your sage -sh -c 'echo $SAGE_ROOT' is better.

slelievre gravatar imageslelievre ( 2022-03-01 11:39:11 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-03-01 09:01:31 +0200

Seen: 149 times

Last updated: Mar 01 '22