
Discrete Math with SageMath: Learn math with open-source software
![]()
![]()
![]()
![]()
![]()
Zunaid Ahmed, University of Illinois
Hellen Colman, Wright College
Samuel Lubliner, Georgia Institute of Technology
Copyright Year:
Publisher: Zunaid Ahmed, Hellen Colman, Samuel Lubliner
Language: English
Formats Available
Conditions of Use
Attribution
CC BY
Reviews
Reviewed by Timothy Huber, Professor, The University of Texas Rio Grande Valley on 12/22/25
The book covers the fundamentals of a discrete structures course and gives the reader an excellent introduction to the combinatorics, logic, and graph theory capabilities of SageMath. Topics include set theory, logic, relations, functions with... read more
![]()
![]()
![]()
![]()
![]()
Reviewed by Timothy Huber, Professor, The University of Texas Rio Grande Valley on 12/22/25
Comprehensiveness
The book covers the fundamentals of a discrete structures course and gives the reader an excellent introduction to the combinatorics, logic, and graph theory capabilities of SageMath. Topics include set theory, logic, relations, functions with recursion and recurrence relations, combinatorics (permutations and combinations), graphs, trees, lattices, Boolean algebra, logic gates, and finite state machines. The text integrates each topic with executable SageMath code. To match the breadth in other reference books, the text could benefit from additional material on advanced counting (e.g., combinations with replacement, and inclusion–exclusion), introductory number theory (e.g.,the Euclidean algorithm, modular arithmetic, Chinese remainder theorem, Euler’s theorem, and basic cryptography), discrete probability, generating functions, and the fundamentals of asymptotic analysis. The book's index is extensive and easy to use.
Content Accuracy
The mathematics in the book is accurate, and the book is a great demonstration of the visualization capabilities of Sagemath in graph theory. I found that some of the graph-theoretic code output did not display ideally in some browsers. However, the authors discuss ways to fine-tune how graphics display.
Relevance/Longevity
The book is designed to be updated, remixed, and adapted to courses at each institution. This makes it a useful fundamental reference for a course in discrete structures.
Clarity
The writing is easy to understand, and each example is followed by code-based mathematical experiments. This may help learners understand the mathematics, since it combines concepts with code. Many other textbooks on discrete structures have initial chapters on proof strategies. This book could be improved with an additional chapter on proof writing. An introduction to proofs could also allow more depth in the mathematical ideas covered.
Consistency
The book is built around the capabilities of SageMath and follows a repeated pattern of definitions, examples, live computations, and applications. Most standard textbooks on discrete mathematics include related topics to build a wide scaffold before including applications. The book’s approach allows immediate experimentation but with less theoretical depth than is included in other textbooks. Learners can experiment with the mathematics immediately, but some sections include only basic definitions and straightforward examples.
Modularity
Chapters are self contained and can be used in a course or read independently. In most cases, instructors can easily use the material in a chapter as a stand alone unit without the need to cover prior chapters.
Organization/Structure/Flow
The book is well organized and provides a good introduction to SageMath, through set theory and logic, relations, functions, recursion, and combinatorics. The later sections on graph theory, trees, lattices and Boolean algebra, logic gates, and finite state machines, align well with a computer science-oriented discrete mathematics course.
Interface
The PDF build is nicely typeset, with figures and mathematics rendered nicely. The web version, which includes interactive SageMath cells, makes the textbook interactive and can serve as a mathematical laboratory that is ideal for learning through discovery and in class demonstrations. Most sections of the web version looked good on a small screen such as a tablet or cell phone. Each section could benefit from “Run all” and “Reset” buttons at the start of each module.
Grammatical Errors
Only minor phrasing and copy editing issues are visible, mainly in early chapters. These are minimal, somewhat subjective, and do not affect correctness or readability.
Cultural Relevance
The book’s applied examples are engaging and much more applicable than those in a typical mathematics textbook. These applications include planning courier routes, designing railway connections with minimum material cost, working with color complements using rational hue values, and building elevator and traffic light controllers. These applications connect discrete mathematics to practical applications.
CommentsThe book is a good resource for learners that want to know the basics of discrete math but also want to build coding skills that allow for experimentation with the mathematics. One of the most impressive chapters is the section on the traffic light state machine. This is a thoughtful example with significant depth that uses much of the developed theory. New versions of the book will benefit from more exercises and suggestions for further reading.
Table of Contents
- Front Matter
- Getting Started
- Set Theory
- Combinatorics
- Logic
- Relations
- Functions
- Graph Theory
- Trees Lattices
- Boolean Algebra
- Logic Gates
- Finite State Machines
- Back Matter
About the Book
Our book is intended to provide concise and complete instructions on how to use Sage to solve problems in Discrete Math. It is appropriate for a first or second year undergraduate course for math and computer science majors. Our goal is to streamline the learning process with SageMath. This approach helps students focus more on mathematics and reduces the friction of learning how to code. Our resources are designed for all math students, regardless of programming experience.
The novelty of our project is that the textbook is authored by students under faculty supervision. With Open Pedagogy as a guiding praxis, we present this student-created textbook as a more effective alternative in promoting student learning and engagement. Students present the contents in new and inventive ways, from the overall voice of the textbook to the actual examples drawn from their and their peers' lives.
The text began as a support textbook for our undergraduate Discrete Math course developed at Wright College, one of the City Colleges of Chicago. Despite the fabulous capabilities of SageMath, students in Discrete Math were often frustrated by the lack of specific documentation geared towards beginning undergrad students in Discrete Math. We developed an OER for our students to use this mathematical software effectively.
About the Contributors
Authors
Zunaid Ahmed, after completing coursework at the City Colleges of Chicago, Zunaid transferred to University of Illinois to pursue a degree in Computer Engineering. He currently works as a Course Assistant for Math 257, a computation-based linear algebra course. His interests lie in semiconductors, quantum computing, and automation, and he has worked on projects ranging from noise cancellation circuits to FSM design.
Hellen Colman is a Full Professor in the Department of Mathematics at the Wright College, one of the City Colleges of Chicago. She holds a Ph.D. in Geometry and Topology from the Universidade de Santiago de Compostela, Spain.
Samuel Lubliner first learned about SageMath in Dr.Colman's Discrete Math course and LaTeX in her Calculus 2 course. Sam holds an MS in Sustainability from DePaul University and completed a software development apprenticeship through DPI and the University of Illinois. Recently, Sam began a new role as an automation developer and gained admission to the MS in Computer Science program at Georgia Tech.