In Desmos, you can use the for function to plot points or evaluate a variable for multiple values using a list or to graph a continuous curve with finite or infinite intervals. This function allows you to generalize expressions to answer questions such as “What would be the path of this object if it followed a list of discrete points?” and “What if it followed a curve?”
The function allows you to map a point or an expression across a list or interval. Lists can help you work with multiple values (or elements) simultaneously, while intervals capture all the values that fall within the specified bounds.
Graph Points
If you want to graph three points along the line \(y=1\), you could individually plot \((1,1)\), \((2,1\)), and \((3,1)\). Or, you could use for to do the same thing in a single line: \((a,1)\) for \(a=[1,2,3]\). Changing the point to \((a,a)\) for \(a=[1,2,3]\) will plot three points along a line: \((1,1)\), \((2,2)\), and \((3,3)\).
You can also use the function to graph grids. For example, \((a,b)\) for \(a=[1,2,3], b=[1,2,3]\) graphs a 3x3 grid. In this case, the for function uses the Cartesian product to generate every possible ordered pair where the \(x\)-value is from list \(a\) and the \(y\)-value is from list \(b\).
Explore the example graph to try it out.
Graph Line Segments and Curves
With lists, you can plot points closer and closer together by reducing the interval between the numbers.
Using the earlier example, if you want more than three points to appear, you can shorten the distance between the numbers in the list. For example, \((a,a)\) for \(a=[1,1.1…3]\) plots 21 points of the form \((a,a)\) that are \(0.1\) units apart. To plot even closer points, something like \(a=[1,1.01…3]\) would display 201 points of the form \((a,a)\) that are \(0.01\) units apart.
You can keep reducing the distance to create the appearance of a solid line. Or, you can graph a line using for and an interval. For example, \((a,a)\) for \(1\le a\le3\) graphs a line segment of all the points of the form \((a,a)\) between \(1\) and \(3\). And, \((a,a)\) for \(-\infty\le a\le\infty\) shows all the points that satisfy the condition where the \(x\)-value is equal to the \(y\)-value.
Parameterize a Point over a Geometric Object
In the Graphing Calculator and Geometry Tool, you can use for to graph a geometric object.
For example, \((p.x,2p.y)\) for \(p=\)circle\(((0,0),1)\) generates points along a circle. Then, it then takes each point along the circle and keeps the \(x\)-value the same while multiplying the \(y\)-value by \(2\).
Generalize the Path of the Vertex of a Parabola
You can also use for to generalize the path of the vertex of a parabola.
Start with the function \(f(x)=ax^2+bx+c\). The vertex of the parabola is located at \(V=(-\frac{b}{2a},f(-\frac{b}{2a}))\).
To investigate how the value of \(b\) affects the parabola, start with sliders at \(a=1\), \(b=0\), and \(c=1\).
Then, try changing the values of \(b\). For instnace, if \(b\) is set to \([-5...5]\), the calculator will generate an 11-element list with all of the integers from \(-5\) to \(5\). The expression \(V\) for \(b=[-5...5]\) displays the vertex positions for each \(b\) value.
The expression \(V\) for \(-\infty\le b\le\infty\) will visualize the vertex path for any \(b\) value.
Generalize from Lists of Points to Parametric Curves and Surfaces
You can use for when working with parametric functions, too.
One way to develop intuition for parametric equations is to visualize the path over a list of discrete points before visualizing that same path as a continuous curve within an interval. For example, the parametric equation of a unit circle is \((\cos(t),\sin(t))\). While you can use the special parameter \(t\) to graph this parametric curve, you can also define the interval using any parameter to represent the circumference of a circle.
If you start with a list of values \(c= [0, \frac{\pi}{4}…2\pi]\), the expression \((\cos(c),\sin(c))\) for \(c = [0,\frac{\pi}{4}…2\pi]\) plots eight equally spaced points around the unit circle.
With lists, you can plot points closer and closer together along the curve by increasing the number of elements in the list. Or, you can graph a continuous curve with an interval. For example, \((\cos(c),\sin(c))\) for \(0 \le c \le 2\pi\) graphs the continuous unit circle.
You can also use the same strategies to graph a 3D surface by including a \(z\)-coordinate. For a cylinder with its base on the \(xy\)-plane and a height of \(3\), the unit circle is graphed for all possible \(z\)-values from \(0\) to \(3\). To graph this, you'll need a new new variable for height, like \(h\). The expression would become \((\cos(c), \sin(c))\) for \(0 \le c \le2\pi\), \(0 \le h \le 3\).
Learn More
Please write in with any questions or feedback to support@desmos.com.