Lecture 1: Welcome! =================== In this first lecture we define computer algebra and sketch the organization of the course. The most important aspect of this lecture is to get started with the notebook interface in SageMath. We can run SageMath in a terminal window, in the cell server, in a notebook, or in the cloud. Our running computation involves the symbol ``pi`` which SageMath recognizes as the mathematical constant \ :math:`\pi`. The lecture ends with finding out which system performs a particular calculation. What is Computer Algebra? ------------------------- :index:`Computer Algebra` is the discipline that studies the algorithms for Symbolic Computation. In :index:`Symbolic Computation`, one computes with symbols, rather than with numbers. In this course we are mostly concerned with the practical aspects of Symbolic Computation, in particular its implementation and its application to solve practical mathematical problems. The lecture notes are organized in four parts: 1. First steps with SageMath 2. Polynomials and rational expressions 3. Functions and Calculus 4. More Advanced SageMath 5. Some Components of SageMath What is SageMath? ----------------- The original name :index:`Sage` was short for Software for Algebra, Geometry, and Experimentation. Later, SAGE became :index:`Sage` and now we refer to :index:`SageMath`. Below are some important points about SageMath: * SageMath is released as free and open source software under the terms of the GNU General Public License. * As scripting language, SageMath uses Python. SageMath has a large, active developers community. * By design, SageMath does not reinvent the wheel, but bundles various powerful free and open source mathematical software systems, such as GAP, Maxima, R, Singular, sympy, numpy, scipy, etc. This design principle is visualized in :numref:`figsagecar`. The figure is copied from [BS10]_. .. _figsagecar: .. figure:: ./figsagecar.png :align: center The motto of SageMath: building the car instead of reinventing the wheel. * Try it without installing, via the :index:`SageMath Cell Server`: https://sagecell.sagemath.org/, or with :index:`CoCalc`: https://cocalc.com. Running SageMath ---------------- There are two main modes to run SageMath: * In a terminal window, which is similar as using the command line interface to interactive software systems. This works fine for short calculations, when the right commands are knows in advance. * The notebook interface runs in a web browser. The help gives direct access to the reference manual and other documentation. The notebook interface is natural with cloud computing. A terminal session with SageMath :: sage: pi pi sage: sin(pi) 0 sage: '%.14e' % pi '3.14159265358979e+00' sage: type(_) sage: type(pi) sage: p = plot(sin,(-pi,+pi)) sage: p For a more interesting plot, consider the sine function with a decaying amplitude, as defined by ``exp(-x^2)*sin(8*x)``. As a computer algebra system, Sage is mainly for symbolic computation. For its numerical computations, we are not limited to the hardware machine arithmetic. For example, to see the decimal expansion of :math:`\pi` with 20 decimal places: :: sage: pi20 = pi.n(digits=20) sage: pi20 3.1415926535897932385 sage: sin(pi20) 6.5640070857470010853e-22 sage: type(pi20) Unlike the exact value for :math:`\pi`, the value of ``sin(pi20)`` is no longer zero. In the SageMath Cell Server to plot the sine function, we can enter: :: var('x') plot(sin(x), (-pi, pi)).show() When running the notebook interface, we can document our computations with text that follows the # symbol. Which systems in SageMath are used? ----------------------------------- Sage is built out of several :index:`systems`. If you are curious to see which software package executed your calculation, you could proceed as follows: .. index:: get_systems :: sage: from sage.misc.citation import get_systems sage: get_systems('Rational(0.75)') ['MPFR'] sage: get_systems('RealField(10)(pi)') ['MPFR', 'ginac'] sage: import sage.misc.citation sage: help(sage.misc.citation) sage: sage.misc.citation.systems.keys() Assignments ----------- 1. Go to http://www.sagemath.org/tour.html and take the Feature tour. After taking this tour, write a couple of sentences (one paragraph long) about what interests you most. 2. Create an account on CoCalc, at https://cocalc.com, and make a notebook with calculations from this lecture. 3. If there is sufficient disk space available on your home computer or laptop, consider installing SageMath from source. On Linux systems, you should not do this installation as root, but as an ordinary user. 4. Which system executes the statement ``pi.n(digits=20)``? .. raw:: latex \cleardoublepage \begingroup \renewcommand\chapter[1]{\endgroup} \phantomsection .. _refs: References ---------- .. [BS10] B. Erocal and W. Stein: The Sage project: Unifying free mathematical software to create a viable alternative to Magma, Maple, Mathematica, and MATLAB. In *Mathematical Software - ICMS 2010*, Springer-Verlag, 2010.