source('../Chapter3/utils.R') source('utils.R') A = matrix(data=c(-2, 0, 1, 0, 0, -2, 0, 1, 1, 0, -2, 0, 0, 1, 0, -2), nrow=4, ncol=4, byrow=FALSE) ##print(A) M = matrix(data=c(2, 1, 0, 0, 1, 2, 1, 0, 0, 1, 2, 1, 0, 0, 1, 2), nrow=4, ncol=4, byrow=FALSE) ##print(M) n = dim(A)[1] ## The eigenvalues are the roots of the following function: ## natural_frequency_fn = function(x){ determinant_from_GE(A - x * M) } ## Lets get a feel for where the zeros of det(A - lambda M) lie: ## xs = seq(-3.5, +0.5, length.out=1000) ys = sapply(xs, natural_frequency_fn) plot(xs, ys, 'l', ylab='det(A-xM)') grid() res = mullers_iteration(c(-4.0, -2.0, 0.0), natural_frequency_fn, n, verbose=FALSE) print(res)