Access to h: | LaTeX | Finding roots of cubics tasks | Partly graphics task | FDM task |
General comments | cube_root_fun | cardano_fun | test_cubic_iter | cubic_plot | basic_fdm | numerov_fdm | test_fdm |
Click here for the Brunel connect portal http://connect.brunel.ac.uk
For a VPN connection you need to click on the box to the left of ``AnyConnect'' and then click on Next. If you are doing this for the first time then you will need to click on ``New Device'' to get a device in this list. I am not in a position to test this at the moment but from what I can remember it is at this stage that you will download and install the software on your computer.
After you have registered your device this should appear in the the list of devices.
Please always check what is currently said although in case it helps the link (click here) contains what it showed for me on Fri 27th March 2020.
From the window which had the ``AnyConnect'' link mentioned earlier there is a link with which says ``Brunel Files''. You should click on that and follow the instructions to access your h: drive. The instructions here depends on the user.
If you need further help then please send an email to
CEDPS-IT@brunel.ac.uk
h:\mybin20if you did the initial set-up instructions. If you cannot access the h: drive now, or it is more difficult, then a zip file called mybin20.zip containing most the files is available if you click here.
I do not specify exactly what should be shown but ir should give an indication that the iteration is converging. In $b$ is given and the function is $\phi(a)=a^3-b$ then showing that the norm of the $\phi$ values is decreasing rapidly is sufficient. In the test with 101 values on a circle I do not want to see 101 values for each stage of the iteration. It is your choice whether or not you should the values when the number of values is small (say 1 or 2).
The letters used in the description vary from student to student. If I use a_0, a_1, ... here then a_0 corresponds to b^{21/64}, a_1 is from the Newton step and a_2, a_3, ... are from the even faster method.
When numbers are small you should use the %e format. If you use the %f format then it will probably just show 0 which is not a satisfactory display.
axis equal clf figure fill hold off hold on plot titleI do also use the following when I am running many scripts.
close all printthe command ``close all'' closes all figures and ``print'' is used to get a hard copy version. I used print to generate the .eps file that you were sent and used in the file print2pdf.m to help generate the .pdf graphics file that you were sent.
format compact x=[0.1, 0.2, 0.3] y1=sin(x)./x y2=sin(x)/x y3=sin(x)\xThe output generated is as follows.
x = 0.100000000000000 0.200000000000000 0.300000000000000 y1 = 0.998334166468282 0.993346653975306 0.985067355537799 y2 = 0.988380498729264 y3 = 0 0 0 0 0 0 0.338386336182412 0.676772672364825 1.015159008547237The output given by y1 is what is wanted. More complicated computations are taking place in the case of y2 and y3. If you type
doc slashthen this will explain what happens in the y2 and y3 cases.
format compact b=[9, -1+1i]; phi =@(a) a.^3-b; a3=[2, 0.8+0.8*1i]; vrow=phi(a3) vcol=phi(a3(:))When you run this you get the following.
vrow = -1.00000 + 0.00000i -0.02400 + 0.02400i vcol = -1.00000 + 0.00000i 9.00000 - 1.00000i -10.02400 + 1.02400i -0.02400 + 0.02400iThe different output is because the vector b used in the definition of phi has the shape of a row vector. The evaluation of phi needs to be with the vector having the same shape as b in your cube root iteration. Thus in the above the first version using the row vector a3 is likely to be what is intended. With releases of Matlab within about the last 2 of 3 years the other version with a3(:) no longer gives an error but creates a matrix, i.e. it does not breakdown with a column vector minus a row vector. The norm of vrow and vcol are thus different.
To deal with any shape of b, and assuming that a3 has the same shape as b, to get a column of entries for the function evaluation it is best to put
vcol=phi(a3); vcol=vcol(:);
v=phi(a); dv=dphi(a); a=a-v./dv;The above assumes that functions phi and dphi have already been set-up. Note also, you do not have to put everything in one statement. In the version above the term v can be used in a test without needing to use phi() again.
For a plot of a circle to look a circle you need the statement
axis equal
If you are not ready to do the part involving creating uexdd for your specific problem then you can use other simpler functions.
Both methods are exact when uex is just x^2 and hence you could use the following in a test.
a=-1; b=2; q =@(x) ones( size(x) ); uex =@(x) x.^2; uexdd =@(x) 2*ones( size(x) );The Numerov method is also exact when uex is x^4 and thus you can check with the last 2 lines replaced by the following.
uex =@(x) x.^4; uexdd =@(x) 12*x.^2;
A\cNote that it is backslash.