As usual start Maple and load all the linear algebra progams. If you still have some topics from previous labs to complete, feel free to work on them too after completing this lab. We will be plotting graphs of functions this lab, so use: > with(plots); You can plot points using this command: > p1:=plot([[-1,5],[2,4],[3,-1]],style=point, symbolsize=30,colour=blue); The matrix for the exact fit quadratic for this system of equations is > E2:=<<1,1,1>|<-1,2,3>|<1,4,9>|<5,4,-1>>; Use Pivot/RowOperation to find the solutions to this system of equations to get the coefficients of a quadratic polynomial which you can define as > y:= x -> something + something *x + something * x^2 ; You can then plot this polynomial using: > p2:=plot(y(x),x=-2..4); Note that the curve passes through all three points by using > display({p1,p2}); Check this using: > y(-1); > y(2); > y(3); Note that we can also make the Vandermonde matrix directly: > A2:=VandermondeMatrix(<-1,2,3>,3,3); Repeat with polynomials of degree 3 through these points: [-1,3], [-2,6], [4,-12] the system of equations in this cases is: > E3:=,3,4) |<3,6,-12>>; Solve for a+b*x + c*x^2 +d*x^3 using > LinearSolve(E3,free=t); to see that a=-8*t, b=-3-10*t, c=-t, d=t, where t is any number. You can plot the family of polynomials of degree 3 like this: > p3j:=t->(t*x^3 - t*x^2+ (-10*t-3)*x - 8*t); > animate( plot, [p3j(t),x=-3..4.5, color=green], t=-4..4, trace=4, frames=50 ); To animate the plot you click on the image and then press the "play" button that is now in the toolbar at the top. Note how every cubic curve passes through all 3 specified points. When t=0 the cubic curve is actually a straight line, not a quadratic! Verify this using > p3j(0); and see that the homogeneous solution is as expected with > factor(p3j(x)-p3j(0)); Pick 5 random points and create the system of equations to find a straight line through them as follows: > randomise(1000*time[real]()): > xv:=RandomVector(5,generator=-6..6); > M:=VandermondeMatrix(xv,5,2); > yv:=RandomVector(5,generator=-3..7); Use this command to plot your points: > p5:=plot((xv,yv),style=point, symbolsize=30,colour=red); Predict what slope and intercept you think your line will have. We can now create the best fit straight line as follows: > MTM:=Multiply(Transpose(M),M); > MTy:=Multiply(Transpose(M),yv); Find the solution to MTM times v = MTy, which gives the best fit line, by using RREF, inverses or by using LinearSolve. Give it as > z:=x-> something + something *x; Find the differences between the polynomial and the data points using: > zv:=evalf(,20); > dzy:=zv-yv; > Multiply(Transpose(dzy),dzy); Now repeat with the same xv and yv to plot the best fit quadratic to your data and check the differences, and then the cubic. You can create the polynomial and copy and paste it with a command such as this: > Multiply(Transpose(LinearSolve(MTM,MTy)),<1,x,x^2>); Verify that the sum of the squares of the differences of the quadratic are smaller than the sum of the squares of the differences of the line and both are smaller than those of the cubic. These are questions from a past lab test, you are given an M different from your neighbours and then asked to do things to it like this. Not so hard, hopefully! e.g. M := Matrix(3, 3, [[24, 6, -24], [-5, 5, 0], [23, 7, -24]]) Q1: (8 marks) Only using the command RowOperation to get an integer solution to M v = z where > z:=Matrix(3,1,[0,0,0]); Q2: (3 marks) Get the other eigenvalues of M using any suitable method. Q3: (6 marks) Find another eigenvector of M using Pivot or RowOperation, call it w. Q4: (3 marks) Multiply MatrixPower(M,2) and w to identify an eigenvalue of the square of M. Why wouldn't MatrixInverse(M) have w as an eigenvector too?