Q: Make a 2D array of stored values in graphing calculator?

Dear Desmos folks,

What is the best way to make a 2D array of stored values in the Desmos graphing calculator? Obviously this is easy to do in Desmos | Matrix Calculator , but I don’t think matrices can be used within the normal calculator interface (or maybe they can?). My aim is to have a spatial grid of stored numerical values that the user can interact with.

I have seen people doing this, e.g. in Conway life Desmos implementations, by stretching out the grid into a long 1-D vector and then calculating the index of an element in terms of the number of rows and cols. That works, but it’s a bit clunky.

A list of lists might also work, but when I try to do this in Desmos it says “Cannot store a list of numbers in a list”. I also thought I might be able to define each grid element in a function-like way, e.g. v_alue(1,2) = 7. However, Desmos seems, not unreasonably, to require a function of x and y to be defined as an algebraic expression of x and y, not as a look-up table of arbitrary values attached to pairs of grid-coords.

Is a stretched-out 1D list of length num_rows*num_cols the only option?
Many thanks,

Raj

Have you tried list comprehensions? That might do what you’re looking for.

Thanks for the note. Sorry, I should have also mentioned those in my original post. It is quite likely that I am not exploiting the full power of list comprehensions. I know how to use them to make a 2D coordinate grid that can be used as the input for some algebraic function of x and y, e.g. this 2D wave:

However, what I am after is a 2D grid in which arbitrary numerical values can be stored, just like a standard 2D array in NumPy or the like. For that, the value in each grid location would not be derivable via some function from the x,y coords, but instead would be stored as a look-up table. It is very possible that list comprehensions could allow this, but if it is possible I don’t know how!

Currently my guess is that the best way to do this in Desmos will be via a long 1D-list, with ind2rowcol and rowcol2ind helper functions to convert between the grid-like and the 1D representations. A bit clunky, but it should work.

Raj

Oh, my bad. I read too quickly. I see what you mean… yes, it would be great if we could have lists of lists, and lists of latex. So many things would be easier! Yes, for activities where I’ve used a rectangular array of m by n, I’ve just made a list that goes from 1 to m*n. I’m not sure of any other way to get around this. Maybe Jay has some tricks up his sleeve?