dimanche 13 janvier 2019

how to use for loop and if statement

The first problem is calculating the inverse matrix of (z-A) where z is a set of different complex numbers and A is a 2×2 matrix. The second problem is after computing the 2-norm of the set of inverse matrix, compare it with a certain number, how to write an if statement so that the set of z can be plotted on the graph with eigenvalues of A if the 2-norm of the inverse matrix of (z-A)is larger than this number.

I have tried to generate different complex numbers, and calculate the 2-norm.

A <- matrix(c(1, 0, 0, 1), 2, 2, byrow=TRUE)
ev <- eigen(A)
z <- complex(real = stats::rnorm(100), imaginary = stats::rnorm(100))
for (i in 1:100) {X <- solve(z-A)}
Y<- norm(X, "2")
a <- 0.1
if(Y > a){ }

The expect final graph should be a circle in the complex graph with its centre at (1,0), which is the eigenvalue of matrix A.

Aucun commentaire:

Enregistrer un commentaire