%% SL6:
A = [-1 1; 1 -2]
B = [1 2 3; 4 5 6; 7 8 9]

%% SL7:
a = 1
b = 5;

a = 1, b = 5
a = 1; b = 5;

c = [1 0 0]
d = [0; 0; 1]

%% SL12:
a3 = -2/4
a4 = -0.5
a5 = -.5

3*5*6
a1 = 15
a2 = 10;
a2/a3
a2/a3*a4
a2/(a3*a4)

%% SL15:
a = 3.24;
alpha = pi/7;
a*(sin(alpha)^2 + cos(alpha)^2 - 1)

a = 14; b = 28;
(log10(a) + log10(b)) - log10(a*b)

T = [1/2 1/3 1/4 1/5; 6 7 8 9; 0.2 0.3 0.4 0.5];
sum(T,2)

%% SL16:
u = [1 2 3]; v = [3 2 1];
u*transpose(v), transpose(v)*u
v'*u, u'*v
dot(u,v), cross(u,v)

%% SL17:
r = 1 + 10*rand(1)
round(r)
ceil(r)
floor(r)
fix(r)
fix(1e2*r)/1e2
rem(r,0.1)

%% SL19:
T = 10 + 4*randn(7,7);
trace(T)

U = [1 2 17/81; 0 2 0; 0 -2 -1];
det(U)

A = [1 2 3; 4 5 6;7 8 1]; 
b = [6 15 16]';
x = inv(A)*b;

% or
x = A \ b;

% SL27:
save Data
save('Data')

save Data_selected A T
save('Data_selected', 'A', 'T')

load Data_selected
load('Data_selected')

%% SL33:
F = [2 2] + [1 -3] + [2 0] + [0 -1.5]
Fn = F/norm(F)

% SL34:
clear, clc;
w1 = [1 2 3], w2 = [-2 -3 -4]',
w3 = [-2; -3; -4],
% w4 = w2 - w3, w5 = w2 - w1 % syntax error here - try to find out what is wrong

w1*3, w1 - 3,
w1 + [5 5 5],
% w6 = 5*w1 - [3 5 6] - w2, % syntax error here - try to find out what is wrong

norm(w1)
sqrt(sum(w1.^2))

norm(w1)
sqrt(sum(abs(w1).^2))

%% SL35:
a = 2; b = 5; c = 3; 
D = b^2 - 4*a*c; 
x1 = (-b + sqrt(D))/(2*a), 
x2 = (-b - sqrt(D))/(2*a),

% or
roots([-2 -5 -3]),
roots([2 5 3]),

%% SL36:
al = pi/3 % (eg. ...)
R = [cos(al) 0 -sin(al); 0 1 0; sin(al) 0 cos(al)]

v1 = [-2; 1; 0];
v2 = [0; 0; 1];
n = cross(v1,v2);
n0 = n/norm(n);
P = eye(3) - 2*n0*n0'

%% SL37:
al = pi/2; 
R = [cos(al) 0 -sin(al); 0 1 0; sin(al) 0 cos(al)];
m = R*[1 0 0]'

u1 = n0; 
u2 = [5/2; 0; 3];
m1 = P*u1,
m2 = P*u2,

det(R), det(P),



