Answered step by step
Verified Expert Solution
Question
1 Approved Answer
LAB 1: VECTORS AND GEOMETRY, PART A (c)2017 UM Math Dept licensed under a Creative Commons By-NC-SA 4.0 International License. 1. Objectives and Expectations for
LAB 1: VECTORS AND GEOMETRY, PART A (c)2017 UM Math Dept licensed under a Creative Commons By-NC-SA 4.0 International License. 1. Objectives and Expectations for Lab 1, Part A In Part A of Lab 1, our main goal is to make use of MATLAB to study vectors, planes, and lines in the context of physical and real life problems that involve these objects. We have the following objectives. You will become proficient in using MATLAB for basic vector operations such as vector addition, dot product, and cross product, etc. You will work on vector projection using MATLAB. Projections are used quite often in data analysis. You will practice solving numerically physics problems in multi-dimensional settings, and be familiar with notions of acceleration, velocity, and trajectories in several dimensions. 2. Matlab Commands 2.1. [u1 ,u2 ,. . . ] Brackets define a list in MATLAB, and it treats vectors as lists. So, to define a vector u = h1, 3, 5i in MATLAB we use the command: >> u=[1,3,5] 2.2. norm(x). The command norm(x) returns the `2 -norm kxk (that is, magnitude, or Euclidean lengthwhat q we think of as length) of a vector x = hx1 , x2 , ... , xn i, given by kxk = x12 + x22 + xn2 . Examples: >> norm([3,4]) (the result is, of course, 5); and >> v = [3, 3, 4, 1]; norm(v) (which gives 5.9161, not 35MATLAB thinks numerically). 2.3. dot(u,v). The command dot(u,v) returns the dot-product u v of two vectors u and v that are of same length. Examples: >> dot([3,4], [1,2]) >> ans = 11 >> v = [3, 3, 4, 1]; u= [0, 1, -1, 2]; dot(u,v) >> ans = 1 Note that MATLAB keeps track of whether calculations make sense: >> v = [3, 3, 4, 1]; u= [0, 1, -1]; dot(u,v) will throw the error ans = Error using dot (line XX) A and B must be same size. 2 LAB 1: VECTORS AND GEOMETRY, PART A 2.4. cross(u,v). The command cross(u,v) returns the cross-product u v of two vectors u and v that are of length 3. Examples: >> cross([3,4,4],[1,2,-1]) >> ans = -12 7 2 >> v = [3, 4 , 0]; u= [0, 1, -1 ]; cross(u,v) >> ans = 4 -3 -3 2.5. acos(x). The command acos(x) returns arccos(x) for a real number x [1, 1]. If 1 x 1, then acos(x) returns real numbers in the interval [0, ]. acos : [1, 1] [0, ]. Otherwise, it will return a complex number. Examples: >> acos(-1) >> ans = 3.1416 >> acos(0.5) >> ans = 1.0472 >> acos(1) >> ans = 0 >> acos(1.2) >> ans = 0.0000 + 0.6224i In general, a complex answer is not what we want. 2.6. plot(x,y). The command plot(x,y) takes as its arguments a vector x and another vector y, and plots successive pairs of (x, y ) coordinates. Thus, >> plot( [0, 1, 2, 3, 4], [0, 1, 4, 9, 16] ) will plot five points along the parabola y = x 2 . Most functions in MATLAB are vector-aware, so that they accept a vector as an argument. Thus we can plot five points of the arccosign function with >> x = [0,1,2,3,4]; plot( x, acos(x), 'o' ) (the 'o' uses a circle as the plot symbol), and can plot a smooth function (with a blue line) with >> x = [-1:0.01:1]; plot(x, acos(x), '-b') 2.7. plot3(x,y,z). The command plot3(x,y,z) plots in three dimensions the curve whose x, y , and z-coordinates are given by the vectors x, y, and z. Thus >> t = [0:.02:12]; plot3( 2*cos(t), 2*sin(t), t, '--r' ) plots (with a dashed red line) a helix extending up along the z-axis. 3. Exercises 3.1. Basic vector operations. You will want to recall from the prelab the formulas for calculating a unit vector and the angle between two vectors. Exercise 1: Compute a unit vector eu in the direction of the vector u = h1, 0.5, 3, 2i using the formula u 1 u= eu = kuk kuk LAB 1: VECTORS AND GEOMETRY, PART A 3 We use norm(u) to compute the `2 -norm (Euclidean length, magnitude) kuk of the vector u. Exercise 2: Consider the (parametric) line equation r(t) = h1, 0, 2i+th2, 3, 1i, t R. Plot the line segment r(t) = h1, 0, 2i + th2, 3, 1i, 0 t 5 in R3 . Exercise 3: Given the intersecting lines x = 1 + t, y = 1 + 2t, 2.5t, tR and x = 3 + 2s, y = 1 + 1.2s, 5 + 1.2s, s R, Compute the angle 0 (in radians) between them. 3.2. Projections. Recall from the prelab how to find the projection of one vector on another, and a perpendicular vector. Exercise 4: Find the projection projv (u) of u = h1, 4, 3.4, 1i onto the vector v = h4, 2.5, 1, 8i. Exercise 5: Find a unit vector v that is perpendicular to u = h0.82, 6.45, 1.07i. Hint: Use projection onto u. Once you find such v, verify numerically that uv = 0 (so that these vectors are perpendicular). How many such vectors v are there? 3.3. Equations of planes. We did not develop the equation of a plane in the prelab, but it is described in detail in your textbook, [JS]. Exercise 6: Given u = h6, 3.2, 1i and v = h3, 4, 1.84i, find a unit vector w such that w is perpendicular to both u and w. Hint: There are only two such unit vectors. You do not need to use any projections in this case. Recall the properties of the cross-product of two vectors. References [JS] Stewart, James. Calculus. Eighth edition. Boston, MA:Cengage, 2016. LAB 1: VECTORS AND GEOMETRY, PART B (c)2017 UM Math Dept licensed under a Creative Commons By-NC-SA 4.0 International License. 1. Objectives and Expectations for Lab 1, Part B Part B of Lab 1 contains less guidance. You are expected to answer problems that are more challenging than the ones in Part A. The material covered and the assignments in Part A is instructive for completing Part B. 2. Matlab Commands 2.1. [a:h:b]. The command [a:h:b] generates an ordered list of numbers (a, a + h, a + 2h, a + 3h, ... , a + nh) where n is the largest positive number such that a + nh b. Examples: >> [1:0.2:2.4] which gives the list [1.00 1.20 1.40 1.60 1.80 2.00 2.20 2.40], and >> [1:0.4:2] which gives [1.0000 1.4000 1.8000]. This command is useful for creating equally spaced set of parameters or coordinates. 2.2. linspace(a,b,h). linspace[a,b,n] creates n equally spaced (linearly spaced) list of numbers between the points a and b, including a and b. Example: >> tset = linspace(0,2,9) which sets tset to be the list [0 0.25 0.5...2]. 2.3. plot(x,y). The command plot(x,y) takes as its arguments a vector x and another vector y, and plots successive pairs of (x, y ) coordinates. Thus, >> plot( [0, 1, 2, 3, 4], [0, 1, 4, 9, 16] ) will plot five points along the parabola y = x 2 . Most functions and operations in MATLAB are vector-aware, so that they accept a vector as an argument. Thus we can plot five points on the parameteric curve r(t) = h1 + 3t, sin(t)i with >> t = [0,1,2,3,4]; plot( 1+3*t, sin(t), 'o' ) (the 'o' uses a circle as the plot symbol), and can plot a smooth function (with a blue line) with >> x = [-1:0.01:1]; plot(x, acos(x), '-b') 2.4. plot3(x,y,z). The command plot3(x,y,z) plots in three dimensions the curve whose x, y , and z-coordinates are given by the vectors x, y, and z. Thus >> t = [0:.02:12]; plot3( 2*cos(t), 2*sin(t), t, '--r' ) plots (with a dashed red line) a helix extending up along the z-axis. 2 LAB 1: VECTORS AND GEOMETRY, PART B 3. Exercises 3.1. Dot product and cross product of vectors. Consider the 1-parameter family of vectors v(t) given by t(1 sin(t)) cos(t) x(t) , t R. (1 t cos(t)) sin(t) v(t) = y (t) = 1 z(t) 7 (3 sin(t) + 2t cos(t) 5t sin(t) cos(t)) Observe that v(0) = (0, 0, 0). We will obtain numerical evidence for the fact that the family of vectors {v(t)}tR lie on a plane. Exercise 1: Pick a nonzero vector u from the family by setting u = v(t1 ) for some t1 R. Compute the normal vectors n(t) = u v(t) of the planes determined by u and v(t) for values of t between 0.1 and 1000 to numerically verify that changing t does not rotate n(t), but scales n(t). Use the values of t generated by the MATLAB command >> tlist=[0.1:0.01:1000]; Plot the tip of the vector n(t) as t varies in this range. 3.2. Projections. Data that are obtained at successive instants in time are called time-series data. Often such data are generated from a sensor or sensors, and in any real-life application the sensor readings will have some error, or news. In this exercise we consider how we might work with such data. For the problem, consider set of points \u0010 (1) S = (3, 7.4), (4.5, 9), (1.32, 5.43), (9.18, 14.8), \u0011 (1.369, 5.05), (7.847, 13.922), (6.7765, 12.385), (3.1162, 7.688) and suppose that it is data received from a sensor. We can stored these in a sequence of 2-dimensional vectors x1 = h3, 7.4i, x2 = h4.5, 9i, x3 = h1.32, 5.43i, x4 = h9.68, 14.6i, ..., x8 = h3.4162, 7.988i. Exercise 2: Plot these points (vectors). What type of trend do you see? Exercise 3: Suppose that all of the data points x = hx1 , x2 i should actually lie on the line (2) r(t) = h1, 5i + th0.16, 0.2i, t 0. Plot the data points and the line on which we expect the points to lie (to plot both together, you can use the MATLAB plot command with multiple arguments: plot( x1, y1, 'ok', x2, y2, '-b' ) will plot the x coordinates in the list x1 against the y coordinates in y1 with black circles, and the x coordinates in x2 against the y coordinates in y2 with a blue line). Observe that the data points do not lie on the line. LAB 1: VECTORS AND GEOMETRY, PART B 3 Exercise 4: Remove the noise from this data set. You can to this by mapping each data point xj onto a point xj on the line where the distance of the point xj from the line is minimal. (Hint: you can use orthogonal projections, first subtracting the vector h1, 5i from the data set, then compute the orthogonal projection of these vectors onto the direction vector of the line, then add h1, 5i back to find the de-noised data. Think about what this will do for one point.) 3.3. Equations of lines and planes. Exercise 5: Given the planes 4.2(x 3.32) 5.28(y 1) + (z + 2) = 0 and (x + 2.42) + 2(y 7.34) 1.1(z 2) = 0, compute the angle between them. References [JS] Stewart, James. Calculus. Eighth edition. Boston, MA:Cengage, 2016
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