TorchLean API

NN.Floats.NeuralFloat.Format.Magnitude

Radix Magnitude #

The magnitude of a nonzero real $x$ is the unique integer $e$ for which $\beta^{e-1}\le|x|<\beta^e$. These bounds are the basic bridge between logarithmic magnitude, canonical exponents, and generic-format rounding.

The logarithmic definition of neuralMagnitude satisfies the standard Flocq magnitude bounds.

Lower magnitude bound for a nonzero real.

Strict upper magnitude bound for a nonzero real.

@[simp]

The magnitude of $\beta^e$ is $e+1$.

@[simp]
theorem TorchLean.Floats.neuralBpow_le_neuralBpow_iff (β : NeuralRadix) (e₁ e₂ : ) :
neuralBpow β e₁ neuralBpow β e₂ e₁ e₂

Radix powers preserve and reflect exponent order.

@[simp]
theorem TorchLean.Floats.neuralBpow_lt_neuralBpow_iff (β : NeuralRadix) (e₁ e₂ : ) :
neuralBpow β e₁ < neuralBpow β e₂ e₁ < e₂

Radix powers preserve and reflect strict exponent order.

theorem TorchLean.Floats.neuralMagnitude_eq_of_bpow_bounds (β : NeuralRadix) (x : ) (e : ) (hx : x 0) (hlower : neuralBpow β (e - 1) |x|) (hupper : |x| < neuralBpow β e) :

Radix-power bounds uniquely determine magnitude.

theorem TorchLean.Floats.neuralMagnitude_le_of_abs_lt_bpow (β : NeuralRadix) (x : ) (e : ) (hx : x 0) (hupper : |x| < neuralBpow β e) :

Any strict radix-power upper bound is also an upper bound on magnitude.

theorem TorchLean.Floats.neuralMagnitude_mono_pos (β : NeuralRadix) {x y : } (hx : 0 < x) (hxy : x y) :

Magnitude is monotone on positive real inputs.

Magnitude is monotone with respect to absolute value.

theorem TorchLean.Floats.neuralCexp_mono_abs (β : NeuralRadix) {fexp : } [NeuralValidExp fexp] [NeuralMonotoneExp fexp] {x y : } (hx : x 0) (hxy : |x| |y|) :
neuralCexp β fexp x neuralCexp β fexp y

A monotone exponent format preserves absolute-value order at canonical exponents.

The magnitude of a nonzero product is at most the sum of operand magnitudes.

Multiplication by a radix power shifts magnitude by its exponent.

theorem TorchLean.Floats.neuralBpow_eq_natCast_of_nonneg (β : NeuralRadix) (e : ) (he : 0 e) :
∃ (n : ), neuralBpow β e = n

A radix power with nonnegative exponent is the cast of a natural number.