Sie können dies mit dem Björck-Pereyra-Algorithmus zur Lösung von Vandermonde-Systemen bewerten, da Sie bewertenb⊤V−1b=(2,0,23,0,25,0,…)
0≤x1<x2<⋯<xnVb0≤x1O(n2)Lix↦12(x+1)
O(ϵmach)
module VandermondeInverse
using SpecialMatrices
function main(n=8)
X = Rational{BigInt}[k//(n-1) for k=0:n-1]
# X = convert(Vector{Rational{BigInt}}, linspace(-1, 1, n))
x = convert(Vector{Float64}, X)
A = convert(Matrix{Rational{BigInt}}, Vandermonde(X))
b = [i%2==0 ? 2//(i+1) : 0 for i=0:n-1]
println("Norm: ", norm(A, Inf))
println("Norm of inverse: ", norm(inv(A), Inf))
println("Condition number: ", cond(convert(Matrix{Float64}, A)))
ans = A'\b
println("True answer: ", ans)
B = convert(Matrix{Float64}, A)
c = convert(Vector{Float64}, b)
println("Linear solve: ", norm((B'\c - ans)./ans, Inf))
d = vec(c')
for k=1:n, l=n:-1:k+1
d[l] -= x[k]*d[l-1]
end
for k=n-1:-1:1, l=k:n
if l > k
d[l] /= x[l]-x[l-k]
end
if l < n
d[l] -= d[l+1]/(x[l+1] - x[l-k+1])
end
end
println("Neville elimination: ", norm((d-ans)./ans, Inf))
nothing
end
end
V = VandermondeInverse
Ausgabe:
julia> V.main(14)
Norm: 14.0
Norm of inverse: 1.4285962612120493e10
Condition number: 5.2214922998851654e10
True answer: Rational{Int64}[3202439130233//2916000,-688553801328731//52390800,19139253128382829//261954000,-196146528919726853//785862000,6800579086408939//11642400,-43149880138884259//43659000,32567483200938127//26195400,-7339312362348889//6237000,48767438804485271//58212000,-69618881108680969//157172400,44275410625421677//261954000,-2308743351566483//52390800,11057243346333379//1571724000,-209920276397//404250]
Linear solve: 1.5714609387747318e-8
Neville elimination: 1.3238218572356314e-15
Wenn dies X
nicht wie in diesem Test positiv ist, scheinen die relativen Fehler in der gleichen Größenordnung zu liegen wie bei einer regulären linearen Lösung.
b⊤V−1LiLi(xj)=δijαjkLk
Lk(x)=∑j,kαj,kxj=(1,x,x2,…,xn)⊤(α0k,…,αnk),
LL=⎛⎝⎜⎜α00⋮αn0⋯⋯α0n⋮αnn⎞⎠⎟⎟.
LkL(1,x,…,xn)(1,x,x2,…,xn)L=(L0(x),L1(x),…,Ln(x)).
Lk(xj)=δjk⎛⎝⎜⎜1⋮1x0xnx20x2n⋯⋯xn0xnn⎞⎠⎟⎟L=I,
L=V−1Vxj
∫1−1xkdx=1+(−1)kk+1
∫1−1Lk(x)dx=∑jαjk1+(−1)kk+1=(2,0,23,0,25,0,…)⊤(α0k,…,αnk).
n+1k=0…n(2,0,23,0,…)⊤LL=V−1