INTRODUCTION(Click here to return main page.)

1. Introduction and Use of Sage


Mathematical tools have long held an important place in the classroom. With the innovation of information and communication technologies(ICT), many tools have appeared and been adapted for educational purposes. Sage is popular mathematical software which was released in 2005. This software has efficient features which can be utilized through the Internet and can handle most mathematical problems, including linear algebra, abstract algebra, combinatorics, number theory, symbolic computation, numerical mathematics and calculus. In this book, we will introduce this powerful software and discuss how it can be used in classes.

Sage is a mathematical Computer Algebra System (CAS) that can be easily used online. The Sage notebook was released in April 2008 at University of Washington, USA. It is free and has powerful capabilities that can be compared with expensive commercial software such as Mathematica, Maple or Matlab. However, it does not require separate installation of the program. It is more like Web-Mathematica, but has some better features. When you connect with any web browser, you can solve almost all calculus problems in the book by using resources that we are offering. You can easily find pre-existing commands to modify for your own problems. The Sage notebook is a platform that allows you to interface with many open-source and commercial programs (if you have a license).

                                     Figure 1. Sage notebook can interface to many programs

Online Sage Servers:   (Sign in)  (ID: skku    Password: math)  (Make your own accounts)  (Mobile Server, No need for login)   (SKKU Sage Cell Server, Mobile, No need for login, Recommended  (University of Washington Sage Server)


                                        Figure 2. Sage Community (Left),

                                                       Sage Korean Version (Right)

Use Firefox or Chrome to connect to one of the above servers. Then register your ID and password to get started.

원본 그림의 이름: M7}]ZVHBIQ}C[28[887TU`N.jpg
원본 그림의 크기: 가로 734pixel, 세로 463pixel

2. Development of the Korean Version of Sage


There are Quick Reference (simple manual) for Sage in English and Korean. Those Quick References can be downloaded from the web site address below.

Sage Quick Reference: Basic Math and Calculus

Peter Jipsen, version 1.1 (Basic Math) Latest Version at   

William Stein (Calculus) Sage Version 3.4   

GNU Free Document License, extend for your own use 

Translated to Korean language by Sang-Gu Lee and Jae Hwa Lee (Sungkyunkwan University)

Korean Version at  


Notebook (and Command line)

Evaluate cell: <shift-enter>

com <tab> tries to complete command

command?<tab> shows documentation

command??<tab> shows source

a.<tab>i shows all methods for object a (more: dir(a))

search_doc('string or regexp') shows links to docs

search_src('string or regexp') shows links to source

lprint() toggle LaTeX output mode

version() print version of Sage

Insert cell: click on blue line between cells

Delete cell: delete content then backspace


Numerical types

Sage has many different number systems. ZZ represents set of integers, QQ represents set of rational numbers, RDF represents floating-point real numbers, CDF represents floating-point complex numbers.

Example for Rationals:

sage: a=1/2; b=QQ(4/2); print a+b; b.parent()

output: 5/2

Rational Field

Builtin constants and functions:

Constants: =pi   =e   =I=i   =oo

=oo=infinity    NaN=NaN    log(2)=log2

=golden_ratio   =euler_gamma


Builtin functions:

sin  cos  tan  sec  csc  cot  sinh  cosh  tanh  sech  csch  coth  log  ln  exp

=a*b  =a/b  =a^b =sqrt(x) =x^(1/n) =abs(x) =log(x, b)

Symbolic variables: e.g. t, u, v, y, z = var('t u v y z')

Define functions: e.g.   f(x)=x^2 or f=lambda x: x^2 or def f(x): return x^2


Operations and equations:

Relations: : f == g, : f != g, : f <= g, : f >= g, : f < g,  : f > g

Solve : solve(f(x)==g(x), x)

Solve : solve([f(x, y)==0, g(x, y)==0], x, y)

Exact roots: (x^3+2*x+1).roots(x)

Real roots: (x^3+2*x+1).roots(x, ring=RR)

Complex roots: (x^3+2*x+1).roots(x, ring=CC)

: var('i'); f(i)=i; sum(f(i), i, 1, 10)

: var('i'); f(i)=i; prod(f(i), i, 1, 10)

Defining symbolic expressions

Create symbolic variables: var('t, u, theta') 

Symbolic functions

Symbolic function (can integrate, differentiate, etc.): f(a, b, theta) = a + b*theta^2

Also, a "formal" function of theta: f = function('f', theta)

Piecewise symbolic functions: Piecewise([[(0, pi/2), sin(1/x)], [(pi/2, pi), x^2+1]])


Python functions


def f(a, b, theta=1):

    c = a + b*theta^2

    return c

Inline functions:

    f = lambda a, b, theta = 1: a + b*theta^2



Factored form: (x^3-y^3).factor()

List of (factor, exponent) pairs: (x^3-y^3).factor_list()


: limit(f(x), x=a)



: diff(f(x), x) or f.diff(x)

: diff(f(x, y), x)

   e.g. diff(x*y + sin(x^2) + e^(-x), x)



: integral(f(x), x) or f.integrate(x)

   e.g. integral(x*cos(x^2), x)

: integral(f(x), x, a, b)

   e.g. integral(x*cos(x^2), x, 0, sqrt(pi))

: numerical_integral(f(x), a, b)[0]

   e.g. numerical_integral(x*cos(x^2), 0, 1)[0]

assume(...): use if integration asks a question

   e.g. assume(x>0)


Multivariable calculus

Gradient: f.gradient() or f.gradient(vars)

   e.g. (x^2+y^2).gradient([x, y])

Hessian: f.hessian()

   e.g. (x^2+y^2).hessian()

Jacobian matrix: jacobian(f, vars)

   e.g. jacobian(x^2 - 2*x*y, (x, y))


2D graphics

Polynomial: plot(x^2, (x, -2, 5))

Functions: plot(f(), (x, , ), options)

Line: line([(), ()], options) : line([(x_1, y_1), (x_2, y_2)])

Polygon: polygon([(), ..., ()], options)

Circle: circle((), , options)

Parametric functions: parametric_plot((f(), g()), (t, , ), options)

Polar functions: polar_plot(f(), (t, , ), options)

Animate: animate(list of graphics objects, options).show(delay=20)


3D graphics

Line: line3d([(), ()], options)

Sphere: sphere((), , options)

Tetrahedron: tetrahedron((), size, options)

Functions: plot3d(f(), (x, ), (y, ), options)

   add option plot_points=[]

Parametric functions: parametric_plot3d((f(), g(), h()), (t, ), options) or

   parametric_plot3d((f(), g(), h(), (u, ), (v, ), options)

Linear algebra

: vector([1, 2])

: A=matrix([[1, 2], [3, 4]]); A

: det(matrix([[1, 2], [3, 4]]))

: A*v

: A^-1 or A.inverse()

: A.transpose()

Other methods: A.<tab>  # to see methods that are available with matrix A

  Sage Problem: Exercise 4 in Section 8.2 (Area of a Surface of Revolution)

★ Find the area of the surface when is a positive even integer.



k,x=var('k, x');


def _(y = input_box(sin(k*x), label="y="), kappa=slider(0, 100, 1, default=1, label=' k')):


 lim(integral(2*pi*sin(k*x)*sqrt(1+diff(sin(k*x), x)), x, 0, pi), k=kappa) ))

   plot(sin(kappa*x), x, 0, pi, color='purple', fill=true).show(aspect_ratio=1, xmin=0, xmax=pi, ymin=-1, ymax=1)


 Answer : 0.

  Sage Problem: Exercise 22 in Section 9.3 (Polar Coordinates)

★ Sketch the curve with the given polar equation.




polar_plot(sin(4*theta), (0, 2*pi)).show(aspect_ratio=1, xmin=-1, xmax=1, ymin=-1, ymax=1)



  Sage Problem: Exercise 16 in Section 11.6 (Cylinders and Quadric Surfaces)

★ Sketch the region bounded by the surfaces and for .


var('x, y, z')


plot3d(z, (x, -2, 2), (y, -2, 2), (z, 2, 4))+implicit_plot3d(x^2+y^2==4,(x, -2, 2), (y, -2, 2), (z, 2, 4), opacity=0.5)


All of the above Sage commands and many more in the published section of each Sage server (e.g. ) can be copied and pasted, so you can modify them. Sungkyunkwan University has made more than 3,000 Sage commands. We hope everybody can take full advantage of Sage in learning and teaching Calculus.


Sage-Calculus--Grapher :   

Sage- Parametric Equation Grapher :  

Sage- Polar Equation Grapher :  

Sage- Implicit Function Grapher :