MAT491 - Lab 2

Q0.

  • Assign your name to a variable called "my_name".
  • Assign your student id to variable "stud_id".
  • Use variable "my_name" and "stud_id" to print your name and your student id using "print" function in the following format:

    Your Name - Your Student ID

  • For example:

    Ali bin Abu - 2000123456


In [ ]:


In [52]:
%pylab inline
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D


Populating the interactive namespace from numpy and matplotlib

Q1.

  • Assign your name to a variable called "my_name".
  • Assign your student id to variable "stud_id".
  • Assign your group name to variable "group".
  • Use variable "my_name", "stud_id" and "group" to print your name, your student id and your group using "print" function in the following format:

    Your Name - Your Student ID - Your Group Name

  • For example:

    Ali bin Abu - 2000123456 - RCS12345


In [ ]:

How to create vector: https://docs.scipy.org/doc/numpy/user/basics.creation.html

Example: To define vector $\vec{v} = <1, 2, 3>$, type

v = np.array([1, 2, 3])

Dot product/scalar product/inner product (Calculus, Stewart pg 824): https://docs.scipy.org/doc/numpy/reference/generated/numpy.inner.html

Example: The dot product of two vectors $\vec{u}$ and $\vec{v}$ is

np.inner(a, b)

Length of vector: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.norm.html

Example: The length of vector $\vec{v} = <1, 1, 1>$ is

np.linalg.norm(v)

Vectors

Find the angle between the planes $x + y + z = 3$ and $x - 2y + 3z = 2$.

Q2. Step 1: Define the normal vectors of these planes n1 and n2.


In [ ]:

Q3. Find the dot product of n1 and n2 and assign it to variable d.


In [ ]:

Q4. Calculate the product of the length of vector n1 and n2 and assign it to variable nn.


In [ ]:

Q5. Calculate the division of d and nn and assign it to variable ac.


In [ ]:

Q6. Calculate the angle between the planes by calculating the arccos of ac.


In [ ]:

End of questions.