# FindInstance of Matrices

I'm trying to use FindInstance to find examples of matrices that complete an expression. However, it seems like I need to specify atomics as my variables to the function. So, here's a really simple example of what I'm trying to do.

A simple test condition could be that my d-dimensional matrix lol should be the identity matrix on those d dimensions. Here's some naive code that doesn't work

FindInstance[lol==IdentityMatrix[3],PopulateMatrix[lol,3]]


Where

PopulateMatrix[symbol_, dimension_] :=
Flatten[Table[
Table[symbol[[i, j]], {j, 1, dimension}], {i, 1, dimension}]]


I feel like this must be close to a correct solution, but it feels ugly. PopulateMatrix[lol,3] returns a desired list of expressions {lol[[1, 1]], lol[[1, 2]], lol[[2, 1]], lol[[2, 2]]} that look like they should play nicely as variables for FindInstance, but it screams at me while doing so, saying that lol[[2,1]] is longer than the depth of the object, because I've not initialised lol as a matrix, but I don't know how to do that.

Any help would be appreciated!

• lol = Array[s, {3, 3}]; FindInstance[lol == IdentityMatrix[3], Flatten@lol] Dec 16, 2015 at 17:03
• This seems strange to me- why can we call upon s within array without mathematica complaining that s[[3,1]] doesn't exist, but I can't call upon lol[[3,1]] in FindInstance without setting it up? Dec 16, 2015 at 18:00
• I'm using s[3,1] ,not s[[3,1]] !! Dec 16, 2015 at 18:07
• Compare Head[s[3, 1]] with Head[s[[3, 1]]] Dec 16, 2015 at 18:09
• ah, awesome. thanks, I didn't immediately spot that subtlety Dec 16, 2015 at 18:18