Actions

Actions provide a way to react to events in the calculator, like clicks or clock ticks. 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.

To learn how to enable Actions on your account and explore the available features, read the resources below.

 

Enabling Actions

Actions are an advanced feature that must be enabled at the account level.

Desmos graphing calculator with Log In and Sign Up Buttons called out.

Make sure you sign in to your account in the Graphing Calculator, Geometry Tool, or 3D Calculator.

Desmos graphing calculator with account name clicked and drop down menu showing.  Option to select Account Settings or to Sign Out.

Click on your name in the top right to bring up account options and click Account Settings.

Account settings page on graphing calculator, Advanced tab is selected, and actions are checked.

Go to the Advanced tab and check the Actions checkbox.

 

Getting Started With Actions

GIF typing letter a followed by subtraction sign, followed by greater than symbol in the expression list.  Final two symbols merge into a right-pointing arrow.

To author an action, use the right arrow symbol (→). You can create this symbol by typing the subtraction symbol (-) followed by a greater than sign (>).

Action to increase a to \(a+1\) with a slider for a is in the expression list.  Action button is pressed numerous times, taking the value of a from one to five.

When writing an action in the expression list, make sure you enable the slider for the included variable if it wasn’t previously defined.

The expression containing the action will then display an action icon. Clicking this icon will run the action each time on click.

Screenshot of three different actions in the expression window. \(a\) → 1. \(a\) → \(a\) + 1. \(a\) → \(b\), \(b\) → \(a\). Sliders for a and b.  Currently sliders are set at six for a and one for b.

Here are some examples of basic actions:

Set \(a\) to 1: \(a\) → 1

Increase \(a\) by 1: \(a\) → \(a\) + 1

Swap the values of \(a\) and \(b\): \(a\) → \(b\), \(b\) → \(a\)

To see how these actions interact, explore the graphs above by clicking on the GIFs.

 

Clickable Objects

When actions are enabled, you can attach them to graphed objects like points, curves, and images. The action will run when the object is clicked on the graph paper or within the 3D cube.

Options Menu for a point opened in expression window which includes Clickable because an action is included elsewhere in the expression list.

Long press the icon to the left of your expression to open the options menu.

Clickable is selected in the style menu for a point.  A field has appeared titled On Click.

Toggle Clickable to the “on” position.

Clickable has been selected in the style menu for a point.  In the On Click field, the action \(a\) → \(a\) + 1 has been entered.

In the field titled On Click, you can author an action that will be performed when the object is clicked in the graph itself.

 

Clickable Objects Examples

GIF of an upside down filled parabola whose vertex increases by one on click.

In this example, the compound inequality \(0 \le y \le k−x^2\) is clickable. Each click anywhere within the inequality will increment the variable \(k\) by one.

Geometry graph shown with two L shapes and an arrow for a 90 degree clockwise and clockwise rotation.

In this example, directed angles on click rotate the geometric shape 90 degrees clockwise or counterclockwise.

Gif of a sphere moving up one or down one on click of up and down arrows in the 3D cube.

In this 3D example, the triangles are attached to actions. Clicking on the triangles moves the center of the sphere up or down by one.

 

The Ticker

When actions are enabled, you can specify an action that will run repeatedly at a specified interval using the ticker.

Add item menu in the graphing calculator is open with ticker as the last option.

To add a ticker, click the Add Item button in the top left of the expression panel of the graphing calculator. You can also type ticker into an expression line.

An action is in ticker field defined as \(a\) → \(b\), \(b\) → \(a\).  Time has been set to 100 ms. Sliders added for a and b, currently set a to two and b to zero.

In the Run section, specify an action.

Optionally, you can set the duration in milliseconds (ms) for the time interval between ticks.

An action is in ticker field defined as \(a\) → \(b\), \(b\) → \(a\).  Time has been set to 1000 ms. Sliders added for a and b. Ticker is running and a and b are alternating values between zero and two.

Click the icon to start the ticker. It will repeatedly run the action(s) at the specified time interval.

 

Actions using Variables and Function Notation

Action \(A = a\) → 1 is in the first expression line.  The second line has a slider for a. The options menu is open for a parabola that is graphed on the graph paper.  The parabola has been made clickable, and \(A\) is entered into the On Click field.

Actions can be assigned to variables, such as:

\(A = a\) → 1

This allows you to attach the same action to multiple objects.

First expression line contains function/action \(f(x) = a\) → \(x\).  Second expression line has slider for a with value set to two. Third expression lines contain actions \(f(1)\) and \(f(2)\).

Functions can also be used to define actions, such as:

\(f(x) = a\) → \(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.

First expression line shows {a \lt 0: a → a^2, a → a-3}. Second expression line is a slider for a currently set to five. Third expression line plots the point (\(a\),0) with the label shown.

Piecewise expressions (using restriction notation in curly brackets) enable you to specify different actions based on a condition.

Curly brackets indicate that a condition is being checked in order to determine which action (if any) to run. In this example, if a is negative (less than \(0\)), then the action will square a. Otherwise (indicated by the comma), a will get subtracted by \(3\).

 

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.

Circle with 60 dots around the outside, giving the impression of a clock or stop watch.  Single blue hand is pointed directly up with the expression list showing prompting you to run the ticker.

Updating a List with Actions

When a clickable action is attached to a list, the special variable index indicates which element of the list was clicked.

Click on the image to move the ant along by pressing on the dots, and see how the list is updated with actions.

Image of an ant standing on point at ordered pair (-2,0).  Other points are plotted at (0,0), (2,0), (5,0).  Expression list is open showing how the ant moves to different points when clicked.

A Random Action

When random( ) is used in an action definition, a new random number is generated each time the action runs.

Click on the image to see an example of how random numbers are used in an action.

A point (a,a) is plotted with a slider for a. A is updated with a random action. The GIF shows clicking the action button and seeing where the point moves.

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?”

Screenshot showing a frequency histogram and a list of the results from a random dice roll.

 

Learn More

Please write to us with any questions or feedback to support@desmos.com .