gdelaurentis / pyadic Goto Github PK
View Code? Open in Web Editor NEWp-Adic numbers and finite fields in Python
Home Page: https://gdelaurentis.github.io/pyadic/
License: GNU General Public License v3.0
p-Adic numbers and finite fields in Python
Home Page: https://gdelaurentis.github.io/pyadic/
License: GNU General Public License v3.0
Sorry, not sure if this related to the update just pushed, or some other issue, but now there seems to be some problem with the integers? Both with as_tuple and even with normal arithmetic... could be my misunderstanding of the correct behavior though. This is with the most recent version just pushed.
The powers of p have the same tuple representation
>>> PAdic(1,2,4)
1 + O(2^4)
>>> PAdic(2,2,4)
1*2 + O(2^5)
>>> PAdic(4,2,4)
1*2^2 + O(2^6)
>>> PAdic(1,2,4).as_tuple
(1, 0, 0, 0)
>>> PAdic(2,2,4).as_tuple
(1, 0, 0, 0)
>>> PAdic(4,2,4).as_tuple
(1, 0, 0, 0)
Normal arithmetic seems broken
>>> PAdic(2,2,4) + PAdic(2,2,4) == PAdic(4,2,4)
False
>>> PAdic(2,2,4) + PAdic(2,2,4)
1*2^2 + O(2^5)
>>> PAdic(4,2,4)
1*2^2 + O(2^6)
Thank you for this package, it has been really helpful trying to build an intuition for p-adic numbers. In playing around I came across an odd behavior that think may be a bug. Specifically, when converting from a negative integer -x I seem to get a different PAdic than when I convert from the equivalent trivial fraction(-x,1).
PAdic(-2, 2, 4)
12 + 12^2 + 12^3 + O(2^4)
PAdic(Q(-2,1), 2, 4)
12 + 12^2 + 12^3 + O(2^5)
Q(-2,1) == -2
True
PAdic(Q(1/5), 5, 20)*5
should just produce 1, but instead gives 1*5^3 + 2*5^5 + 2*5^6 + 4*5^7 + 2*5^8 + 2*5^9 + 2*5^11 + 1*5^12 + 4*5^13 + 4*5^17 + 4*5^18 + 3*5^20 + 3*5^21 + 3*5^22 + O(5^23)
I believe this to be because a proper representation of 1/5 in 5-adic numbers is ...0000.1 . This would be 1*5^-1 in your representation, but that is not what is outputted. The issue also exists for other bases.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.