Using Desmos: Actions and the Ticker
Created: 2025/3/23

This section explains how to use actions and tickers in the Desmos Graphing Calculator. These are powerful tools that can significantly enhance what you can do with Desmos.

Actions

Basics of Actions

Actions are flexible tools that let you manipulate variable values dynamically.

Define aa as you like, then input a->a+1.

1
a=1a=1
2
aa+1a\to a+1

The -> automatically converts to a right arrow and is recognized as an action.

Click the arrow button to the left of the equation. The action will execute, and the value of aa will increase by 1 each time.

In other words, aa is being updated to a+1a+1.

Multiple Actions

You can execute multiple actions at the same time.

1
a=2a=2
2
b=1b=1
3
aa+1, baa\to a+1,\ b\to a

In this case, bb is assigned the value of aa before the action is executed. So, after one execution, a=3,b=2a=3,\,b=2 will result.

When multiple actions are listed together, they execute simultaneously. This means you cannot assign multiple values to the same variable in one operation.

For example:

1
a=1a=1
2
aa+1, aa+2a\to a+1,\ a\to a+2

will result in an error stating, "An action cannot specify multiple update rules for 'a'."

Assigning Actions to Variables

Actions themselves can be assigned to variables.

1
a=2a=2
2
b=1b=1
3
A=aa+1A=a\to a+1
4
B=bb+1B= b\to b+1
5
C=A,BC=A,\,B

As shown above, executing CC will execute A,BA,\,B simultaneously. Similarly,

1
a=1a=1
2
A1=aa+1A_1=a\to a+1
3
A2=aa+2A_2=a\to a+2
4
C=A1,A2C=A_1,\,A_2

will result in an error because CC specifies multiple update rules for aa.

Executing Actions by Clicking on Graphs

Points, functions, and other graph elements can execute actions when clicked.

As shown in the image above, you can make a graph clickable by enabling the option in the equation settings and specifying the action to execute on click.

This lets you manipulate variables by clicking on graphs or labels.

Click the label +1 / -1. You should see the value of aa change.

If you assign an action to a variable, you can also specify that variable.

Tickers

Tickers let you execute specified actions at regular intervals.

To add a ticker, select it from the "+" menu.

If the ticker option is not visible, try adding an action first. The ticker option should then appear.

Once the ticker is added, specify an action in the "Run" section and set an appropriate value in the right-hand field.

Clicking the metronome icon will start the ticker. As shown in the image above, aa+1a\to a+1 will execute every 100 milliseconds.

Advanced

Getting Ticker Execution Time

Tickers generally execute at the specified intervals, but if the calculations take too long, the execution might be slower than expected.

To ensure consistent graph updates across devices, you can retrieve the actual interval at which the ticker executed and adjust the action accordingly.

For example, by setting tt+1t\to t+1 every millisecond, you can create a graph that shows how many milliseconds have elapsed.

Ideally, it should increase by 1000 milliseconds per second, but if the ticker's calculations can't keep up, the elapsed time will be inaccurate.

To address this, you can use the special variable dt\mathrm{dt} to get the elapsed time of the ticker.

As shown in the image, dt\mathrm{dt} represents the elapsed time of the ticker in the "Run" section. By increasing tt by dt\mathrm{dt} each time, tt is updated correctly.

Updating Lists with Actions

For graphs drawn using lists, you can execute actions when a graph element is clicked. Often, you'll want to change the action based on which graph in the list was clicked.

In this case, you can use the special variable index\mathrm{index} to identify which graph in the list was clicked.

Using this, you can customize the action based on the clicked graph, as shown in the example below.

Click the green circles!

SHARE
Images are created with the Desmos Graphing Calculator, used with permission from Desmos Studio PBC.
© 2024 UNS Physics. All Rights Reserved.