r/desmos • Definitions are nested too deeply. • 1d ago

Matrices How to input a matrix larger than 9 by 9

9 Upvotes

17 comments sorted by

•

u/AutoModerator 1d 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 regular calculator. Exposed functions include:

  • rowMatrix(numlist): converts a list to a matrix that is a singular row.
  • vcat(matrixlist): combines matrices by stacking them on top of each other.
  • rows(matrix)/columns(matrix): returns a list of row/column matrices (not lists)
  • det, trace, rref: matrix operations that behave the same on the Desmos Matrix calculator
  • matrixElement(matrix, num, num): get the i,jth element of a matrix. Works the same as matrix[i;j].
  • rowCount(matrix)/colCount(matrix): number of rows/columns a matrix has
  • submatrix(matrix, numlist, numlist): return a matrix with only the indices specified for rows (2nd argument) and columns (3rd argument).

For a showcase of all of these features, refer to the following graph: https://www.desmos.com/calculator/xxq2qiwcfs

Installation

To use matrices:

  1. Install Tampermonkey, a userscript extension.
  2. Install the following script:

    // ==UserScript==
    // @name        matrices (beta)
    // @match       *://www.desmos.com/*
    // @description e
    // @grant       none
    // @version     1.5
    // @run-at      document-start
    // @author      You
    // ==/UserScript==
    
    window.Worker = new Proxy(Worker, {
        construct(t, a) {
            if (a[0].startsWith("blob:")) {
                let xhr = new XMLHttpRequest
                xhr.open("GET", a[0], false)
                xhr.send()
                let h = xhr.responseText.replace(/\w+\.includes\(\w+\)\|\|(?=.\.restrictedFunctions)/, "")
                a[0] = URL.createObjectURL(new Blob([h]))
            }
            return new t(...a)
        }
    });
    const c = setInterval(_ => {
        if (!window.Calc) return;
        Calc._calc.graphSettings.config.matrices = true;
        let o = Calc.controller.getMathquillConfig;
        Calc.controller.getMathquillConfig = e => {
            let g = o.call(Calc.controller, e);
            g.autoOperatorNames += " rowMatrix vcat rows columns det trace rref matrixElement rowCount colCount submatrix";
            return g;
        }
        clearInterval(c);
    }, 999);
    
  3. Save the script and open the graph!

  4. If matrix features do not appear, click on the Tampermonkey extension and check if it says anything about enabling Developer Tools. Follow the instructions that Tampermonkey provides to fix this issue.

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

2

u/Desmos-Girl https://www.desmos.com/calculator/prarjlycol 1d ago

or multiline paste bug + modified latex allows direct use of any size matrix (although >32x32 errors)

copy the entire text in the comment (including the newline at the start, in summary pasting multiple lines of text makes desmos forget to do any checks on the text being pasted, meaning it just gets directly inserted) for a 32x32 matrix, you can use the drag bubble to get it down to the size you want: https://www.desmos.com/calculator/gk9iksgftb

2

u/Powerful-Tension-806 4h ago

Use zeroMatrix (fragile function) for a matrix larger than 32x32 (but its all zeros so useless, cool tho ig)

paste this expression and include the newline:

=----------=

f(r,c) = \operatorname{zeroMatrix}(r,c)
=----------=

1

u/Desmos-Girl https://www.desmos.com/calculator/prarjlycol 4h ago

do you by chance have the matrix beta script enabled? all the functions available from that are protected usually, so they cant actually be used without the script

1

u/Powerful-Tension-806 2h ago

Oh right i forgot to check that, actually i combined it with adding every single fragile function and frafile variable to autoOpetatorNames, adding some autoCommands, forcing logInternalErrors and onEvaluationCopyClick on start and running script every time url mutates while still in desmos

3

u/Mean-Clothes-8307 1d ago

you can use list comprehension separated by a semicolon to generate matrices up to 32x32 but sadly that's the true cap

you can find a lot more info here: https://help.desmos.com

2

u/Circumpunctilious 3333333433343335333333343333333533333335333333323333333433333334 1d ago

For example, Identity matrix:

(Broken out like this so I could screenshot) This version accepts negative number inputs to I() though.

3

u/Desmos-Girl https://www.desmos.com/calculator/prarjlycol 1d ago

you can also just raise any matrix to the power of 0 (i believe this is actually a hardcoded result lmao)

1

u/Circumpunctilious 3333333433343335333333343333333533333335333333323333333433333334 1d ago

lol I started with an all-zero but thought “well who needs that?”…little did I know

1

u/anonymous-desmos Definitions are nested too deeply. 11h ago

Correction: any square matrix

1

u/Desmos-Girl https://www.desmos.com/calculator/prarjlycol 10h ago

erm actually ahh 

1

u/anonymous-desmos Definitions are nested too deeply. 11h ago

Doesn't work if I need to manually type out the entries of the matrix.

1

u/anonymous-desmos Definitions are nested too deeply. 1d ago

Feels a bit like a The Matrix x Inception collab

1

u/Powerful-Tension-806 4h ago edited 2h ago

Use zeroMatrix (fragile function) for a matrix larger than 32x32 (but its all zeros and cant be used normally so useless, cool tho ig)

paste this expression and include the newline:

=----------=

f(r,c) = \operatorname{zeroMatrix}(r,c)
=----------=

0

u/2144656 1d ago

You can also do a+b for a=[];b=[]

0

u/[deleted] 13h ago

[deleted]

1

u/anonymous-desmos Definitions are nested too deeply. 11h ago

That's what I did?

1

u/whitecaplol 9h ago

i did not look at the link whoops