Polska wersja
Scientific Computing 2020-21
Tuesday lecture
1015am in room 5870, lab 1215pm room 2041(lab)
Attention - how the course would look like
The interactve lecture and lab will be on zoom (detail on the moodle: moodle )
The solutions of homeworks and projects and reports (instead of an oral exam if one wishes..) should be uploaded also on
moodle - details below.
Please upload the
homework and project solutions as octave scripts to
moodle .
CHAT
I started a chat channel on
chat.mimuw.edu.pl: #on-sciecomp-2020-21-wt-1015-1345; here there is a
link. In case zoom does not connect you will have to work yourself and I will try on Tue 1015-1345 reply your questions on the chat.
Exam
Project (25%) and lab short problems (solved in the lab) 50% - oral exam (or a theoritical report)
25%.
During the exam one should show (now due to pandemia upload to moodle) a short report (2-3 pages details in project section) and the code (working) and answer a few questions concerning
the material presented in the lectures.
ORAL EXAM or a theoretical report
There two options for an oral exam : classical - we set a date and time and connect on google meet or
a short report on a given subject extending knowledge from our course - e.g. describe how to solve in LAPACK eignvalue problem what functions are available how to use them a short
code using them etc or sparse matrices what formats are available with some details...
I will propose a few subjects, see below.
Questions/problems for the oral exam.
Three questions. I will ask one question and the examinee may pick the other two.
Lecture
I will give here a brief program on moodle
- Lect no 1: introduction - what is this course about etc What is octave..
Some notes concerning the lecture:
SC20_21.pdf
Office hours:
Plan.
(room 5010 - IV floor).
- during classes only, otherwise please contact me by e-mail
Homeworks - lab problems
Each lab problem will have a due date.
Lab short problems which are late (showed me after the due date), will obtain the graded no of points multiplied by 0.8 (if late up to 2 labs; or 0.5 if later).
I will naturally postpone all dedlines of the home problems due to the
extraordinary situation.
Next lab
Octave scripts or source C files
Projects
References
- Piotr KrzyĹźanowski,
Obliczenia in�ynierskie i naukowe. Skuteczne, szybkie, efektowne, Wydawnictwo Naukowe PWN, 2011
-
Piotr KrzyĹźanowski,
Obliczenia naukowe.
Html lecture notes (in Polish). Pdf version is also available there. University of Warsaw. 2010.
Lab
- Lab LINUX BASICS AND OCTAVE :
- linux basics: cd, ls, rm, cp, pwd, mv, tar, mkdir, rmdir, chmod, head, tail, more, cat, man.
-
Basics of octave - octave as a scientific calculator, semicolon :
how to create a matrix,
saving/loading from/to files in different formats;
basic matrix/vector operations - opt. solving linear equations and LLSP
etc
- Sone simple problems
- Create matrices 3x4 A and 3x5 B -
then the matrix 3x8 C with 3 first columns are A and next B. Create D 3x3 as a main minor of C oi.e. from C(1,1) to C(3,3).
Change the order of columns of D. Compute sin on elements of D.
Write D to a file (binary or ascii) - change D(1,1) to -100 and load this new matrix to octave as DD.
Compute 1st norm of DD.
- Compute a discrete max norm of (sin(x))^2 on [0,1] (on 10000 points)
- Create a text file with any 3x3 matrix in a proper octave format and load it to octave.
- Plot a graph of sin(x) on [0,4]. Do the same for x*(sin(x)+2).
- Compute an approximation of the derivative
by central difference on [0,4] on N+1 equidistant points with h=4/N N=100 i.e. compute Dcf(xk)=0.5(f(xk+h)-f(xk-h))/h for xk=4*k*h k=1,..,N (equidistant points on [0,4].
Can it be done without a loop? Compare with the values of analytical derivative at those points i.e. er(xk;h)=|Dcf(xk)-f'(xk)| compute Er(h)=max_k(er(xk;h)).
Check the order of approximation i.e. take once N=100 then N=200 and compute Er(h)/Er(h/2) or plot er(xk;h)/er(xk;h/2).
Repeat the problem for forward and backward differences respectively (fwd diff: (f(xk+h)-f(xk))/h; bck diff (f(xk)-f(xk-h))/h)
- Compute an approximation of the 2nd order derivative
by 3point difference on [0,4] on N+1 equidistant points with h=4/N N=100 i.e. compute D2f(xk)=(f(xk+h)-2f(xk)+f(xk-h))/(h*h) for xk=4*k*h k=1,..,N (equidistant points on [0,4].
Compare with the values of analytical 2nd derivative at those points i.e. er(xk;h)=|D2f(xk)-f''(xk)| compute Er(h)=max_k(er(xk;h)).
Check the order of approximation.
Lab -
scripts: example
matbasic.m
write on command line of octave'a: matbasic.
lab1.m some solutions
matB.txt an xample of a saved matrix (can be loaded into an octatave session)
- Lab - functions, m-files, basic linear algebra, solving the systems, LLSP, norms, matrix factorizations: Cholesky, LU, QR, eigenvalue problems etc
- Write a m-file with a function which has two parameters x and a and returns
f(x;a)=x^a and its derivative as a 2nd returned value; default value of a is one.
- Solve any linear 2x2 system e.g. A=[1,2;3,4] f=[1;3], x=A\f - test if residual vector f-A*x is zero, and if we get the right solution (if we know it) here the solution =[1;0]
- Solve any simple regular LLSP - e.g. A=[1,1;1,2;3,4] f- the 1st column of A - x=A\f - is the computed solution equal to the 1st unit vector ie. to [1;0]?
- A simple problem - polynomial interpolation; and linear regression as a LLSP
- using vander() and polyval() and backslash - solve linear regression problem
for givem x_k,y_k find a,b such that \sum_k |ax_k+b -y_k|^2 is minimal.
Compare with polyfit(). Write a function which for two parametes being the vecors x and y (of the same length) returns the vector wit hthe parameters [a;b] of the linear regression problem.
More demanding version : The function should check if the problem has a unique solution (up to fl calculations naturally)? How to do it withou using rank(), svd(), or null() functions?
HINT: perhaps we can use qr() instead of backslash?
- find Lagrange interpolating polynomial on equidistant points on [-5,5] for f(x)=1/(1+x*x) -
compute discrete max norm of the error on [-5,5] and at interpolation nodes
Test for 5,10,20 and 30 nodes.
- do same as in the previous problem but for Chebyshev points (linearly scaled roots of T_n(x)=cos (n*arc cos(x))).
- Not always direct solvers gives a good solution. Take N=2+5*k equidistant nodes on [0,1] and repeat computing
Lagrange interpolator p for any function e.g. f(x)=sin(3x) for k=0,1,2,3,...; check if f=p at interpolation nodes i.e compute max_k|f(x(k)-p(x(k))| where (x(k))_k interpolation nodes.
- Take a symmetric matrix 2x2 and compute its eigenvalues and eigenvectors.
Check if AX=XD X- a matrix having the eigenvectors as columns - D a diagonal matrix with with respective eigenvalues on its diagonal.
Test for A=[2,1;1,2], then D=diag([3;1]) and X=[1,1;1,-1]. Compare with the results of eig().
Repeat tests for different random symmetric matrices.
- SVD: compute svd() for a random matrices Check if the obtained values are OK.
- Solve a LLSP problem by svd() for a random matrix 5x4 and 4x5. Compare with backslash results.
-
Compute using svd() condition of A for a random A 5x5; compute the second matrix norm of A for a random A 5x4 etc
Compute the orhonormal basis of ker(A) and R(A). Compare with the results obtained by null() and orth().
A few octave scripts, m-files, source C files, LAPACK functions
Link to Octave
Octave scripts, m-files,simple C files with e.g. examples of an use of BLAS/LAPACK
matbasic.m - a script with basic octave commands
we can edit it : gedit matbasic.m
Wyklad - srodowko programisty gdzie mozna znalezc materiaĹy
o jezyku C jak i Makefile'ach (in Polish)
Project
Later in April - May 2021
Return to my homepage
Last update : March 3, 2021