\documentclass{beamer}
\usepackage{comment}
\usepackage{fancybox}
\usepackage{beamerarticle}
\usepackage[utf8x]{inputenc}
\mode<presentation>
{
  \usetheme{Rochester}
 \usecolortheme{crane}
% \usecolortheme{seahorse}
 \setbeamercovered{transparent}
  % or whatever (possibly just delete it)
}
\usepackage{ngerman}

\title{Sage Days 24: The Development of Symbolic Calculus in Sage}
\date{July 17, 2010}
\author{William Stein}

%\newcommand{\todo}[1]{[[#1]]}
\newcommand{\todo}[1]{}

\begin{document}
\maketitle
%\tableofcontents 

\begin{frame}
\frametitle{Goals for this workshop}

{\small ``Ask not what Sage can do for you, but what you can do for Sage.''}
    \begin{enumerate}
      \item {\bf Goals for newbies.  Learn to:}
        \begin{itemize}
          \item Install Sage,
          \item Navigate the documentation,
          \item Understand basic structure of the source code,
          \item Program in Python and Cython,
%\footnote{A Python compiler that natively supports C data types.}, 
and
          \item Improve Sage, then submit patches for review.
        \end{itemize}
      \item  {\bf Goals for developers:}
        \begin{itemize}
           \item Get function fields into Sage (trac \#9054 and related).
           \item Update Sympy and polish the Sage/Sympy interface.
           \item Special functions.
           \item Piecewise functions.
           \item Runtime addition of attributes to symbolic expressions.
           \item Clashing of variable names with Maxima.
           \item Easy access to ripping apart symbolic expressions
           \item C library interface to Maxima.
        \end{itemize}
   \end{enumerate}
\end{frame}

\begin{frame}
\vfill
\begin{center}
\LARGE\bf Part 1: The Past
\end{center}
\vfill
\end{frame}


\begin{frame}    
\frametitle{Background: The Goal of the Sage project}

\begin{center}
{\bf\Large Create a viable free open source alternative to Magma, Maple, Mathematica, and Matlab}
\end{center}

\vfill A viable alternative will have:
    \begin{itemize}
       \item All the {\em mathematical features} of Magma, Maple,
          Mathematica, and Matlab with {\em comparable (or better) speed},
          including sophisticated symbolic calculus, special functions,
          global fields, easy of use and documentation.
       \item Beautiful interactive 2d and 3d graphics.
       \item A notebook interface and an IDE.
       \item Commercial support (including customized notebook servers)
       \item Many undergraduate books (e.g., Zimmerman et al.!)
     \end{itemize}    

     Sage does {\em not} need to be able to run programs written in
     the Ma*'s own custom math-only languages.  Sage 'aint Octave.

\end{frame}


\begin{frame}[fragile]
\frametitle{2005: I started the Sage project}
   \begin{center}
   \bf
    SAGE = Software for \underline{Arithmetic Geometry} Experimentation
  \end{center}

\begin{itemize}  
\item I want an {\em open} alternative to Magma {\bf \underline{(ask me why)}}, and I
  have an extensive research program I've built on it over 6 years.
  David Joyner (coding theorist) has similar concerns.

\item In 2005 -- number theory and some coding theory (GAP) -- no
  Symbolic Calculus.
\end{itemize}

\vfill
{\small
\begin{verbatim}
sage: E = EllipticCurve('389a'); E
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x
sage: E.gens()
[(-1 : 1 : 1), (0 : -1 : 1)]
\end{verbatim}

%sage: G = matrix(GF(5),4,7,[1,1,1,0,0,0,0,1,0,0,1,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,1])
\begin{verbatim}
sage: G = matrix(GF(5),4,7,[1,1,1,0,0,0,0,1,0,0,1,1,0,0,0,1,0...
sage: C = LinearCode(G); C
Linear code of length 7, dimension 4 over Finite Field of size 5
sage: C.minimum_distance()
3
\end{verbatim}
}
\end{frame}

\begin{frame}
\frametitle{(Why not Magma?)}
\begin{enumerate}
\item Commercial: Expensive for my collaborators and students
\item Closed: Magma's implementation of algorithms a trade secret
\item Frustrating: Tight control by John Cannon
\item Static: Users can't define their own classes (data
  types)
\item Copy protection: A pain in the ass.
\item Language: No {\tt eval}, no exception handling, no
  namespaces, little new development on the language, math-only language.
\item Developer community: far too small, no public mailing list
\item No graphics, no symbolic calculus, no graphical user interface.
\item No public bug tracker or list of reported bugs
\item No compiler (nothing like Cython)
\item ...
\end{enumerate}
(Similar remarks about Maple.)
\end{frame}

\begin{frame}[fragile]
\frametitle{2006: Maxima/Sage interface}

\begin{itemize}
\item I taught Calculus (in San Diego) during this time, and used Maxima +
  GNUplot for demos, and for plots in lecture notes.
\item I integrated Maxima into Sage. 
\item David Joyner  wrote {\em Sage Constructions} -- examples of
  how to do Calculus using the Sage/Maxima interface.
\end{itemize}

\begin{verbatim}
sage: f = maxima('1/sqrt(x^2+2*x-1)')
sage: f.integrate(x)
log(2*sqrt(x^2+2*x-1)+2*x+2)
sage: maxima.plot2d('cos(2*x) + 2*exp(-x)','[x,0,1]',
                    '[plot_format,openmath]')
[[a plot appears]]
\end{verbatim}

\end{frame}

\begin{frame}[fragile]
\frametitle{2007: Bobby Moretti (UW undergraduate)}
\todo{photo of bobby}
\begin{itemize}
\item 2007: Bobby Moretti (UW undergraduate):
  wrote a pure Python + Maxima symbolic Calculus package.  
\item Idea and implementation was Bobby's from start to finish
\item Made Sage an option for Calculus
  classes, but too slow compared to Ma* and not
  flexible enough.
\end{itemize}
{\small
\begin{verbatim}
sage: f = 1/sqrt(x^2 + 2*x - 1); f
1/sqrt(x^2 + 2*x - 1)
sage: f.integrate(x)
log(2*x + 2*sqrt(x^2 + 2*x - 1) + 2)
\end{verbatim}
}
\end{frame}

\begin{frame}[fragile]
\frametitle{2008: Gary Furnish (Utah undergraduate): New Symbolics!!}
\begin{itemize}
\item 2008: Gary Furnish: another undergrad, tried to completely
  rewrite symbolic calculus in Cython.
\item Wrote a lot of Cython code, which lacked a sufficiently mature
  foundation, so we didn't end up using it.
%\item Kept other people from working on symbolics:
%\begin{itemize}
%\item
%``With the symbolics rewrite moving quickly, I'd like to request that if
%possible people try to avoid adding ...'' 
\vfill
\begin{quote}
``Ugly performance enhancing software hacks are often
  needed to make theoretical algorithms viable.'' -- Gary Furnish, sage-devel, 2008-05-01.
\end{quote}
% \end{itemize}
\end{itemize}
\begin{center}
\includegraphics[width=.4\textwidth]{gfurnish}
\end{center}

%\begin{verbatim}
%...
%segfault
%\end{verbatim}
\end{frame}
 
\begin{frame}[fragile]
\frametitle{2008--2009: GiNAC/Pynac}

\todo{issac photo}
\begin{itemize}

\item July 2008: ISSAC -- during the boat trip, Burcin suggested
  investigating integrating {\bf GiNAC} into Sage.

\item Big problem: GiNAC depends on the huge C++ CLN library (basic
rings/fields arithmetic), which takes a long time to build, and
provides nothing that isn't already in Sage.

\item Aug 2008: I wrote the first version of Pynac during an intense
  two week coding sprint in San Diego.   

\begin{center}
\shadowbox{
\begin{minipage}{.8\textwidth}
  {\bf Key Idea:} Rip out the CLN dependence of GiNAC and replace it
  by Sage/Python.  Amazingly, this  worked.
\end{minipage}
}
\end{center}

\item Pynac is a low level C++ library that depends on Sage/Python and
  provides fast symbolic arithmetic.  No integration, series, or other
  high level algorithms.

\end{itemize}

\end{frame}


\begin{frame}[fragile]
\frametitle{Aug 2008 -- May 2009: Build complete new symbolic system in Sage on Pynac}
\begin{itemize}
\item Finish Pynac and build a new fast symbolic system on top: Burcin
  (mostly) + Mike Hansen + Carl Witty + Robert Bradshaw + Nick Alexander + me + $\cdots$

\item This is the main new feature of Sage-4.0.

\item Maxima is still used for some things, e.g., symbolic
  integration, some comparisons, etc.
\end{itemize}
{\small 
\begin{verbatim}
sage: f = 1/sqrt(x^2 + 2*x - 1); f
1/sqrt(x^2 + 2*x - 1)
sage: timeit('f*f')
625 loops, best of 3: 83.5 µs per loop
sage: g = maxima(f)
sage: timeit('g*g')
125 loops, best of 3: 1.41 ms per loop
sage: 1.41/.0835
16.8862275449102
\end{verbatim}}

\end{frame}


\begin{frame}
\frametitle{May 2009 - today: Further development}
\begin{itemize}
\item May 2009 - today: Burcin (mostly) has further developed symbolics in Sage

\item Pynac has been very stable (hardly any changes needed).

\item Nils Bruin (and Robert Bradshaw): A new C library interface to Maxima.

\end{itemize}
\todo{nils photo}

\end{frame}

\begin{frame}[fragile]
\frametitle{Sympy: a standalone pure Python symbolic calculus library}
\todo{ondrej c photo}

Sympy is a Python project mainly by Physics,
Engineering, and Science students...
\begin{itemize}
\item 2005: Sympy project started by Ondrej Certik (physics undergraduate at the time)
\item 2007?: Sympy included in Sage
\item They have many very hard working developers.
\end{itemize}
\begin{center}
\includegraphics[width=.6\textwidth]{sympy} 
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{Unflattering Demo of using Sympy in Sage}
\small\begin{verbatim}
sage: var('x')
sage: f = 1/sqrt(x^2 + 2*x - 1); f
1/sqrt(x^2 + 2*x - 1)
sage: time f.integrate(x)
log(2*x + 2*sqrt(x^2 + 2*x - 1) + 2)
Time: CPU 0.01 s, Wall: 0.02 s
sage: f.integrate(x, algorithm='sympy')
Traceback (most recent call last):
AttributeError: 'Integral' object has no attribute '_sage_'

sage: from sympy import sqrt, integrate, var
sage: x = var('x')
sage: f = int(1)/sqrt(x**2 + 2*x - 1); f
(-1 + 2*x + x**2)**(-1/2)
sage: time f.integrate(x)
Integral((-1 + 2*x + x**2)**(-1/2), x)
Time: CPU 0.64 s, Wall: 0.65 s
\end{verbatim}


\end{frame}




\begin{frame}
\vfill
\begin{center}
\LARGE\bf Part 2: The Future
\end{center}
\vfill
\end{frame}

            
\begin{frame}
\frametitle{Roadmap of Sage project}
\todo{photo of a roadmap from google images}
 \begin{itemize}
       \item  Sage-5.0 (2010)
       \item  Sage-6.0 (2011)
       \item Sage-7.0 (2012)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Roadmap of Sage project}
 \begin{itemize}
       \item  Sage-5.0 (August 31, 2010)
           \begin{itemize}
                \item  Windows port via Cygwin
                \item  Upgrade PARI to the latest SVN version
                \item  Upgrade MPIR to version 2.x 
                \item  Get doctest coverage to 90\% (currently at 84.6\%)
           \end{itemize}
\item Sage-5.x (rest of this year...)
\begin{itemize}
                \item  Function fields (Hess's algorithms, 2-descent, L-functions)
                \item Special functions: support everything in the DLMF:
              \begin{itemize}
                  \item arbitrary precision numerical evaluation (mpmath)
                  \item series expansion
                  \item differentiation
                  \item shifts (difference analogue of differentiation)
              \end{itemize}
               \item Symbolic summation
               \item Symbolic integration (Risch-Norman algorithm)
               \end{itemize}
             \item  Sage-6.0 (2011)
       \item Sage-7.0 (2012)
\end{itemize}
\end{frame}


\begin{frame}
\frametitle{Roadmap of Sage project}
 \begin{itemize}
       \item  Sage-5.0 (August 31, 2010).  
       \item  Sage-6.0 (2011), some potential goals:
 \begin{itemize}
              \item Noncommutative symbolic computation (Plural, Weyl Algebras, Graded algebras, Lie algebras).
              \item Much improved Sage notebook (scalability, customizability)
                \item Textbooks, interacts, etc., integrated with the sage distribution
                \item Commercial support (custom notebook servers) 
                \item Fully switch to using C library interfaces for GAP and Maxima.
                \item Get doctest coverage to 100\%
                \end{itemize}
\item Sage-7.0 (2012)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Roadmap of Sage project}
 \begin{itemize}
       \item  Sage-5.0 (August 31, 2010).  
       \item  Sage-6.0 (2011):
       \item Sage-7.0 (2012), some potential goals:
 \begin{itemize}
                \item Fast Groebner basis computation that is competitive with Magma/Maple
                \item Vast improvements in Sage for Science and Engineering (documentation, diff'eq,
                  data workflows, reproducible research, instrument support, data formats like HD5)
                \item Statistics: something Pythonic/Cythonic and built on
                  top of R + scipy.stats + GSL, which competes with
                  SAS, etc. 
                \item Switch to Python 3.x
                \item Much randomized and unit testing that goes beyond doctesting
\end{itemize}
\end{itemize}
\end{frame}

 
        

\begin{frame}
\vfill
{\bf ... World Domination}
\vfill
Any questions?
\end{frame}         

 
                
                
                    
                

\end{document}











%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
