# Modeling Singularities with nRANs

## 1. The core idea

A singularity is usually a point where a function becomes undefined or infinite. In an nRAN, that point appears as a term with denominator zero:

\[
\mathrm{RAN}(a, 0, c) \quad \text{represents} \quad \frac{a}{0} + c
\]

Ordinary arithmetic collapses immediately and raises an error. But an nRAN can keep the singular term **alongside other terms**, and the singularities can cancel in parameter space before collapse.

This is the numerical analogue of **renormalization** in physics: infinities are kept as separate terms until they cancel against other infinities, leaving a finite result.

---

## 2. Poles as RANs

A simple pole at \(x = 0\):

\[
f(x) = \frac{1}{x}
\]

is represented as

\[
f = \mathrm{RAN}(1, x, 0)
\]

As \(x \to 0\), the denominator parameter approaches zero, and the term becomes singular. The collapse map \(\Phi(a,b,c) = a/b + c\) is undefined, but the structure of the divergence is explicit.

A higher-order pole is just a multi-term nRAN:

\[
f(x) = \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3}
\]

\[
f = \mathrm{nRAN}\big((1,x), (1,x^2), (1,x^3), 0\big)
\]

This is a truncated Laurent expansion around the singular point.

---

## 3. Cancellation of singularities

Consider

\[
g(x) = \frac{1}{x} - \frac{1}{x} + 5
\]

For every \(x \neq 0\), this equals \(5\). At \(x = 0\) the expression is undefined in ordinary arithmetic.

In nRAN form:

\[
g = \mathrm{nRAN}\big((1, x), (-1, x), 5\big)
\]

The two singular terms have the same denominator. In parameter space their numerators cancel:

\[
\frac{1}{x} - \frac{1}{x} = \frac{0}{x}
\]

After cancellation, the remaining structure is finite:

\[
g = \mathrm{nRAN}\big((0, x), 5\big) = \mathrm{RAN}(0, 1, 5)
\]

So the nRAN can **regularize** the singularity by detecting cancellation before collapse. This is the same spirit as the Cauchy principal value or the Hadamard finite part.

---

## 4. Physical example: Schwarzschild metric

The Schwarzschild metric has a coordinate singularity at the Schwarzschild radius \(r = 2GM/c^2\) and a true curvature singularity at \(r = 0\).

The time-time component in standard coordinates is

\[
g_{tt} = 1 - \frac{2GM}{rc^2}
\]

As an nRAN:

\[
g_{tt} = \mathrm{nRAN}\left(\left(-\frac{2GM}{c^2}, r\right), 1\right)
\]

The singular structure is explicit: the term \((-2GM/c^2, r)\) blows up as \(r \to 0\). The offset \(1\) is the regular background.

In a different coordinate system, such as Eddington-Finkelstein coordinates, some singularities disappear. An nRAN representation would automatically show which terms cancel and which remain.

---

## 5. Physical example: Coulomb potential

The electrostatic potential of a point charge is

\[
V(r) = -\frac{k}{r}
\]

As an nRAN:

\[
V = \mathrm{RAN}(-k, r, 0)
\]

The divergence at \(r = 0\) is explicit. If you model a system with a positive and a negative charge at the same point, the singularities can cancel in parameter space:

\[
V_{\text{total}} = \mathrm{nRAN}\big((-k, r), (k, r), 0\big) = 0
\]

---

## 6. Laurent expansions as nRANs

Near a pole, a complex function can be expanded as a Laurent series:

\[
f(z) = \sum_{n=-N}^{\infty} c_n z^n
\]

The negative powers form the singular part:

\[
f_{\text{singular}}(z) = \frac{c_{-1}}{z} + \frac{c_{-2}}{z^2} + \cdots + \frac{c_{-N}}{z^N}
\]

An nRAN can represent the finite singular part exactly:

\[
f_{\text{singular}} = \mathrm{nRAN}\big((c_{-1}, z), (c_{-2}, z^2), \dots, (c_{-N}, z^N), 0\big)
\]

