Variables and Sliders

One of the most fundamental parts of the Desmos Graphing Calculator is variables. Variables set parameters that can change the entire graph globally when changed. This wiki has information about some uses of variables and some examples.

## Variable and Slider Properties

To create a variable, make an expression and then type a variable name followed by a '=' sign and a value which can be many things including a number, an expression, an action, and more into that expression. If the value is a number, a slider will pop up which allows you to change the value of the variable. It is possible to slide this slider by dragging the circle. It is also possible to press the play button to make the variable change in a specific way defined by the Animation Mode. Here are the four parameters you can control on a variable/slider:

* Restrictions: The maximum and minimum values the slider can take while moving in accordance with the Animation Mode or by dragging the slider manually.

* Step: The distance between two adjacent positions on the allowed slider values.

* Animation Speed: The speed at which the variable changes in accordance with the Animation Mode.
* Animation Mode: The way at which the variable changes.

There are four animation modes which are looping, repeatedly playing in the same direction, one time run, and indefinitely running. It is common to use the looping mode, however the others are also useful. For example, it is possible to use the indefinitely play mode to record time in your graph(although this could be achieved better with actions). The step setting is also an useful mode. In graphs, there might be a necesity to make calculations that involve whole numbers, or even numbers, which can be achieved by using the step setting. A switch also might be needed and this can be achieved by setting the step so that the slider alternates between two positions. Restrictions are very useful for most people that use Desmos because they allow keeping the graph inside of the viewbox and stop lines from becoming infinitely steep! By default, the maximum restriction is set to 10 and the minimum restriction is set to -10. The default step size is 0, the Animation Mode default is looping, and the default Animation Speed is 1x.

## Movable Points

Try typing

(
a
,
b
)

{\displaystyle (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.

# y
m
x
c

{\displaystyle 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

)

{\displaystyle (x\_1,y\_1) }

and

(

x
2

,

y
2

)

{\displaystyle (x\_2,y\_2) }

- you can write subscripts by typing the underscore '\_', and then make a variable

m

{\displaystyle m}

. Set it to equal

(

y
2

−

y
1

)

/

(

x
2

−

x
1

)

{\displaystyle (y\_2-y\_1)/(x\_2-x\_1)}

, which is the equation of the gradient. Then we need to figure out

c

{\displaystyle c}

, the y-intercept. We can substitute the x and y coordinates of one of the points to rearrange the equation. First,

y
1

=
m

x
1

c

{\displaystyle y\_1 = mx\_1 + c}

,

y
1

,

x
1

,
m

{\displaystyle y\_1, x\_1, m}

are all known variables. We can subtract

m

x
1

{\displaystyle mx\_1}

from each side, and we've got our five expressions needed:

* (

x
1

,

y
1

)

{\displaystyle (x\_1,y\_1) }
* (

x
2

,

y
2

)

{\displaystyle (x\_2,y\_2) }
# * m
(

y
2

−

y
1

)

/

(

x
2

−

x
1

)

{\displaystyle m = (y\_2-y\_1)/(x\_2-x\_1)}
# * c

y
1

−
m

x
1

{\displaystyle c=y\_1-mx\_1}
# * y
m
x
c

{\displaystyle y=mx+c}