# Mathematica will not run Arnoldi method while using NIntegrate

This is simplified version of my real code:

mat[x_] := {{x^2, 1, 0}, {1, x^2, -1}, {0, -1, x}}
ei[x_] := Eigensystem[
mat[x],
1,
Method -> {"Arnoldi", "Criteria" -> "RealPart"}
][[1, 1]]
NIntegrate[ei[x], {x, 0, 4}]


and Mathematica gives me this error:

Eigensystem::arm: Method -> Arnoldi can only be used for matrices of machine- or arbitrary-precision real numbers.


I tried changing WorkingPrecision of NIntegrate, fixing the precision, and changing the code to:

mat[x_] := SetPrecision[{{x^2, 1, 0}, {1, x^2, -1}, {0, -1, x}}, 20]
ei[x_] := Eigensystem[
SetPrecision[mat[N[x, 20]], 20],
1,
Method -> {"Arnoldi", "Criteria" -> "RealPart"}
][[1, 1]]
NIntegrate[ei[N[x, 20]], {x, 0, 4}, WorkingPrecision -> 20]


Still did not help. Why this is happening?

I need to use Arnoldi method to find the eigenvalues and eigenvectors, since my real matrix is very big and I am interested in couple of eigenvalues and eigenvectors.

• You need to insert x_?NumericQ somewhere in your definitions to thwart the attempt at symbolic preprocessing. – J. M.'s ennui Jun 11 '16 at 15:58
• @J.M., I have changed the declarations of the variables in the functions with x_?NumericQ, as well as added the option: Method -> {Automatic, "SymbolicProcessing" -> False}. Did not help, I am still getting the error. – gurluk Jun 11 '16 at 16:04
• Are the values you're getting with this actually correct though? – Feyre Jun 11 '16 at 16:57
• @Feyre, you mean eigenvalues, or the result of the integration? – gurluk Jun 11 '16 at 17:00
• @gurluk: part of your problem is that you are thinking in terms of "declarations", a concept from other programming systems. This is foreign to Mathematica. x_NumericQ is not a declaration, but a constrained pattern, a very different beast. – John Doty Jun 11 '16 at 17:16

mat[x_?NumberQ] := {{x^2, 1, 0}, {1, x^2, -1}, {0, -1, x}}
ei[x_] :=
Eigensystem[mat[x], 1,
Method -> {"Arnoldi", "Criteria" -> "RealPart"}][[1, 1]]
NIntegrate[ei[x], {x, 0, 4}]


(* 8. *)

• This does not get rid of the error message, nor change anything. – Feyre Jun 11 '16 at 17:02
• It worked for you? :) What? I am copying the same code and it still gives the same error? haha – gurluk Jun 11 '16 at 17:02
• This works. For those who say it doesn't (@Feyre) : probably you forgot to clear your old definitions of mat that don't contain the restriction! So I'd suggest adding Clear[mat] in front of the answer. – Jens Jun 11 '16 at 17:09
• @rewi, now works. – gurluk Jun 11 '16 at 17:13
• @Jens, I cannot believe the problem was actually so small and easy. I was expecting something related to arbitrary precision, I think I overthought :) Thank you both. – gurluk Jun 11 '16 at 17:13