All problems
Shifted Power Method Step
Problem
Perform one shifted power iteration step on matrix A with shift mu and nonzero vector v.
Compute w = (A - mu*I)*v, the Rayleigh estimate lam = mu + (w . v) / (v . v), and return [lam, w / ||w||_2].
Hint
The Rayleigh quotient is w . v over v . v before adding the shift back.
Test cases
case 1
in: [[[2,0],[0,3]],0,[1,1]]
expected: [2.5,[0.5547001962252291,0.8320502943378437]]
case 2
in: [[[2,0],[0,3]],1,[1,1]]
expected: [2.5,[0.4472135954999579,0.8944271909999159]]
case 3
in: [[[4,1],[2,3]],0,[1,1]]
expected: [5,[0.7071067811865475,0.7071067811865475]]
case 4
in: [[[4,1],[2,3]],2,[1,0]]
expected: [4,[0.7071067811865475,0.7071067811865475]]
Starter codePython
def shifted_power_step(A, mu, v):
# Your code here
pass4 test cases · run your code against them in the editor