Variables and Sliders

One of the most fundamental parts of the Desmos Graphing Calculator: variables. Setting parameters that update your whole graph when changed is what they do. We're going to go through some uses of variables and some examples.

Variable and Slider Properties
To create a variable, simply write a letter followed by a '=' sign and a number, a slider will appear. Now you can slide your slider or press the play button to watch an animation play out, if you have a graph connected to the variable. Here are the four parameters you can control on a variable/slider:


 * Restrictions setting the maximum and minimum values the slider can take
 * Step setting the increments in which you can move the slider
 * Animation Speed
 * Animation Mode

There are four animation modes: looping, repeatedly playing in the same direction, one time run, and indefinitely running. Most of the time you'll be looping your animations, however the others are also useful. For example, you could use the indefinitely play to record time in your graph. Steps are useful too. When you need to make calculations that involve whole numbers, or even numbers or you can make a switch with just two states, or more if you want! Restrictions are always useful, you don't want your graph flying off the grid or your line getting infinitely steep! By default the maximum is set to 10 and the minimum is set to -10.

Movable Points
Try typing $$(a,b)$$and pressing enter, you will find that the two variables are automatically formed. You have just created a movable point. You can then take the same variables and use them in another equation. For example, if you have two points, you can work out the gradient and y-intercept of the line formed by these two points, and then graph them. Full instructions on this graph are in the examples section.

Some Examples
Try the following examples in Desmos:

Linear Line
Write the expression $$y=mx+c$$, you will see that the two variables are automatically formed when you press enter. Then mess with the two sliders and notice how one controls the steepness and the other the y-intercept.

Line between two points
Make two points, $$(x_1,y_1)$$and $$(x_2,y_2)$$- you can write subscripts by typing the underscore '_', and then make a variable $$m$$. Set it to equal $$(y_2-y_1)/(x_2-x_1)$$, which is the equation of the gradient. Then we need to figure out $$c$$, the y-intercept. We can substitute the x and y coordinates of one of the points to rearrange the equation. First, $$y_1 = mx_1 + c$$, $$y_1, x_1, m$$are all known variables. We can subtract $$mx_1$$from each side, and we've got our five expressions needed:


 * $$(x_1,y_1)$$
 * $$(x_2,y_2)$$
 * $$m = (y_2-y_1)/(x_2-x_1)$$
 * $$c=y_1-mx_1$$
 * $$y=mx+c$$