Generate a Triangular Matrix
Upper or lower triangular. Runs entirely in your browser, so your data never leaves your device.
Output
The result appears here as you type.
How to use Generate a Triangular Matrix
- 1. Set the matrix size. Enter Size (n) for the dimension of the square matrix. Triangular matrices are always square, since only rows above or below the diagonal hold non-zero entries.
- 2. Choose upper or lower triangular. Set Type to Upper triangular for non-zero entries above the diagonal, or Lower triangular for non-zero entries below it, matching whichever convention your exercise or software expects.
- 3. Set the value range and diagonal option. Enter Minimum element and Maximum element for the non-zero entries, and toggle Unit diagonal to force every diagonal entry to 1 instead of a random value.
- 4. Copy the generated matrix. Copy the matrix into a linear algebra exercise on LU decomposition, determinant computation, or any tool that specifically expects a triangular structure.
When to use Generate a Triangular Matrix
Generate a Triangular Matrix produces a random upper or lower triangular matrix, where every entry on one side of the main diagonal is zero. Triangular matrices show up throughout linear algebra, especially in LU decomposition, since their determinant is just the product of diagonal entries.
- Teaching that triangular matrix determinants multiply diagonals. Students learning that a triangular matrix's determinant equals the product of its diagonal entries can verify the shortcut directly against a generated example before trusting the rule.
- Practicing LU decomposition by hand. LU decomposition exercises need both an upper and lower triangular matrix as targets. Generating each separately, with a matching value range, gives students consistent practice material.
- Testing a triangular solve function. Numerical libraries often have a specialized forward or backward substitution solver for triangular systems, and testing it needs a genuinely triangular input matrix, not just a general square one.
- Building a unit diagonal example for permutation work. Toggling Unit diagonal produces a matrix with 1s on the diagonal, a common requirement in certain decomposition conventions where the diagonal is fixed rather than random.
Examples
A random 3×3 upper triangular matrix
Output
4 7 2 0 9 1 0 0 8
About the Generate a Triangular Matrix tool
Generate a Triangular Matrix runs as plain JavaScript in your browser tab, with no server behind it. Upper or lower triangular. Whatever you put in stays on your device from start to finish.
The tool is part of EditSafely's Math Tools section, 234 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.
You can shape the output with 5 settings, including Size (n), Type, Minimum element and Maximum element, and the result refreshes the moment you change one. A worked example further down the page shows exactly what the tool produces for a real input.
That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, results are instant because nothing round-trips to a server, and it is safe to use with confidential material.
Frequently asked questions
Does Generate a Triangular Matrix cost anything?
Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.
Does the generator send anything to a server?
No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.
How do I get a different result?
Run the generator again. Each run is computed fresh on your device, and any options you change are applied to the next result immediately.
Do I need to sign up or install anything?
Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.
How do I use the result?
The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.