Sage

      Comments Off on Sage

Description

Sage is a powerful and versatile open-source mathematical software designed for mathematicians and researchers. It provides a wide range of tools for performing symbolic and numerical computations, solving problems in algebra, differential calculus, number theory, and much more. Sage integrates multiple systems for symbolic and numerical computation, thus providing a unified platform to address a wide variety of mathematical needs. Sage serves as a tool for exploring and solving complex mathematical problems.

Set up the environment and version

ml math/sagemath

Available versions : 10.2 (default)

Tutorials

Some tutorials

Lancement

  • Load the math/sagemath module then typ the command sage
  • The DeprecationWarning does not affect the proper functioning of the software.
  • To exit, typ the command quit

Addition et factorisation

$ ml math/sagemath/10.2
$ sage
...
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.2, Release Date: 2023-12-03 │
│ Using Python 3.11.1. Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: 2+3
5
sage: factor(1234567891011121314151617181920212223242526272829303132333435363738
….: )
2 * 3 * 86893956354189878775643 * 2367958875411463048104007458352976869124861

Example of a script solving a system of equations

  • Example file solving_equations.sage
var('x y p q')
eq1 = p+2*q==9
eq2 = q*y+p*x==-6
eq3 = q*y^3+p*x^2==24
print(solve([eq1,eq2,eq3,p==1],p,q,x,y))
  • Note the print function to display the results

Running a Sage calculation

  • Job launch script sage_job.sh
#!/bin/sh
#SBATCH --job-name=sage
#SBATCH --partition=normal		# submission queue
#SBATCH --output=job_sage%j.out       
#SBATCH --error=job_sage%j.err 

module load math/sagemath
sage solving_equations.sage
  • Launching the computation
sbatch sage_job.sh

Documentation