r/desmos • INTRUDER ALERT! GREEN BERNARD IN BASE • 3d ago

Matrices Matrix comparison - prototype

https://www.desmos.com/calculator/n1sjos9dzk

A way of determining whether two matrices are strictly equal

1 Upvotes

7 comments sorted by

•

u/AutoModerator 3d ago

Matrices (Beta feature)

Please note that this does NOT refer to the Desmos Matrix calculator. This matrix update allows the creation and manipulation of matrices in the graphing calculator. Here are (most) features of matrices:

Get started

  • Type in "#43" to create a 4x3 matrix. Drag the handle in the lower right corner to change the size.
  • Perform some matrix math operations. You can multiply and add, raise it to powers (including negative ones), take the transpose with ^T, and use functions like det, rref, and trace.
  • Index a matrix M with M[2;3].
  • Use matrix comprehensions: a+b for a=[1...5];b=[1...4].
  • Take a 2x2 matrix M, and write M(1,2) to transform the point (1,2). You can do the same with a 3x3 matrix and a 3d point.

More features

  • A matrix can itself be an element of a matrix! See the below example.
  • You can use indexing notation to take submatrices. For example, to get row 3,4 and column 1,2,3 of a matrix M, you can either write M[3,4;1,2,3] or M[[3,4];[1,2,3]]. Leaving one of these elements returns the entire row/column. For example, M[1,2;] gets row 1,2 and keeps all the columns.
  • Extract entire rows or columns using .rows and .columns.
  • Lists of matrices of varying sizes are possible. For example, having a 3x1 matrix and 2x2 matrix in the same list is allowed.

    • Because of this, you can't total or sum a matrix list. You can however write a recursive function to do so, e.g. f(L, n) = {L.count = n: L[n], L[n] + f(L, n+1)}. Use it with f(L, 1).
  • Lists inside matrices will broadcast. For example, a 2x1 matrix with elements [2,3,4] and 0 will broadcast into 3 matrices: [2 0], [3 0], and [4 0].
  • Instead of looping a matrix with numbered indices with M.columns.count and M.rows.count, you can instead loop over the columns and rows directly. For example, to calculate the sum of all elements in a matrix, you can write total(v.columns.total for v = M.rows)

Help and Examples

For more, refer to the following articles and example graphs:

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/Professional_Denizen Washed-up Wizard 3d ago

{rank(A-B)=0,0}

If A=B, then A-B must be a zero matrix, and only zero matrices have rank of zero.

1

u/R3d5t0n3_GUY INTRUDER ALERT! GREEN BERNARD IN BASE 3d ago

Even if I put the rank check in a piecewise function, it would still broadcast this error

1

u/R3d5t0n3_GUY INTRUDER ALERT! GREEN BERNARD IN BASE 3d ago

Even when using a case that theoretically wouldn’t call the rank

3

u/Desmos-Girl https://www.desmos.com/calculator/prarjlycol 3d ago • Heartwarming

piecewise the matrix itsself (rank(A-{dim check:B,A} and add a seperate dimension check after

alternatively unique can be used to compare arbitrary objects, eg 2-[A,B].unique.count

1

u/R3d5t0n3_GUY INTRUDER ALERT! GREEN BERNARD IN BASE 3d ago

Tysm for this! It helps me to see what people think of my prototyping and how they can simplify it

1

u/Professional_Denizen Washed-up Wizard 3d ago

Yeah, I somehow forgot that throwing an error instead of returning “false” might be undesirable.

I guess in my head (beneath the surface) I had gone through the thought process: “Why would you try to check if two differently-sized matrices are the same; you already know the answer.” But it never occurred to me that you might want to use this in a larger project where you’re not working with matrices of definitive size.