Broadcasting Explained
Broadcasting is a feature in Desmos that allows for operations involving lists that would normally not work with lists. In short, under certain contexts, operations on Desmos lists will instead be applied separately on each element of the list, before being merged back together in the same order to create a new list. This is best shown with an example.
In an ordinary programming language, an expression like would be an error— it doesn't usually make sense to add a list of numbers to a number. However, Desmos uses broadcasting to apply the addition operation to each element separately. As a result, evaluates to . Broadcasting works on list-list operations too— evaluates to , for example. Here are a few more examples:
- evaluates to
- evaluates to
- evaluates to
- evaluates to
In some cases Desmos may end up broadcasting a list in one context, but not broadcast it in another context, even if both contexts exist within the same expression:
The second expression here evaluates to . In the portion, the list is not being broadcasted when it's used in , because treats it as a list to retrieve its maximum element (in this case ). However, when is added to its maximum via the "" part, it is being broadcasted, because Desmos is trying to add a list to a number.
In some rare cases, you might want to force Desmos to broadcast a list. In these case you can use a list comprehension with the list you want to force-broadcast as a parameter. However, these cases tend to be very rare, so don't do this by default.