List basics
Separate values with commas and surround them with square brackets to create a list.
2
[ ( 1 , 2 ) , ( 4 , 1 ) ] [(1,2),(4,1)] [( 1 , 2 ) , ( 4 , 1 )]
Lists may also contain points or vectors, but every item in one list must have the same type. Placing a list inside an expression draws several graphs at once.
x = [ 2 , 4 , 7 ] x=[2,4,7] x = [ 2 , 4 , 7 ] y = [ 1 , 3 ] x + [ 3 , 2 ] y=[1,3]x+[3,2] y = [ 1 , 3 ] x + [ 3 , 2 ] 3
[ ( 1 , 2 ) , ( 2 , 4 ) ] [(1,2),(2,4)] [( 1 , 2 ) , ( 2 , 4 )] 4
( x , y ) f o r x = [ 0 , 1 ] , y = [ 0 , 1 ] (x,y)\ \mathrm{for}\ x=[0,1],y=[0,1] ( x , y ) for x = [ 0 , 1 ] , y = [ 0 , 1 ]
Open in Desmos ↗
Creating lists
Three periods abbreviate an arithmetic sequence and allow its length to depend on another variable.
1
[ 1 , 2 , . . . , 5 ] = [ 1 , 2 , 3 , 4 , 5 ] [1,2,...,5]=[1,2,3,4,5] [ 1 , 2 , ... , 5 ] = [ 1 , 2 , 3 , 4 , 5 ] 2
[ 3 , 3.1 , . . . , 3.5 ] = [ 3 , 3.1 , 3.2 , 3.3 , 3.4 , 3.5 ] [3,3.1,...,3.5]=[3,3.1,3.2,3.3,3.4,3.5] [ 3 , 3.1 , ... , 3.5 ] = [ 3 , 3.1 , 3.2 , 3.3 , 3.4 , 3.5 ] 4
[ 1 , 2 , . . . , n ] = [ 1 , 2 , 3 , 4 ] [1,2,...,n]=[1,2,3,4] [ 1 , 2 , ... , n ] = [ 1 , 2 , 3 , 4 ]
for provides list-comprehension syntax.
1
[ 2 i f o r i = [ 1 , 2 , 4 ] ] = [ 2 , 4 , 8 ] [2i\ \mathrm{for}\ i=[1,2,4]]=[2,4,8] [ 2 i for i = [ 1 , 2 , 4 ]] = [ 2 , 4 , 8 ] 2
[ 1 f o r i = [ 1 , 2 , . . . , 100 ] ] [1\ \mathrm{for}\ i=[1,2,...,100]] [ 1 for i = [ 1 , 2 , ... , 100 ]]
Lists in expressions
Desmos substitutes each element into the expression and draws the resulting graphs.
2
x 2 + y 2 < [ 1 , 3 ] x^2+y^2<[1,3] x 2 + y 2 < [ 1 , 3 ] 3
A = [ 0.5 , 1 ] A=[0.5,1] A = [ 0.5 , 1 ] 2 sin ( A x ) 2\sin(Ax) 2 sin ( A x )
Open in Desmos ↗
Multiple lists are paired by position: ([1,2],[3,4]) draws ( 1 , 3 ) (1,3) ( 1 , 3 ) and ( 2 , 4 ) (2,4) ( 2 , 4 ) . Use for when you need every combination.
Using for
1
y = a x f o r a = [ 1 , 2 , 3 ] y=ax\ \mathrm{for}\ a=[1,2,3] y = a x for a = [ 1 , 2 , 3 ] 2
( x , y ) f o r x = [ 1 , 2 , 3 , 4 ] , y = [ 2 , 3 , 4 ] (x,y)\ \mathrm{for}\ x=[1,2,3,4],y=[2,3,4] ( x , y ) for x = [ 1 , 2 , 3 , 4 ] , y = [ 2 , 3 , 4 ]
Open in Desmos ↗
See for and with for more details.
Selecting elements
Append an index in square brackets. Desmos uses one-based indexing.
1
A = [ 2 , 4 , 5 ] A=[2,4,5] A = [ 2 , 4 , 5 ] 4
B = [ 1 , 3 , 5 , 8 ] B=[1,3,5,8] B = [ 1 , 3 , 5 , 8 ] 5
∑ n = 1 4 B [ n ] = 17 \sum_{n=1}^{4}B[n]=17 ∑ n = 1 4 B [ n ] = 17
Indices may themselves be lists, ranges, or conditions.
1
A = [ 2 , 4 , 6 , 8 , 10 ] A=[2,4,6,8,10] A = [ 2 , 4 , 6 , 8 , 10 ] 3
A [ 2 , . . . , 4 ] = [ 4 , 6 , 8 ] A[2,...,4]=[4,6,8] A [ 2 , ... , 4 ] = [ 4 , 6 , 8 ] 4
A [ 3 , . . . ] = [ 6 , 8 , 10 ] A[3,...]=[6,8,10] A [ 3 , ... ] = [ 6 , 8 , 10 ] 5
A [ B ] = [ 2 , 4 ] A[B]=[2,4] A [ B ] = [ 2 , 4 ] 6
C = [ 1 , 2 , . . . , 10 ] C=[1,2,...,10] C = [ 1 , 2 , ... , 10 ] 7
C [ C > 8 ] = [ 9 , 10 ] C[C>8]=[9,10] C [ C > 8 ] = [ 9 , 10 ]
Use [1,3,4].count or count([1,3,4]) to obtain a list’s length.