Desmos Graphing Calculator lets you express equations more flexibly using for and with.
The for keyword is primarily used in two scenarios: parametric representation and iterating through elements of a list.
In Desmos, you can use the variable to create parametric graphs. However, withfor, you can use any variable as a parameter.
is often used to represent time in physics, making it particularly useful in such cases.
Keep in mind that the parameter's range must always be explicitly defined, such as . If you want to represent , you need to use infinity and write .
Interestingly, when using for parametric representation, you can't define an infinite domain like this. This is one of the advantages of using for.
You can create graphs by iterating through the elements of a list like this:
You can also use multiple lists. In this case, all combinations of elements are iterated through.
You can even generate lists using list comprehensions, as shown below:
For more details on using lists, check out the following article:
The with keyword allows you to define the value of a variable. It has two main applications.
You can replace the value of an already defined variable within a specific expression.
For example:
This draws , but:
This draws .
Normally, when you define , can be referenced in all expressions. However:
In this case, cannot be referenced from other expressions.
While this might seem limiting, it helps prevent naming conflicts when working with many variables.
You can achieve the same result by using functions: