0
$\begingroup$

I use Mathematica version 9.0.1.

matA = DiagonalMatrix[ConstantArray[1, 3]];

matB = Normal[SparseArray[{Band[{1, 1}] -> 200, Band[{1, 2}] -> -100, 
 Band[{2, 1}] -> -100}, {3, 3}]];

{matA, matB} gives

{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{200, -100, 0}, {-100, 200, -100}, {0, -100, 200}}}

e1 = Eigenvalues[{matB, matA}] gives an error:

Eigenvalues::exnum: Eigenvalues has received a matrix with non-numerical or exact elements. >>

e2 = Eigenvalues[N@{matB, matA}] gives the answer:

{341.421, 200., 58.5786}

Question: Why would e1 give an error when both matrices are numerical? I don't understand why N@{matB, matA} is needed to get their eigenvalues.

$\endgroup$
6
  • 3
    $\begingroup$ The phrase is "non-numerical or exact". Since the elements do not have decimal places, Mathematica is loathe to introduce imprecision which is required by the algorithm, hence the message. So, by using N you tell it you deliberately add the imprecision, making the decision for it. $\endgroup$
    – rcollyer
    Feb 9, 2014 at 20:45
  • $\begingroup$ @rcollyer You should probably make that an answer. It is the answer. $\endgroup$
    – Szabolcs
    Feb 9, 2014 at 20:50
  • $\begingroup$ @user11946 Can you please choose a display name? The generic "user11946" is hard to remember ... $\endgroup$
    – Szabolcs
    Feb 9, 2014 at 20:51
  • $\begingroup$ @rcollyer - It is subtle but I can see it now. Thanks for the insight. $\endgroup$
    – user11946
    Feb 9, 2014 at 21:12
  • 1
    $\begingroup$ @user11946. No one is asking you to display your real name. Just change your username to something memorable. $\endgroup$
    – RunnyKine
    Feb 9, 2014 at 22:01

1 Answer 1

3
$\begingroup$

This is rcollyer's comment posted as an answer because as Szabolcs says, it is the answer.

The phrase is "non-numerical or exact". Since the elements do not have decimal places, Mathematica is loathe to introduce imprecision which is required by the algorithm, hence the message. So, by using N you tell it to deliberately add the imprecision, making the decision for it.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.