Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Reflecting Bear Background Panda Bear is confused. He is trying to work out how things should look when reflected in a mirror, but is getting
Reflecting Bear
Background
Panda Bear is confused. He is trying to work out how things should look when reflected in a mirror, but is getting the wrong results. In Bear's coordinates, the mirror lies along the first axis. But, as is the way with bears, his coordinate system is not orthonormal: so what he thinks is the direction perpendicular to the mirror isn't actually the direction the mirror reflects in Help Bear write a code that will do his matrix calculations properly!
Instructions
In this assignment you will write a Python function that will produce a transformation matrix for reflecting vectors in an arbitrarily angled mirror.
Building on the last assingment, where you wrote a code to construct an orthonormal basis that spans a set of input vectors, here you will take a matrix which takes simple form in that basis, and transform it into our starting basis. Recall the from the last video,
TETEE
You will write a function that will construct this matrix. This assessment is not conceptually complicated, but will build and test your ability to express mathematical ideas in code. As such, your final code submission will be relatively short, but you will receive less structure on how to write it
Matrices in Python
For this exercise, we shall make use of the @ operator again. Recall from the last exercise, we used this operator to take the dot product of vectors. In general the operator will combine vectors andor matrices in the expected linear algebra way, ie it will be either the vector dot product, matrix multiplication, or matrix operation on a vector, depending on it's input. For example to calculate the following expressions,
ast
sAt
MAB
One would use the code,
a s @ t
s A @ t
M A @ B
This is in contrast to the
operator, which performs elementwise multiplication, or multiplication by a scalar.
You may need to use some of the following functions:
invA
transposeA
gsBasisA
These, respectively, take the inverse of a matrix, give the transpose of a matrix, and produce a matrix of orthonormal column vectors given a general matrix of column vectors ie perform the GramSchmidt process. This exercise will require you to combine some of these functions.
How to submit
Edit the code in the cells below to complete the assignment. Once you are finished and happy with it press the Submit Assignment button at the top of this notebook.
Please don't change any of the function names, as these will be checked by the grading script.
If you have further questions about submissions or programming assignments, here is a list of Q&A You can also raise an issue on the discussion forum. Good luck!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started