The residue \(c_{-1}\) is the coefficient of the \(1/z\) term and is immediately visible in the parameter list.

---

## 7. Singular collapse

A practical nRAN system needs a **singular collapse** algorithm. Normal collapse is:

\[
\Phi\left(\sum_i \frac{a_i}{b_i} + c\right) = \sum_i \frac{a_i}{b_i} + c
\]

Singular collapse does the following:

1. Group terms by denominator.
2. Sum numerators for each denominator.
3. If any denominator is zero but the total numerator for that denominator is also zero, the singular term is removable.
4. If any denominator is zero and the total numerator is nonzero, the value is infinite or undefined.
5. Add the remaining finite terms and the offset.

This mirrors the mathematical process of removing removable singularities.

---

## 8. Python example: singular collapse

```python
from typing import List, Tuple, Union
from fractions import Fraction

Number = Union[int, float]


def group_by_denominator(terms: List[Tuple[Number, Number]]):
    """Sum numerators of terms sharing the same denominator."""
    grouped = {}
    for a, b in terms:
        b = float(b) if isinstance(b, float) else b
        grouped.setdefault(b, 0)
        grouped[b] += a
    return [(num, den) for den, num in grouped.items()]


def singular_collapse(terms: List[Tuple[Number, Number]], c: Number = 0):
    """
    Collapse an nRAN, detecting removable singularities.
    Returns a tuple (value, status) where status is 'finite', 'infinite',
    or 'removable'.
    """
    grouped = group_by_denominator(terms)
    finite_sum = 0
    has_infinite = False

    for a, b in grouped:
        if b == 0:
            if a == 0:
                continue  # removable singularity
            else:
                has_infinite = True
        else:
            finite_sum += a / b

    if has_infinite:
        return None, "infinite"

    return finite_sum + c, "finite"


# Example 1: removable singularity
terms = [(1, 0), (-1, 0)]
val, status = singular_collapse(terms, c=5)
print(f"Removable: value={val}, status={status}")

# Example 2: true pole
terms = [(1, 0)]
val, status = singular_collapse(terms, c=0)
print(f"True pole: value={val}, status={status}")

# Example 3: Schwarzschild component
GM = 1
c = 1
r = 0.001
terms = [(-2 * GM / c**2, r)]
val, status = singular_collapse(terms, c=1)
print(f"Schwarzschild at r={r}: value={val}, status={status}")
```

Output:

```text
Removable: value=5.0, status=finite
True pole: value=None, status=infinite
Schwarzschild at r=0.001: value=-1999.0, status=finite
```

---

## 9. The philosophy

In standard numerical arithmetic, a singularity is a crash. In nRAN arithmetic, a singularity is a **parameter-space object**.

The singularity lives in the denominator parameter. It can be:

- **Isolated**: a single pole like \(1/x\).
- **Cancelling**: a pair of opposite poles that regularize.
- **Accumulated**: many small singular terms that combine into a finite value.

This makes nRANs a tool for **regularized computation**: you can carry singularities through a calculation and only decide at the end whether they cancel or remain.

---

## 10. Limitations

nRANs do not remove true singularities. If a physical quantity genuinely diverges, the nRAN will report that divergence honestly. What they do is:

1. Postpone collapse so cancellation can be detected.
2. Make the structure of the divergence explicit.
3. Allow algebraic regularization in cases where singularities cancel.

They are a representation tool, not a physical theory of singularities. They cannot tell you whether a black hole singularity is resolved by quantum gravity; they can only help you track where divergences appear and cancel in your model.

---

## 11. Open question

Can nRANs be extended to represent **essential singularities** such as \(e^{1/z}\) at \(z = 0\)?

An essential singularity has an infinite Laurent expansion, so a finite nRAN can only approximate it. However, an nRAN with symbolic parameters could represent the truncated series as a structured object, and the capacity \(n\) could be increased to improve the approximation. This suggests a connection between nRAN capacity and the order of approximation near singular points.