Sinusoidal Time Encoding
Fourier feature map · multi-scale · sin/cos encoding · positional encoding
The Temporal Spiral's encoding is a multi-scale Fourier feature map of time: each of the twelve scales contributes one frequency component encoded as a (sin θ_i, cos θ_i) pair. Together they form a 24-dimensional continuous vector that any neural network can consume directly — no date parsing, no calendar arithmetic, no discontinuities.
Fourier decomposition of time
A standard Fourier decomposition expresses a signal as a sum of sinusoids at different frequencies. The Temporal Spiral applies the same idea to time itself: rather than decomposing a measured signal, it decomposes the timestamp t into twelve independent frequency components, one per scale.
For scale i with cycle length T_i:
θ_i = 2π × (t mod T_i) / T_i ∈ [0, 2π) f_i = [ sin(θ_i), cos(θ_i) ] ∈ ℝ²
Concatenating the twelve f_i vectors gives the full encoding:
φ(t) = [ sin(θ_1), cos(θ_1),
sin(θ_2), cos(θ_2),
…
sin(θ_12), cos(θ_12) ] ∈ ℝ²⁴This 24-dimensional vector is the Fourier feature map of the timestamp. It is continuous, bounded, and directly differentiable — properties that make it well-suited as an input to attention layers, MLP time encoders, and recurrent controllers.
How this compares to transformer positional encoding
Vaswani et al. (2017) introduced sinusoidal positional encoding for transformers. The Temporal Spiral uses the same mathematical skeleton — but targets calendar time rather than token position.
| Property | Transformer PE (Vaswani 2017) | Temporal Spiral |
|---|---|---|
| Domain | Token position (integer index) | Wall-clock timestamp (milliseconds) |
| Encoding form | sin/cos of position × geometric frequencies | sin/cos of fractional phase per scale |
| Frequencies chosen by | Geometric series (10 000^(2i/d_model)) | Human-relevant cycle lengths (µs → millennium) |
| Learned parameters | None | None |
| Continuity | Continuous over position | Continuous over time (no midnight discontinuity) |
| Geometry | d_model/2 frequencies in ℝ^d_model | 12-torus T¹² = (S¹)¹² in ℝ²⁴ |
| Wrapping | No wrap (monotone in position) | Cyclic per scale (captures recurrence) |
| Delivery | Computed inside the model | REST API — NTP/NTS-anchored, certified |
The key conceptual difference: transformer positional encoding is monotone — it distinguishes token 1 from token 1000 but has no notion of "same time of day". The Temporal Spiral is cyclic per scale, which means two timestamps that share the same hour of day produce the same θ_hr value — a property directly useful for learning daily, weekly, and seasonal patterns.
Why twelve rungs?
Twelve is a deliberate, well-tested general-application anchor — not a mathematical ceiling.
The twelve cycle lengths span twelve orders of magnitude, from one millisecond to one millennium, in approximately one-order-of-magnitude steps:
| Scale | Cycle length | Order of magnitude |
|---|---|---|
| θ_us | 1 ms | 10⁻³ s |
| θ_ms | 1 s | 10⁰ s |
| θ_s | 1 min | 10¹ s |
| θ_min | 1 hr | 10³ s |
| θ_hr | 1 day | 10⁴·⁹ s |
| θ_day | 1 week | 10⁵·⁸ s |
| θ_wk | 1 year | 10⁷·⁵ s |
| θ_mo | 1 year | 10⁷·⁵ s |
| θ_yr | 1 year | 10⁷·⁵ s |
| θ_dec | 1 decade | 10⁸·⁵ s |
| θ_cen | 1 century | 10⁹·⁵ s |
| θ_mil | 1 millennium | 10¹⁰·⁵ s |
This coverage gives balanced Fourier bandwidth across every human-relevant time rhythm: sub-second inference cadence, minute/hour scheduling, daily and weekly patterns, seasonal cycles, annual recurrences, and decade-scale trends.
Fewer than 12: coverage gaps
Dropping rungs removes frequency bands. A 6-rung encoding that skips weekly and monthly scales loses the ability to distinguish "same time last Tuesday" from "same time last month" — both produce nearly identical low-rung values.
More than 12: diminishing returns
Adding rungs beyond a millennium introduces frequencies that recur on geological or cosmological timescales. For general applications, those bands carry no human-readable signal and add redundancy without information gain.
Custom deployments requiring ultra-high precision (sub-microsecond cadence) or deep-time domains (paleoclimatology, orbital mechanics on million-year scales) can request an adjusted rung count. Twelve is the well-tested default that covers the overwhelming majority of AI, robotics, and scheduling applications.
For mathematical background on Fourier feature maps, see Wikipedia: Fourier transform. For the original sinusoidal positional encoding paper, see Vaswani et al. 2017, "Attention Is All You Need".
Ready-to-use feature vector from the API
Every GET /v1/spiral response includes the full 24-dimensional Fourier feature vector in the compact field — ready to concatenate into a model input with no further processing:
curl 'https://api.temporalblock.com/api/v1/spiral' \
-H 'X-API-Key: tblk_live_…'
// Response (compact field):
{
"compact": {
"scales": [
"us", "ms", "s", "min", "hr",
"day", "wk", "mo", "yr", "dec", "cen", "mil"
],
"sin": [
0.000, -0.999, 0.951, -0.309, 0.588,
0.454, -0.208, 0.866, 0.743, -0.978, 0.991, 0.171
],
"cos": [
-1.000, 0.009, 0.309, 0.951, 0.809,
0.891, -0.978, 0.500, 0.669, 0.206, 0.134, 0.985
]
}
}To build a 24-dimensional input vector in Python:
import numpy as np, requests
r = requests.get(
"https://api.temporalblock.com/api/v1/spiral",
headers={"X-API-Key": "tblk_live_…"},
).json()
compact = r["compact"]
# interleave sin/cos: [sin_us, cos_us, sin_ms, cos_ms, …]
fourier_vec = np.array(
[v for pair in zip(compact["sin"], compact["cos"]) for v in pair]
) # shape: (24,)The vector is NTP/NTS-anchored and certified — the timestamp used to compute each θ_i came from an authenticated time source, not the server's unsynchronized system clock.
Related
- Theta (θ) — Angular Time CoordinateThe phase angle driving each sin/cos pair in the encoding
- Temporal Spiral — full coordinate referenceComplete API reference, confidence envelopes, and rung detail
The Temporal Spiral encoding is patent pending — U.S. Provisional Application No. 64/065,213 (filed 2026-05-14).