b⊤V- 1b = ( 2 , 0 , 23, 0 , 25, 0 , ... )
0 ≤ x1< x2< ⋯ < xnVb0 ≤ x1O ( n2)euEux ↦ 12( x + 1 )
O ( ϵm a c h)
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
Resultado:
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
Se X
não for positivo como neste teste, parece que os erros relativos são da mesma ordem que com uma resolução linear regular.
b⊤V- 1euEueuEu( xj) = δeu jαj keuk
euk( x ) = ∑j , kαj , kxj= ( 1 , x , x2, … , Xn)⊤( α0 k, … , Αn k) ,
euL = ⎛⎝⎜⎜α00⋮αn 0⋯⋯α0 n⋮αn n⎞⎠⎟⎟.
eukeu( 1 , x , … , xn)( 1 , x , x2, … , Xn) L = ( L0 0( x ) , L1( x ) , … , Ln( X ) ) .
euk( xj) = δj k⎛⎝⎜⎜1⋮1x0 0xnx20 0x2n⋯⋯xn0 0xnn⎞⎠⎟⎟L = I,
L = V- 1Vxj
∫1- 1xkd x= 1 + ( - 1 )kk + 1
∫1- 1euk( X )d x= ∑jαj k1 + ( - 1 )kk + 1= ( 2 , 0 , 23, 0 , 25, 0 , ... )⊤( α0 k, … , Αn k) .
n + 1k = 0 ... n( 2 , 0 , 23, 0 , ... )⊤euL = V- 1