Skip to main content

Hyperreal

Struct Hyperreal 

Source
pub struct Hyperreal { /* private fields */ }
Expand description

A hyperreal number generated by the infinitesimal. See the module documentation.

Implementations§

Source§

impl Hyperreal

Source

pub fn dt() -> Hyperreal

The infinitesimal itself.

Source

pub fn from_algebraic(a: Algebraic) -> Hyperreal

Source

pub fn from_rational(r: Rational) -> Hyperreal

Source

pub fn from_i64(n: i64) -> Hyperreal

Source

pub fn from_reciprocal_powers(c: &[Rational]) -> Hyperreal

Σ cᵢ·(1/dt)^i for rational c (little-endian), written directly as (Σ cᵢ·dt^(d−i)) / dt^d: with the top coefficient nonzero the numerator has a nonzero constant term, so the fraction is already in lowest terms and dt^d is comonic — no polynomial gcd at any degree.

Source

pub fn is_zero(&self) -> bool

Source

pub fn add(&self, o: &Hyperreal) -> Hyperreal

Source

pub fn neg(&self) -> Hyperreal

Source

pub fn sub(&self, o: &Hyperreal) -> Hyperreal

Source

pub fn mul(&self, o: &Hyperreal) -> Hyperreal

Source

pub fn recip(&self) -> Option<Hyperreal>

Source

pub fn div(&self, o: &Hyperreal) -> Option<Hyperreal>

Source

pub fn as_reciprocal_powers(&self) -> Option<Vec<Rational>>

The rational c with self = Σ cᵢ·(1/dt)^i, when the value is a polynomial in 1/dt over the rationals; None for a positive power of dt, an irrational coefficient, or a denominator that is not a power of dt. The inverse of Hyperreal::from_reciprocal_powers.

Source

pub fn principal_part(&self) -> (Vec<Algebraic>, Hyperreal)

The principal part of the Laurent expansion at dt = 0 and the limited rest: the coefficient of (1/dt)^j at index j − 1 for each j up to the pole’s order, and self − Σ c_j·(1/dt)^j exactly. Writing self = dt^(−k)·N/U with U(0) ≠ 0, the coefficients are the first k terms of the power series N/U.

Source

pub fn as_dt_polynomial(&self) -> Option<Vec<Algebraic>>

The coefficients of a polynomial in dt, lowest power first, when the value is one.

Source

pub fn taylor_coefficient(&self, k: usize) -> Algebraic

The coefficient of dt^k in the Taylor series of a limited value at dt = 0. A limited value in lowest terms has den(0) = 1, so s_k = num_k − Σ_{j=1}^{k} den_j·s_{k−j}.

Source

pub fn root_split(&self, n: u32) -> Option<(Hyperreal, Hyperreal)>

self = outside^n · inside, where every polynomial factor of inside’s numerator and denominator appears fewer than n times (Yun’s squarefree decomposition takes the n-th powers out) and inside’s constant is taken out only when it is an n-th power: with rational coefficients the factors left inside are primitive integer polynomials with a positive lowest-order coefficient and the constant is the rest, otherwise they are monic and the constant’s n-th root — real, the positive one for even n — goes outside. None for zero, and for an even n of a negative value.

Source

pub fn numerator_is_constant(&self) -> bool

Whether the numerator is a constant: the value is a constant over a polynomial.

Source

pub fn degrees(&self) -> (usize, usize)

The degrees of the reduced numerator and denominator; (0, 0) for zero.

Source

pub fn degree(&self) -> usize

max(deg num, deg den): how far the value reaches in dt.

Source

pub fn pow(&self, k: i32) -> Result<Hyperreal, PowerError>

self^k, refused for zero to a negative power or a degree past MAX_POWER_DEGREE.

Source

pub fn signum(&self) -> i32

−1, 0 or 1: the sign of the lowest-order coefficient of the numerator.

Source

pub fn as_standard(&self) -> Option<Algebraic>

The standard value, when the value has no infinitesimal part at all.

Source

pub fn valuation(&self) -> Option<i64>

ord N − ord D; None for zero.

Source

pub fn leading_coefficient(&self) -> Option<Algebraic>

The coefficient of the leading power of dt.

Source

pub fn is_infinitesimal(&self) -> bool

Source

pub fn is_limited(&self) -> bool

Source

pub fn standard_part(&self) -> Option<Algebraic>

The standard real infinitely close to a limited value; None for an infinite one.

Source

pub fn infinitely_close(&self, o: &Hyperreal) -> bool

Source

pub fn eval_at(&self, t: &Rational) -> Option<Algebraic>

The value at the standard point dt = t; None at a pole.

Source

pub fn monomial(c: Algebraic, k: i64) -> Hyperreal

c·dt^k, for any integer k.

Source

pub fn ramify(&self, m: u32) -> Hyperreal

The same function of dt^m: dt replaced by dt^m, which keeps a reduced fraction reduced and a comonic denominator comonic.

Source

pub fn unramify(&self, m: u32) -> Option<Hyperreal>

The function r with self = r(dt^m), when every power of dt the value holds is a multiple of m; None otherwise.

Source

pub fn laurent_coefficient(&self, k: i64) -> Algebraic

The coefficient of dt^k in the Laurent expansion at dt = 0.

Source

pub fn pade(series: &[Algebraic], l: usize, m: usize) -> Option<Hyperreal>

The rational function of numerator degree at most l and denominator degree at most m, denominator nonzero at 0, whose expansion at 0 begins with series (its first l + m + 1 coefficients), by the extended Euclidean algorithm on dt^(l+m+1) and the truncated series; None when no such function exists.

Source

pub fn render(&self, name: &str) -> String

The exact rational function with the infinitesimal written as name.

Source

pub fn render_powers(&self, power: &dyn Fn(usize) -> String) -> String

The exact rational function with the infinitesimal’s k-th power written power(k), for k ≥ 1.

Trait Implementations§

Source§

impl Clone for Hyperreal

Source§

fn clone(&self) -> Hyperreal

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hyperreal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Hyperreal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ExactCodec for Hyperreal

Source§

fn write(&self, out: &mut Vec<u8>)

The reduced numerator’s coefficients, then the comonic denominator’s, lowest power first.

Source§

fn read(buf: &[u8], pos: &mut usize) -> Option<Self>

Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Source§

fn from_bytes(buf: &[u8]) -> Option<Self>

The value buf canonically encodes, with nothing left over.
Source§

impl Hash for Hyperreal

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Hyperreal

Source§

fn cmp(&self, o: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Hyperreal

Source§

fn eq(&self, o: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Hyperreal

Source§

fn partial_cmp(&self, o: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Hyperreal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.