Advanced maths

P adic expansion calculator for a rational number

Expand a rational number into finitely many p-adic unit digits, retaining its valuation separately.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Expand a rational number into finitely many p-adic unit digits, retaining its valuation separately. Exact modular inversion verifies the truncated unit residue. The page states how negative valuations shift the displayed exponents and why a p-adic truncation has a different meaning from an ordinary real decimal approximation.

THE FORMULAx=p^v u; u≡Σ_(j=0..N−1) a_j p^j modulo p^N.

A worked example

For 1/3 in the 5-adics, the unit digits begin 2,3,1,3,1,3, listed from least significant to most significant. They reconstruct residue 10417 modulo 15625. Multiplication gives 3 × 10417 = 31251, which is congruent to 1 modulo 15625.

Good to know

Prime2–97,1–50 unit digits, exact rational input. Negative valuations shift exponents below zero. Zero labeled separately; p-adic truncation is not real approximation.

Choose a prime and a different notion of closeness

The p-adic valuation measures how many factors of prime p occur in a rational number, subtracting those in its denominator. A number divisible by a high power of p is p-adically small, even if its ordinary real magnitude is large. The prime selector therefore changes the arithmetic viewpoint rather than just the notation base.

A composite base does not define the same p-adic field construction and is rejected. The interface supports primes up to ninety-seven. Integer-base conversion elsewhere in the catalogue writes an ordinary real value using place weights; this page instead calculates a residue-compatible p-adic expansion with an infinite tail in increasing powers.

Five-adic digits reconstruct a modular rational residueDigits (least significant first): 2,3,1,3,1,32 + 3×5 + 1×25 + … + 3×3125 = 104173×10417 = 31251 ≡ 1 modulo 15625
For 1/3 in the 5-adics, the unit digits begin 2,3,1,3,1,3, listed from least significant to most significant. They reconstruct residue 10417 modulo 15625. Multiplication gives 3 × 10417 = 31251, which is congruent to 1 modulo 15625. Diagram is schematic; labels specify the numerical values.

The Gaussian integer prime factorization calculator factors elements of the Gaussian integer ring. A p-adic expansion instead fixes one rational prime and separates its valuation from the unit residue modulo a prime power.

Split the valuation from the unit

Write a nonzero rational as p to the valuation times a unit u whose numerator and denominator are not divisible by p. The unit has a digit expansion a0+a1 p+a2 p squared and so on, with digits from zero through p minus one. Its first digit is nonzero for a nonzero unit.

The table indexes unit digits starting at zero. To find each actual exponent in the original rational, add the valuation. A negative valuation therefore places some digits at negative powers without changing how the unit residue is computed. Reading table index zero as original exponent zero in every case would lose this shift.

Compute a finite unit residue

For N requested digits, invert the unit denominator modulo p to the N. Multiplying that inverse by the unit numerator gives a unique residue from zero through p to the N minus one. Repeated division by p extracts its N digits exactly.

This construction works because the unit denominator is coprime to p after valuation factors are removed. A denominator originally divisible by p is not automatically invalid; it contributes a negative valuation first. The remaining denominator then becomes invertible for the unit calculation.

Verify one third in the 5-adics

The rational one third has valuation zero at p=5. Its first six unit digits are two,three,one,three,one,three. These digits encode the residue 10417 modulo 15625. Multiplying by three gives 31251, which is congruent to one modulo 15625.

That congruence checks the truncated inverse exactly. As an ordinary real number, 10417 is not close to one third. Their difference is divisible by a high power of five after accounting for the denominator, which is the p-adic sense of the approximation. The two notions of closeness should not be mixed.

Handle negative valuation and zero separately

For one fifth at p=5, valuation is minus one and the unit is one. The first unit digit one therefore belongs to original exponent minus one. The algorithm does not try to invert five modulo a power of five before removing that valuation factor.

Zero has no finite integer valuation: it is conventionally assigned infinite valuation. The page labels that special case and returns zero digits. It is not confused with a nonzero rational whose first several original nonnegative-power digits happen to vanish because of a positive valuation.

Interpret the omitted tail correctly

N digits specify the unit modulo p to the N. Additional digits refine that congruence and leave all earlier digits unchanged. They do not bound an ordinary real rounding error by p to the minus N in the usual absolute value.

The displayed residue is not a claim that the rational equals that finite integer exactly. The omitted tail represents higher p-adic powers. If the valuation is v, the truncation agreement for the original number is shifted accordingly. Preserve both v and N when comparing expansions from another package.

Keep the supported rational-input scope

The page accepts the site’s bounded exact rational syntax, including fractions and supported decimal strings, and returns at most fifty unit digits. It does not construct arbitrary p-adic algebraic extensions, solve p-adic polynomial equations or compute an infinite symbolic periodic expansion.

Use the exact modular reconstruction as the certificate for the requested finite prefix. Hensel root lifting is a related but distinct task and is not performed automatically by this digit interface. A correctly reconstructed rational expansion illustrates the p-adic model; it does not establish broader analytic or number-theoretic claims about another input family.

A few questions, answered

Can the denominator contain p?

Yes. Its p factors first contribute to a negative valuation; the remaining unit denominator is then inverted.

Is the unit-digit index the original power of p?

Add the displayed valuation to the unit index to obtain the original exponent.

Why is the large residue a good approximation?

It agrees modulo a high power of p. That is p-adic closeness, not ordinary real closeness.

How is zero handled?

It has a separate infinite-valuation label and zero digits rather than an invented finite valuation.

Find your calculator

Start typing to explore the library.