Evaluates a square matrix at a function.
func | The function to be evaluated. |
mat | The matrix to be used. |
return value | func(mat) |
(Diagonalisable matrices are supported currently.)
a = [827,444;42,888];
a = a/max(abs(eig(a)));
e = ejs.funcAtMatrix(@(x) x^3, a)
e - a*a*a
e = ejs.funcAtMatrix(@(x) x^827, a)
eig(e)
// Compares the power series to the evaluation.
n = 5;
a = rand(n)
a /= (max(abs(eig(a)))+1e-8); // so as to avoid numerical instability in the powers
f = ejs.funcAtMatrix(@(x) exp(x), a)
e = eye(n);
q = e;
for (j=1; j<18; ++j) {
q *= a/j;
e += q;
}
max(abs(e-f))