0

I was trying to fit this into a module but I didn't have any luck. And for some reason it won't Inverse the Matrix. Here's the code:

Input:

f[x_, y_] = 2^x - y
n = 3
m = Array[f, {n, n}]
k = MatrixForm[m]
Inverse[k]
MatrixForm[UpperTriangularize[m]]

Output:

Output

And here is how the output should look like :

enter image description here

Is it possible to put this into a Module function? Please help!

Andrej
  • 15
  • 2

1 Answers1

2

As pointed out by MarcoB in the comments, one shouldn't use MatrixForm for calculations (check the question he referred to). As he suggested, this is the real reason Inverse doesn't evaluate.

Also, in this case the matrix m is singular. You can easily check that by MatrixRank[m] which yields 2, and also by checking Det[m]==0.

How to proceed with m being singular highly depends on what you are trying to do next with Inverse[m].

Bichoy
  • 1,203
  • 6
  • 15
  • (Thanks for the correction Chris) – Bichoy May 23 '15 at 17:04
  • Ok thanks very much I did it! Only now to implement it into a module. f[x_, y_] = 2^x - y | n = 3 m = Array[f, {n, n}] | MatrixForm[m] | Transpose[m] // MatrixForm | MatrixForm[UpperTriangularize[m]] | – Andrej May 24 '15 at 16:51
  • Then, just put the whole thing into a module, something like: Module[{f,n=3,m}, f[x_,y_] = 2^x -y; m=Array[f,{n,n}]; .... ]. This module will return the value of the last statement being evaluated (but don't terminate the last statement inside with ; ) – Bichoy May 24 '15 at 17:00
  • Wow thanks a lot! I did it. It finally works like it should. – Andrej May 24 '15 at 17:15
  • You are very welcome @Andrej – Bichoy May 24 '15 at 17:22