I often have to generate symmetric matrices so I created this simple online utility that does it for me. It lets you generate symmetric matrices of any size you need. It works in the browser and is powered by alien technology from the future.

## Symmetric Matrix Generator Options

## Symmetric Matrix Generator Examples (click to try!)

1 7 1 2 2 8 7 1 1 7 5 9 8 5 6 0 9 2 1 9 1 4 1 3 4 8 9 2 8 4 2 2 2 4 4 6 2 5 1 2 3 7 4 8 9 8 6 3 2 7 6 2 0 0 7 0 4 4 4 2 7 2 4 1 9 8 4 8 0 2 0 8 1 2 9 6 9 0 4 8 1

2.09 1 1 1 0 1 2.03 0 1 1 1 0 2.58 1 0 1 1 1 2.28 0 0 1 0 0 2.36

❼ ⓪ ④ ⑦ ① ⑤ ② ⑤ ① ④ ⓪ ❻ ⑤ ② ⑥ ⑤ ⑤ ② ⑨ ② ④ ⑤ ⓿ ④ ② ⑨ ② ④ ④ ⓪ ⑦ ② ④ ❻ ② ③ ⑥ ⑤ ⑥ ⑨ ① ⑥ ② ② ❾ ④ ⑧ ⑧ ⑥ ② ⑤ ⑤ ⑨ ③ ④ ❽ ⑤ ⑤ ① ⑤ ② ⑤ ② ⑥ ⑧ ⑤ ❷ ⓪ ② ② ⑤ ② ④ ⑤ ⑧ ⑤ ⓪ ❷ ④ ⑦ ① ⑨ ④ ⑥ ⑥ ① ② ④ ❸ ⑨ ④ ② ⓪ ⑨ ② ⑤ ② ⑦ ⑨ ⓿

λ α α α α β α α α λ α α α β α β α α λ β β β α β α α β λ α β α α α α β α λ β β β β β β β β λ α α α α α α β α λ β α β β α β α β λ

✸ ✷ ✹ ✵ ✹ ✷ ✸ ✸ ✸ ✸ ✲ ✹ ✺ ✸ ✺ ✹ ✲ ✷ ✷ ✲ ✵ ✷ ✵ ✹ ✵ ✺ ✺ ✹ ✹ ✵ ✲ ✺ ✺ ✵ ✷ ✷ ✵ ✺ ✷ ✲ ✺ ✷ ✸ ✵ ✷ ✹ ✸ ✵ ✺ ✺ ✷ ✵ ✲ ✲ ✷ ✺ ✹ ✺ ✷ ✷ ✹ ✲ ✹ ✸ ✹ ✵ ✵ ✸ ✵ ✹ ✷ ✲ ✸ ✲ ✺ ✷ ✵ ✲ ✲ ✷ ✹ ✸ ✷ ✺ ✷ ✷ ✲ ✹ ✲ ✹

🃏 ♠ ♥ ♥ ♣ ♠ ♠ 🃏 ♥ ♠ ♣ ♣ ♥ ♥ 🃏 ♠ ♣ ♣ ♥ ♠ ♠ 🃏 ♦ ♠ ♣ ♣ ♣ ♦ 🃏 ♥ ♠ ♣ ♣ ♠ ♥ 🃏

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

53 79 49 40 60 53 66 45 27 72

## How Does This Symmetric Matrix Generator Work?

This symmetric matrix generator works entirely in your browser and is written in JavaScript. A symmetric matrix can only be square and has the property `a`

, which means its elements with respect to the main diagonal are identical. In the code, such matrices are implemented using two-dimensional arrays. If a matrix has the size _{ij}=a_{ji}`n×n`

, then the starting two-dimensional array that represents it looks like this `matrix = [[],[],…,[]]`

, where empty cells `[]`

appear `n`

(or `size`

) times. To generate this array, the generator calls `matrix.push([])`

for a total of `n`

times. To fill the inside arrays with elements it uses two `for`

loops. Since the values in upper and lower matrix parts are duplicates, the outer loop runs from `i = 0`

to `i = size - 1`

and the inner loop runs from `j = i`

to `j = size - 1`

. It uses three complex math formulas to generate the matrix elements `matrix[i][j]`

. For integer values, it calculates `r()*(end-start)+start`

, for fractions it calls `Math.floor(r()*(end-start+1))+start`

, and for custom elements it runs `elemArr[Math.floor(r()*elemArr.length)]`

, where `r()`

is the `Math.random()`

function. The array `elemArr`

is created from the custom matrix elements option `elements`

. The variables `start`

and `end`

are also specified in the options. If `i == j`

, then the diagonal options are used, if `i != j`

, then non-diagonal options are used. The lower part of the matrix is filled by copying elements from the positions `matrix[i][j]`

to positions `matrix[j][i]`

. To print the `matrix`

double array, it turns it into a string by calling the `join(elSeparator)`

function for the internal arrays (`elSeparator`

is the symbol that separates the matrix elements) and `join(rowSeparator)`

for the external array (`rowSeparator`

is the symbol that separates the matrix rows).

### Created by Browserling

This symmetric matrix generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our programmer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.