-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Labels
Description
Maybe the following example is not a bug ... but the solution computed is suboptimal
The following computations can be done modulo 29^2.
They should be possible with padics?
julia> k = PadicField(29,2)
Field of 29-adic numbers
julia> A = k[0 29 1; 29 1 0; 1 0 0]
[ O(29^2) 29^1 + O(29^3) 29^0 + O(29^2)]
[29^1 + O(29^3) 29^0 + O(29^2) O(29^2)]
[29^0 + O(29^2) O(29^2) O(29^2)]
julia> A = k[0 29 1; 29 1 0; 1 0 0];
julia> A
[ O(29^2) 29^1 + O(29^3) 29^0 + O(29^2)]
[29^1 + O(29^3) 29^0 + O(29^2) O(29^2)]
[29^0 + O(29^2) O(29^2) O(29^2)]
julia> det(A) # precision loss
28*29^0 + O(29^1)
julia> inv(A) # precision loss
[ O(29^0) O(29^0) O(29^0)]
[ O(29^2) 29^0 + O(29^2) 28*29^1 + O(29^2)]
[29^0 + O(29^1) O(29^1) O(29^1)]
julia> pseudo_inv(A)[1] # not as bad but still not good
[ O(29^2) O(29^2) O(29^2)]
[ O(29^2) 28*29^0 + O(29^1) 29^1 + O(29^2)]
[28*29^0 + O(29^1) O(29^2) O(29^2)]
julia> b = k[1; 1; 1;];
julia> x1 = solve(A,b;side=:right) #precision loss
[ O(29^0)]
[29^0 + 28*29^1 + O(29^2)]
[ 29^0 + O(29^1)]
julia> A*x1
[ O(29^0)]
[29^0 + O(29^1)]
[ O(29^0)]
julia> A*x1 == b
true
julia> b
[29^0 + O(29^2)]
[29^0 + O(29^2)]
[29^0 + O(29^2)]
julia> x2 = inv(A^2)*A * b # this is the best possible and desired solution
[ 29^0 + O(29^2)]
[29^0 + 28*29^1 + O(29^2)]
[29^0 + 28*29^1 + O(29^2)]
julia> A*x2
[29^0 + O(29^2)]
[29^0 + O(29^2)]
[29^0 + O(29^2)]
julia> A*x2 == b
true
Similar, but with wierd printing
julia> k = PadicField(29,2)
Field of 29-adic numbers
julia> K,toK = completion(F,prime_ideals_over(maximal_order(F),29)[1], 2)
(Eisenstein extension with defining polynomial x + 26*29^1 + O(29^2) over Unramified extension of 29-adic numbers of degree 1, Map: F -> eisenstein extension with defining polynomial x + 26*29^1 + O(29^2) over QQ_29^1)
julia> A = K[0 29 1; 29 1 0; 1 0 0];
julia> b = K[1; 1; 1;];
julia> A*solve(A,b;side=:right) # not really a solution
[1]
[1]
[0]
In some larger examples solve
complains that no solution exists, although it clearly does.