Find such that:
A = [
3 2 -1
-2 -2 4
-2 1 -2
]
A * b
b = [1, -2, 0]
using RowEchelon
rref([A b])
Symbolic as amenable to exact arithmetic:
rref(Rational{Int}.([A b]))
Ab = Float64[A b]
Ab[1, :] /= Ab[1, 1]
Ab
Ab[2, :] -= Ab[2, 1] * Ab[1, :]
Ab[3, :] -= Ab[3, 1] * Ab[1, :]
Ab
Ab[2, :] /= Ab[2, 2]
Ab
Ab[3, :] -= Ab[3, 2] * Ab[2, :]
Ab[1, :] -= Ab[1, 2] * Ab[2, :]
Ab
Ab[3, :] /= Ab[3, 3]
Ab
Ab[1, :] -= Ab[1, 3] * Ab[3, :]
Ab[2, :] -= Ab[2, 3] * Ab[3, :]
Ab
function row_echelon!(A)
for col in axes(A, 1)
A[col, :] /= A[col, col]
for row in axes(A, 1)
if row != col
A[row, :] -= A[row, col] * A[col, :]
end
end
display(A)
end
end
Ab = Float64[A b]
row_echelon!(Ab)
row_echelon!(Ab + 0.1*rand(size(Ab)...))
https://en.wikipedia.org/wiki/Double-precisionfloating-pointformat
https://en.wikipedia.org/wiki/Zeno%27s_paradoxes
num = 1.0
while num > 0
@show num
num /= 2
end
Find such that:
ε = 2e-10
A = [
1 1 -1
1 1+ε 1
1 -1 1
]
b = [2, 0, 1]
Ab = [A b]
Ab[2, :] -= Ab[1, :]
Ab[3, :] -= Ab[1, :]
Ab
Ab[2, :] /= Ab[2, 2]
Ab
Ab[1, :] -= Ab[2, :]
Ab[3, :] += 2Ab[2, :]
Ab
Ab[3, :] /= Ab[3, 3]
Ab
Ab[1, :] -= Ab[1, 3] * Ab[3, :]
Ab[2, :] -= Ab[2, 3] * Ab[3, :]
Ab
distance = 16
while distance > 0
@show distance
distance /= 2
end
A \ b
ε = 0.0001
(A + ε * rand(size(A)...)) \ (b + ε * rand(size(b)...))
Find such that:
B = A[:, 1:2]
using RowEchelon
rref([B b])
This gives the system
The system has no solution.
x = B \ b
e = B * x - b
The system has no solution. We want to minimize the error : multi-objective optimization. Reduce to one objective with sum of squares.
In general, , :
where is the Euclidean norm.
Unconstrained mathematical optimization program:
Decision variables:
Objective function:
Optimal solution: solution of . If is invertible, .
B' * e
(B' * B) \ B' * b
Find such that:
C = A[1:2, :]
c = b[1:2]
using RowEchelon
rref([C c])
This gives the system
The system has infinitely solutions: It has a solution for any .
x = C \ c
C * x - c
Suppose we want to minimize :
Mathematical optimization program:
Decision variables:
Objective function:
Constraints:
Optimal solution: where is a solution of . If is invertible, .
C \ c
C' * ((C * C') \ c)
This page was generated using Literate.jl.