Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a function called largest eig ( ) and add it to your HW 2 . py file. This function will determine the largest eigenvalue

Create a function called largest eig() and add it to your HW2.py file. This
function will determine the largest eigenvalue and its associated eigenvector with
the power method as discussed in class. The function should take the matrix
A, an allowed error tolerance, and a maximum iteration number as input and
produce both the highest eigenvalue of A and its eigenvector along with the
final error and iteration number. In order to ensure standard output between
everyones implementation, scale the eigenvector so that the largest absolute
value of the eigenvector is equal 1. The function should take the following
inputs in this order:
numpy array A : the matrix that defines the linear system
float epsilon: the error tolerance
int max it: the maximum allowed number of iterations
And produce the following outputs in this order:
float: eig: the largest eigenvalue
numpy array x: the eigenvector corresponding to the largest eigenvalue
int n it: the number of iterations taken to reach solution
float error : the calculated error in the last iteration
The error for this case should be computed by calculating the relative error
between the eigenvalue of the current and precvious iteration:
error =|(\lambda subi+1\lambda subi)\\lambda subi+1|
where i is the iteration number. Please write in python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. How do you expect to use active listening during the meeting?

Answered: 1 week ago