Profweb

Home » Publications » Real Life Stories » Mathematics and Programming in the Cloud with CoCalc

Publications

Real Life Stories

Published June 13, 2017 | Mathematics

Mathematics and Programming in the Cloud with CoCalc

Author’s Note

This Real Life Story was written with the collaboration of Ryan W. Moon, Editor, Profweb.

Cloud computing is an increasingly important part of the college experience in Quebec. With more and more educational establishments using Google Tools, Office 365 and Moodle, there is less and less of an emphasis on having computers with a laundry list of applications installed. When you can fire up a web browser and have access to a wide range of tools, it is a game-changer. The field of mathematics is also well-entrenched within this computing trend, with the appearance of cloud-based innovations in the past couple of years, not the least of which is a powerful platform for cloud computing known as SageMathCloud, which has recently been rebranded as CoCalc. Since this name change is very recent, most of the information and tutorials on the internet still make reference to the old name, and this article will use both names interchangeably.

I have been using SageMathCloud/CoCalc (and its underlying mathematical core, “SageMath”) in my teaching for quite some time now, both for my own use for class and workshop preparation as well as for in-class use with students - most prominently in the Computer Applications in Math course, in which my students use the system heavily themselves. It has become my one and all central repository for all my teaching materials (linked with my Dropbox account), and I could not imagine a life without it any more!

The SageMathCloud/CoCalc and its Origins

CoCalc is a sophisticated online computation system which can be accessed with any web browser, and was originally created as an interface to access the mathematical software package “Sage” (or “SageMath”, to distinguish it from the independent accounting software SAGE) from any internet-connected computer. But it has since grown to provide much more functionality than this, and I see it now as a very powerful general document storage, editing, and collaboration tool - with the added possibility of doing complex calculations and programming in the cloud. The recent rebranding under the name “CoCalc” (Collaborative Calculation in the Cloud) reflects these extended possibilities, which I will describe in more detail later on in this article.

An overview description of CoCalc on the platform’s web site.

The underlying mathematics software “Sage” (short for System for Algebra and Geometry Experimentation) was created by Professor William Stein, a mathematician who is now at the University of Washington, as an alternative to the ‘3 Ms’ - Maple, Mathematica and Matlab, commercial and proprietary mathematical software packages (often called Computer Algebra Systems or CAS). While these are great and powerful computing tools, their closed-source nature (the behind-the-scenes work of the system is hidden and inaccessible to the user) and high price tags make them, at least in my opinion, less than ideal for academic purposes, be it for research or teaching. As an anecdotal example, while working on my Ph.D., I encountered a critical bug when using one of the 3 Ms and promptly reported the bug to the company. It took them forever to fix the problem (far longer than I had the time to wait), and I quickly became frustrated and had to find cumbersome workarounds. Back then, there was no alternative, but in an open-source system, I could have found and fixed the problem myself and contributed it back. This was precisely one of the key motivations for William Stein: He noticed that there were a number of existing open-source math packages that could be brought together under one framework with the highly popular and flexible Python programming language to create a viable, free, and open alternative, and got to work with many volunteers to make this happen. The result of this hard work was the free open-source software known as SageMath, which is now used by mathematicians, students, and many non-mathematicians worldwide and continues to grow and improve at a staggering rate.

While it is possible to install SageMath on your own computer, or even on a local server to be used by several people in (limited) collaboration (I did this for our Math Department for about 4 years), it is the integration of this software in the SageMathCloud/CoCalc online system which greatly simplifies access to it since:

  • There is no need to install anything on a local computer.
  • It completely opens up the possibilities for collaboration (sharing of material, simultaneous editing of documents, and much more), and
  • It allows easy access to all your files in- and outside of the classroom.

When this system became available, I realized that it was much more advanced than my local SageMath installation, and convinced our college to buy a site licence for a certain number of users, mainly for our math faculty and for students in at least one course per semester.

The website can be used for free with very little limitations, but with the risk of slower performance during times of high demand - a site or individual subscription lifts these restrictions and is highly recommended.

An introductory video about SageMathCloud and its history

How to Work with CoCalc

Everything in CoCalc starts as a ‘project’, which is essentially a data storage for all the files you might want to create or upload (in fact, each project is a virtual server running a full Linux operating system, which means that with a bit of know-how, you can in fact do almost anything you could do on a local computer - but in the cloud!).

At a very basic level, you can simply use CoCalc as a kind of Dropbox-replacement which enables you to open and display almost any type of file (for example pdf-documents) on any computer with internet access - with the added benefit that you can also easily create and edit them in the same environment, right in your web browser. CoCalc can directly deal with many text-based file formats, including:

  • Markdown, a simple and highly recommended way to write structured documents quickly in a simple text document (this is fast becoming a standard on many websites, including Moodle)
  • HTML
  • Many programming languages (including Python in particular)
  • The scientific typesetting language LaTeX

In each of these cases, CoCalc provides a sophisticated in-browser editor with syntax-highlighting and automated preview.

An example showing the document editor within SageMathCloud/CoCalc.

What makes the system special is that a whole project can be shared with other CoCalc users (for example other teachers, or students). Collaborating users can work on the same file simultaneously with changes appearing in real-time, which works not only for simple text documents, but also for computational documents. At the same time, you can use an integrated chat-system to discuss the document with your collaborators, right next to the editor.

Furthermore, the system includes an automatic backup and versioning system, called “TimeTravel”: all files are automatically saved every couple of seconds, and all changes are remembered since the original creation of the file. This enables you to compare the current state of a document with a previous version, and to possibly revert changes.

But the real power of the system comes to bear when dealing with computations: Creating a “SageMath worksheet”activates a powerful computer algebra system, which can be edited like a simple text document, and its output can be easily exported as a pdf-document. Furthermore, the system has built-in support for many other open-source mathematical software, for example:

  • R, a widely-used statistics software
  • Octave, a different open-source computer algebra system/programming language
  • Julia, a programming language for high-performance numerical analysis

A more detailed introduction to using SageMathCloud/CoCalc.

Integrated Course Management

There are elements of course management included within CoCalc, which enable the teacher to automatically create shared student projects for a whole class, and to easily distribute and collect assignments (in the form of a folder containing any type of files). As a teacher, you can go into the students’ project folders at any time to see the status of the advancement of the projects. You can also chat with students in real-time within the documents and give them support if they are struggling with any aspects of the course or the assignments.

An excellent tutorial introducing all the course management functions within SageMathCloud/CoCalc can be found here.

How I Use CoCalc in My Classes

SageMathCloud/CoCalc is in fact part of a ‘quadfecta’ of math software that I use (and encourage my students to use) in my classes, along with Desmos, GeoGebra and Wolfram Alpha which have been the subject of previous publications on Profweb. Students from my Calculus I and Calculus II courses know that they can look to Wolfram Alpha for quick answers with fuzzy logic. Desmos is great for graphing functions and works as the ultimate modern replacement for a graphing calculator. GeoGebra is particularly great for geometric interaction and experimentation (but it also has very advanced computer algebra capabilities).

I usually reserve SageMathCloud for the more advanced classes, like Linear Algebra, Multivariable Calculus, Probability & Statistics, and in particular Computer Applications in Math (which at our college is a type of “topics” course, with a focus on using a computer for complex computations). Any student who wants to pursue any sort of scientific or engineering program/career needs to learn at least a modicum of programming, and the SageMathCloud/CoCalc has an excellent integrated development environment that recognizes a variety of computer languages, including Python (on which SageMath is based).

Python is one of the easiest programming languages to learn, and which is increasingly becoming a standard at many universities. For this reason, I use CoCalc to gently introduce students to the basics of programming in Python, while exploring some fun and sophisticated mathematical topics. Some of my former students have written to me to say how happy they were to have learned the basics of Python, as it was immediately useful in their university studies.

An example of a SageMath worksheet showing some simple computations.

As SageMath was written by mathematicians for mathematicians, and is used actively in research, it has support for many advanced mathematical subjects - the sky's the limit!

Here is an incomplete list of topics that I usually discuss in my courses and which lend themselves well to using SageMath:

  • Cryptography, also including matrix operations over finite fields (i.e. using modular arithmetic)

    An example showing some built-in Cryptography functionality in a SageMath worksheet.

  • Complex numbers (especially visualizations in the complex plane)
  • Fractals (for example: Koch snowflake, Barnsley’s Fern, Mandelbrot set)

    An example showing Barnley’s Fern computed in a SageMath worksheet.

  • Graph Theory

    An example showing some built-in Graph Theory functionality in a SageMath worksheet.

  • Markov Chains
  • Scientific typesetting using LaTeX (here is an excellent series of introductory videos about LaTeX using SageMathCloud )

The buttons shown on top of a SageMath worksheet (e.g. “Plots”, “Calculus”, “Linear”, etc.) give quick examples of how to use and access various mathematical objects - and the integrated documentation (“Help”) can give further details on more advanced topics.

Taking First Steps and Final Thoughts

The best way for teachers to get started with CoCalc is to simply sign up for a free account and experiment, maybe using the videos linked in this article or the aforementioned tutorial for teachers as a starting point. Apart from being a great authoring and organisational tool for teachers, students can greatly benefit by experiencing this modern and powerful software tool as early as possible in their education. Many of the universities are using Python and CoCalc in their classes now, and it would be great for our students to have their first exposure to this already in the colleges!

For a more complete overview of the SageMathCloud, who better than project creator William Stein himself to provide you with a seminar on the tool. Happy exploration!

An in-depth SageMathCloud tutorial from project creator William Stein.

About the Author

Gabriel Indurskis has been teaching in the college network since 2008 and is in the mathematics department at Champlain Saint-Lambert. Prior to teaching at Champlain Saint-Lambert, he also taught at the University of British Columbia and at UQAM. Gabriel grew up in Germany and arrived in Canada in 2001. He earned a Ph.D. in mathematics at the Université de Québec à Montréal en 2006.

0 comment(s)

Comment

* required fields
Type of comment*