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.