Desmos

Typically Desmos is used as a graphing calculator to plot functions from \( \mathbb{R}\) to \(\mathbb{R}\). It does, however, have lesser known features like lists, list comprehension, polygons, and the full scope of RGB colors, which allow us to do so much more. How much more?

A common exercise in introductory computer science courses will ask students to implement Conway's Game of Life. While to my knowledge no such course quite exists for Desmos, enthusiasts will take it upon themselves to give it a stab.

This example serves as a demonstration of how Desmos is quietly capable of so much more than it at first appears.

Techniques

Here we describe some resources and techniques which are useful for various applications.

Colors

Desmos natively comes equipped with 6 colors: red, blue, green, orange, purple, and black. While you can control opacity, and layering objects with different colors/opacities allows some other colors, the precise effect is difficult to control. As far as I'm aware, how layering different colors works is not well documented. Instead, Desmos provides an RGB and an HSV function to add additional colors to select. One can assign a color to a variable, at which point, the color appears in the color selection menu for any graph object.

Lists

Lists in Desmos share some similarities with lists or arrays in many popular programming languages. Once a list is declared as a variable with some elements, its elements can be accessed with an index enclosed by square brackets.

Ray Intersection with Polygon

Examples

Below are examples of ways to use the above tools.

Point-in-polygon Problem

The point-in-polygon problem asks whether a given point lies within some polygon. A simple technique is to shoot a ray from the point and count the number of intersections between the ray and the polygon's edges. If the point is within the polygon, the number of intersections should be odd; otherwise, the number of intersections should be even.

Thomae's Popcorn Function

Thomae's function is a common function presented in introductory analysis courses which challenges students' intuition of what it means to be continuous.

Dynamical Billards

Dynamical billiards generalizes the popular game of billards to a dynamical system modelling the motion of a particle within some boundary.