7.5 sagemath hints

To download latest stable release use https://mirrors.mit.edu/sage/src/index.html.

To download development releases use https://www.sagemath.org/download-latest.html

To build do

unset SAGE_ROOT 
unset SAGE_LOCAL 
 
#Do this to force sage to use system's before building sage 
 
export GIAC=/usr/local/bin/giac 
export MAXIMA=/usr/bin/giac 
 
#Now do (to build with newer python), make sure to tell it to 
#use system giac, which I installed before, since it is newer 
#version. see my giac notes on how to install giac 
 
./configure --with-system-python3=no --with-system-giac=force 
make 
make install
 

To obtain version numbers of installed CAS systems do (see also https://ask.sagemath.org/question/42617/how-to-find-version-number-of-cas-used-by-sage/

 
>sage 
 
    SageMath version 9.8, Release Date: 2023-02-11 
    Using Python 3.11.1. Type "help()" for help. 
 
#ignore this, since I install maxima manually outside sage 
age: ver = installed_packages() 
sage: ver['maxima']  #WRONG. version. I have deleted maxima used by sage 
'5.45.0.p0' 
 
 
#use this below, since I installed maxima outside sage. 
#but make sure to remove the maxima's binaries installed by sage from its local/bin 
#after installing external maxima and do the following 
#         >cd $SAGE_ROOT/local/bin 
#         >rm rmaxima 
#         >rm maxima 
#         >rm xmaxima 
 
#         >ln -s /usr/bin/rmaxima 
#         >ln -s /usr/bin/maxima 
#         >ln -s /usr/bin/xmaxima 
 
#now do this to get the correct version of the external maxima used 
 
sage: print(maxima.version()) 
5.46.0 
 
#to install fricas, use the command 
#     > sage -i fricas 
#AFTER installing sagemath 
 
sage: print(fricas.eval(")lisp |$build_version|")) 
Value = "FriCAS 1.3.8" 
 
#this will now print the version by external giac since we asked 
#sage to use system giac before 
 
sage: print(giac.version()) 
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I" 
 
age: gap.version() 
'4.11.1' 
 
sage: pari.version() 
(2, 15, 2) 
 
sage: gp.version() 
((2, 15, 2), 'GP/PARI CALCULATOR Version 2.15.2 (released)')
 

To enter an ode do

age: x = var('x') 
sage: y = function('y') 
sage: ode=diff(y(x),x)+y(x)==sin(x) 
 
sage: ode 
y(x) + diff(y(x), x) == sin(x)
 

To obtain lhs and rhs of equation

age: ode.lhs() 
y(x) + diff(y(x), x) 
sage: ode.rhs() 
sin(x)
 

To use sagemath to solve ODE

x = var('x') 
y = function('y') 
 
sage: desolve(diff(y(x),x,2) + y(x) ==0, y(x),algorithm='fricas') 
_C0*cos(x) + _C1*sin(x) 
 
sage: desolve(diff(y(x),x,2) + y(x) ==0, y(x),algorithm='maxima') 
_K2*cos(x) + _K1*sin(x)
 

To check if integral evaluated or not, do

var('x') 
sage: anti=integrate(sqrt(1+x^3),x) 
 
sage: anti 
integrate(sqrt(x^3 + 1), x) 
 
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral) 
 
True
 

To simplify, use  expr.full_simplify()

to find what methods are there for some expressions to appy to, type expr.<TAB> i.e. hit TAB key after the dot.

see help on http://doc.sagemath.org/html/en/genindex.html

see http://doc.sagemath.org/html/en/tutorial/programming.html