MATLAB – Lab Sheet 1 1. Use MATLAB to compute the roots of the following polynomials: a. π(π₯) = π₯ 3 + 8π₯ 2 + 10π₯ + 4 b. π(π¦) = π¦ 5 + 7π¦ 4 + 19π¦ 3 + 25π¦ 2 + 16π¦ + 4 2. Use MATLAB to derive the polynomials having the following roots: a. −6.5708 − 0.7146 + π0.3132 − 0.7146 − π0.3132 b. Two roots at and three roots at π₯ = −2.000 and three roots at π₯ = −3.000 3. Use MATLAB to evaluate the polynomials below at the specified values. a. π(π₯) = π₯ 3 + 8π₯ 2 + 10π₯ + 4 ππ‘ π₯ = 1.25 b. π(π¦) = π¦ 5 + 7π¦ 4 + 19π¦ 3 + 25π¦ 2 + 16π¦ + 4 ππ‘ π¦ = −3.75 4. Define the variables π₯ and π§ as π₯ = 5.3, and π§ = 7.8, then evaluate: π₯π§ 2 π§) (a) (π₯⁄ + 14π₯ 2 − 0.8π§ 2 π₯ 2 π§ π§ π₯ 1⁄ 2 (b) π₯ 2 π§ − π§ 2 π₯ + ( ) − ( ) 5. Define two variables: alpha= 35°, beta= 23°. Using these variables, show that the following trigonometric identity is correct by calculating the value of the left and right sides of the equation: 1 πππ πΌπππ π½ = [cos(πΌ − π½) + cos (πΌ + π½)] 2 6. Two trigonometric identities are given by: (a) π‘ππ4π₯ = π₯ (b) π‘ππ 2 = 4π‘πππ₯−4π‘ππ3 π₯ 1−6π‘ππ2 π₯+π‘ππ4 π₯ 1−πππ π₯ π πππ₯ For each part, verify that the identity is correct by calculating the values of the left and right sides of the equation, substituting π₯ = 17°. 7. Create a row vector with 15 equally spaced elements in which the first element is 9 and the last element is 44. 8. Create a column vector in which the first element is 14, the elements decrease with increments of-3, and the last element is -10. (A column vector can be created by the transpose of a row vector.) 9. Create the matrix shown by using the vector notation for creating vectors with constant spacing when entering the rows (i.e., do not type individual elements). A= 2.5000 42.0000 15.0000 3.0000 3.5000 38.6000 14.6000 2.0000 4.5000 35.2000 14.2000 1.0000 5.5000 31.8000 13.8000 0 6.5000 28.4000 13.4000 -1.0000 7.5000 25.0000 13.0000 -2.0000 10. Create the matrix A in Problem 9, and then use colons to address a range of elements to create the following vectors: (a) Create a four-element row vector named Va that contains the third through sixth elements of the second row of A. (b) Create a three-element column vector named Vb that contains the second through fourth elements of the fifth column of A. 11. Create the matrix A in Problem 9, and then use colons to address a range of elements to create the following matrices: (a) Create a 3 x 4 matrix B from the first, second, and fourth rows, and the first, second, fourth, and sixth columns of the matrix A. (b) Create a 2 x 3 matrix C from the second and fourth rows, and the second, fifth, and sixth columns of the matrix A. 12. For the function π¦ = (2π₯ 2 −16π₯+4)2 , π₯+15 calculate the value of y for the following values of π₯ = −1.2, −0.4, 0.4, 1.2, 2, 2.8, 3.6. Solve the problem by first creating a vector π₯, and then creating a vector π¦, using element-by-element calculations. Make a plot of the points using asterisk markers for the points and a black line connecting the points. Label the axes. 13. Define π and π as scalars π = 3 πππ π = −4, π₯ = [−3, −2.8, −2.6, … , 1.6, 1.8, 2]. Then use these variables to calculate π¦ by: π 2 ⁄π 3 π¦=8 2 π₯ + π 2 ⁄π 3 Plot π¦ π£π π₯. (π‘+3)2 14. For the function π¦ = 6π‘ (1/3) − 2(π‘+4) + 2, calculate the value of π¦ for the following values of π‘: 0, 2, 4, 6, 8, 10, 12, 14, 16, using element-by-element operations. π 15. Use MATLAB to show that the sum of the infinite series ∑∞ π=0(−1) 1 converges (2π+1) to π/4 . Do it by computing the sum for: (a) n = 100 (b) n = 1,000 (c) n = 5,000 In each part create a vector n in which the first element is 0, the increment is 1, and the last term is either 100, 1,000, or 5,000. Then, use element-by-element calculation to create a vector in which the elements are (−1)π 1 (2π+1) . Finally, use the function π π’π to add the terms of the series. Compare the values obtained in parts a, b, and c with the value of π/4. (Do not forget to type semicolons at the end of commands that otherwise will display large vectors.)