Actions provide a way to react to events, like clicks or clock ticks, in the calculator. Each action is made up of one or more update rules, which specify new values for a variable based on specific events within the expression list or on the graph paper.
Enabling Actions
Actions are an advanced feature that you must enable at the account level in order to use.
Make sure you sign in to your account in the Desmos Graphing Calculator, Geometry Tool, 3D Calculator, or Notebook.
Click your name to open Account Options and then click Account Settings.
Go to the Advanced tab and check Actions.
Getting Started With Actions
Use the right arrow symbol (→) to create an action. You can create this symbol by entering Hyphen (\(\mathbf{-}\)) followed by Greater Than (\(\mathbf{>}\)) in an expression line.
When you write an action, make sure to enable the slider for the variable you are using.
The expression containing the action will then display an Action icon . Clicking this icon will run the action on each click.
Here are some examples of basic actions:
- To set \(a\) to \(1\): enter \(\mathbf{a}\)→ \(\mathbf{1}\)
- To increase \(a\) by \(1\): enter \(\mathbf{a}\) → \(\mathbf{a}\) + \(\mathbf{1}\)
- To swap the values of \(a\) and \(b\), enter \(\mathbf{a}\) → \(\mathbf{b}\), \(\mathbf{b}\) → \(\mathbf{a}\)
To explore these actions, click the GIFs to open example graphs.
Clickable Objects
When you enable actions, you can attach them to graphed objects like points, curves, and images. The actions will then run when you click the objects in your graph.
Find the object in the expression line. Then, click and hold the Color icon to open the Options menu.
Toggle on Clickable.
In the field titled On Click, you can write an action that will occur when you click the object in the graph.
Clickable Objects Examples
In this example, the compound inequality \(0 \le y \le k−x^2\) is clickable. Each click anywhere within the inequality will increase the variable \(k\) by one.
In this example, the directed angles are clickable. Each click will rotate the geometric shape \(90\) degrees clockwise or counterclockwise.
In this 3D example, the triangles are attached to actions. Each time you click the triangles, the center of the sphere moves up or down by one.
Actions on Lists and Tables
Update Lists and Tables
In addition to using actions to update the value of a single variable, you can also modify lists and tables.
When you have a list of values assigned to a variable, you can use actions to assign a new list of values, modify all of the values of the list, and append new values to your list using the join( ) function. To update a table column, reference the column header's variable name in your action.
Use “index” With Lists
When you attach a clickable action to a list, the special variable \(index\) indicates which element of the list you clicked.
In the Ant Actions example graph, you can move the ant along by pressing the dots and see how the list is updated with actions.
Actions Using Variables and Function Notation
To assign an action to a variable, enter \(\mathbf{A = a}\) → \(\mathbf{a+1}\) in an expression line for an example.
This allows you to attach the same action to multiple objects that use the same variable.
You can also use functions to define actions, by entering an example like:
\(\mathbf{f(x) = a}\) → \(\mathbf{x}\).
This allows you to create related actions. For instance, with this definition, \(f(1)\) and \(f(2)\) will be distinct actions that set a to \(1\) and \(2\) respectively when they run.
Piecewise expressions (using restriction notation in curly brackets) enable you to specify different actions based on a condition.
Curly brackets indicate that the calculator is checking which action (if any) to run based on the given condition. In this example, if \(a\) is less than \(0\), then the action will square \(a\). Otherwise (indicated by the comma), \(a\) will get subtracted by \(3\).
The Ticker
When you enable actions, you can specify an action that will run repeatedly at a specified interval using the ticker.
To add a ticker, click Add Item . You can also type Ticker into an expression line.
In the Run section, specify an action. You can run multiple actions simultaneously by separating them with commas.
Optionally, you can set the duration in milliseconds (ms) for the time interval between ticks.
More Examples
Actions Tracking Time
For actions run by the ticker, the special variable dt represents the time elapsed since the last tick, measured in milliseconds. You can use dt to track how long the ticker has been running.
Click on the image to see an example graph that uses dt to measure the ticker time.
A Random Action
When you use the random( ) function to define an action, the calculator will generate a new random number each time the action runs.
Click the image to explore an example of how you can use random numbers in an action.
Statistics in Action
Adding elements to a list with actions allows you to simulate random experiments in Desmos. For example, you can explore questions like, “What happens if I add together the result of two random dice rolls?”
Learn More
Please write to us with any questions or feedback to support@desmos.com.