Question

NEED HELP WITH PROBLEM 1 AND 2 OF THIS LAB. I NEED TO PUT IT INTO PYTHON CODE! THANK YOU!

LAB 9 - ITERATIVE METHODS FOR EIGENVALUES AND MARKOV CHAINS 1. POWER ITERATION The power method is designed to find the domin• For an nxn diagonalizable matrix A with real eigenvalues ordered by 11. > ... > Anl, define an initial guess xo. • For j fr[ ] import numpy as np Problem 1 [] # This function approximates the dominant eigenvector of our matrix A. def evect_approx1(

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import numpy as np
A=np.array([[1,1],[2,0]])#creating A matrix
def evect_approx1(x_0,k):
   x_vect=0
   for j in range(1,k+1):#loop from j=1 to k
       x_vect=np.dot(A,x_0) #eigen vector formual for next iteration
       x_0=x_vect
   return x_vect #return final result
print(evect_approx1(np.array([1,9]),10))

import numpy as np
A=np.array([[1,1],[2,0]])#creating A matrix
def evect_approx1(x_0,k):
   lambda_1=0
   for j in range(1,k+1):#loop from j=1 to k
       x_vect=np.dot(A,x_0)
       x_0=x_vect
       lambda_1=(np.dot(A,x_vect)/x_0)[0]#eigen values can be 2 in this case we are considering only one to get desired output
   return lambda_1
print(evect_approx1(np.array([1,9]),10))

follow indention to get desired output

[8] import numpy as np A=np. array([[1,1],[2,0]]) #creating A matrix def evect_approx1(x_,k): X_vect=0 for j in range(1, k+1)

Add a comment
Know the answer?
Add Answer to:
NEED HELP WITH PROBLEM 1 AND 2 OF THIS LAB. I NEED TO PUT IT INTO...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT