Reflect matrix about y_axis

I want to reflect a given matrix about the y_axis, say:
A = [[1,2], [3,4]]
I used the numpy function, np.fliplr(A) but the test said I was wrong. I then used the numpy function, np.flip(A,1) and still wrong. Please, can anyone help me with reflecting A about the y_axis? Thanks
NB: The matrix above is not the one in the test.

2 Likes

I assume you either want to swap rows or columns. If that is the case I think it may be easier to do it manually like A[[0,1]] = A[[1,0]] for swapping rows, or A[:,[0,1]]= A[:,[1,0]] to swap columns.

1 Like

The wording of the problem confused me a bit at first, but I think they’re looking for a 2x2 matrix A_reflection_yaxis that, when multiplied with a vector [x, y], will result in a vector that is a reflection of [x, y] over the y-axis, i.e. A_reflection_yaxis multiplied by [x, y] = [-x, y]. Hope this helps.

1 Like

I used np.array([[-1,0],[0,1]]) and used the function np.linalg.eig and getting the error 'There was a problem compiling the code from your notebook. Details:
unsupported operand type(s) for *: ‘NoneType’ and ‘int’

1 Like

yes, I think what you used is similar to what I used. I reasoned that the matrix in question are the basis vectors arranged as columns.

1 Like

Still no reply from the instructors?, its been 10 days

2 Likes

It’s resolved @Abdullah_Q

1 Like

I did it but it still not working for me
as original matrix = [[2, 3], [2, 1]]
and yaxis_reflected_matrix = [[-2, 3], [-2, 1]]
and it gives me complex numbers in eigenvectors and eigenvalues (“Error”)

1 Like

IIRC, the original matrix that you are referring to has nothing to do with the exercise you are asking about. I believe they are asking for a 2x2 matrix that transforms a 1x2 vector into its reflection across the y-axis. In other words, can you find a 2x2 matrix A, such that for any 1x2 vector x, the product Ax will equal the reflection of x across the y-axis.

The reflection of any point (x,y) across the y-axis is (-x,y), so we are looking for the matrix A such that A × [x y]^T = [-x y]^T.

2 Likes

Oh, thank you. I found it but I didn’t expect that he want that answer from me as I get matrix multiplication of A = \begin{bmatrix} 2 && 3 \\ 2 && 1 \end{bmatrix} with y = \begin{bmatrix} -1 && 0 \\ 0 && 1\end{bmatrix} and the result = \begin{bmatrix} -2 && 3 \\ -2 && 1 \end{bmatrix}

1 Like

I made the same error. Thank you for your persistence in asking the question.

2 Likes

I am getting the same issue (error with complex numbers). I used the same approach when defining the reflection around the Y axis. [[-2,3], [-2,1]]. Unclear how to get around this issue.

1 Like

@Vince_Kegel How Are You I hope you a good health
First He didn’t ask you to make operation multiplication
of Matrix He just wanted the values of the Reflection of Y-Axis


This Image Illustrates what values you enter in your matrix
ask me if you misunderstand this

ATEF

8 Likes

You are correct. Thank you. I need to read the instructions carefully.

1 Like

Thanks @Atef_Yasser. Your clarification was really helpful. I do think that the wording in the exercise is very confusing and it took me a while to figure out what matrix was being asked just by reading the instructions.

2 Likes

Yes the wording is quite confusing. Thank you

1 Like

Thank you!
¡Muchas gracias!
:pray:t5:

1 Like

Thanks @Atef_Yasser for solving my confusion here.

I think that’s the variable name causing the confusion here, if the assignment can rename “A_reflection_yaxis” to “yaxis_reflection_matrix” it will be much clearer.

1 Like

I have spend quite long to figure it out what it is actually asked to do . We do not have to reflect the matrix A about y-axis and we also not asked to find the reflection of the transformation matrix , simply we need to find the reflection of basis vector (1,0) and (0,1) in which y coordinate will remain the same only x coordinate will change its sign ,I hope this will make sense to everyone .

4 Likes

Yea, they def need to change the wording, because it leads you to believe that they want you to transform A into A’, where A’ is the reflection of A. Where A was the same matrix in the first question.

1 Like