MA2895 Summer Assignment: Corrections, Comments and FAQ

Links to the FAQ.

Finding the eigenvalues and eigenvectors of a triangular matrix A degree 4 polynomial interpolant, the secant method, the areas, the centroids and some graphics

Corrections/Comments

  • The command to use in Matlab to create the zip file to submit is on page 2 and uses one of the files sent to you. The command has a name ending with _summer_cr_zip_file. The version sent on Wed 15th July has the instruction on page 12 to be consistent with this. There was a mistake in the Fri 10th July version.
  • The cr_zip.m has worked correctly for several students but one reported that it did not work in their environment. I cannot reproduce the problem in my environment but sending a slightly modified version of cr_zip.m solved the problem for that student. If anyone else has problems with the page 2 test then please let me know. The contents of the shorter version of cr_zip.m is available here

    Answers to FAQ plus some comments

    Finding the eigenvalues and eigenvectors of a triangular matrix

  • The starting version of your function file already allocates space for the eigenvalues lambda and the matrix V whose columns are the eigenvectors and thus you do not need to do this again. Also, you should not be changing the triangular matrix. The starting version also determines the number of columns in the matrix which you need in the algorithm. Your task is to implementing the algorithm to set the entries in lambda and V.
  • If you have a loop then take care if the index is going forwards or backwards.
  • If you change the function file and you have not yet created the script file to test it then I recommend that you at least do the optional test shown on page 6 to check that the function does run.

    A degree 4 polynomial interpolant, the secant method, the areas, the centroids and some graphics

  • As a comment, the function file for evaluating the degree 4 interpolating polynomial is similar to one of the questions in the February class test. The February class test involved a degree 2 polynomial interpolant. Please make sure you test the function and this will happen if you evaluate the function when plotting it.
  • What you need to add to the function file can be just one (long) statement to determine the output y at x using the other interpolation parameters. (One statement was used in the class test question.) It may be more manageable however to have 6 shorter statements with 5 of these for getting the value of each of the Lagrange basis functions and the final statement to combine the 5 quantities to set y. If you wish to break things down further then you could have one statement to evaluate the denominator part of each of the Lagrange basis functions. If you choose this version then it will be 11 short statements which should be easy to check.

    You do not need to create any functions as part of this function file.

  • In the programming part of the partly graphics task the statements for items numbered as 2, 3, ..., 7 must all be in the script file with name which contains test_deg4_etc. You only will only be considering the function file again if you note any mistakes when you are trying to use in your script file.
  • You can use the Matlab function find() to help you determine the row vector called pos() in item 3.
  • There is only 1 figure to create but there are several things to add to the figure if you do all parts. To be able to add to an existing figure you use a set-up of the form
    figure(id)
    clf
    hold on
    
    At the end of the file, or at least after the last graphics command, it is good to put
    hold off
    
  • In the secant iteration you can use a for--loop with a maximum of about 20 steps. You do not know in advance how many iterations will be needed but since you start near the solution the convergence should be fast and you are likely to have the required accuracy with between 5 and 8 iterations. If it has not converged by 20 steps then something is probably wrong in the implementation.

    If you use a while loop then take care to ensure that the iteration will end.

  • Remember that it is 4 roots and 3 areas that you compute.