#[repr(u8)]pub enum Symbol {
Show 67 variants
One = 49,
Two = 50,
Three = 51,
Four = 52,
Five = 53,
Six = 54,
Seven = 55,
Eight = 56,
Nine = 57,
Pi = 112,
E = 101,
Phi = 102,
Gamma = 103,
Plastic = 80,
Apery = 122,
Catalan = 71,
X = 120,
UserConstant0 = 128,
UserConstant1 = 129,
UserConstant2 = 130,
UserConstant3 = 131,
UserConstant4 = 132,
UserConstant5 = 133,
UserConstant6 = 134,
UserConstant7 = 135,
UserConstant8 = 136,
UserConstant9 = 137,
UserConstant10 = 138,
UserConstant11 = 139,
UserConstant12 = 140,
UserConstant13 = 141,
UserConstant14 = 142,
UserConstant15 = 143,
UserFunction0 = 144,
UserFunction1 = 145,
UserFunction2 = 146,
UserFunction3 = 147,
UserFunction4 = 148,
UserFunction5 = 149,
UserFunction6 = 150,
UserFunction7 = 151,
UserFunction8 = 152,
UserFunction9 = 153,
UserFunction10 = 154,
UserFunction11 = 155,
UserFunction12 = 156,
UserFunction13 = 157,
UserFunction14 = 158,
UserFunction15 = 159,
Neg = 110,
Recip = 114,
Sqrt = 113,
Square = 115,
Ln = 108,
Exp = 69,
SinPi = 83,
CosPi = 67,
TanPi = 84,
LambertW = 87,
Add = 43,
Sub = 45,
Mul = 42,
Div = 47,
Pow = 94,
Root = 118,
Log = 76,
Atan2 = 65,
}Expand description
A symbol in a RIES expression
Variants§
One = 49
Two = 50
Three = 51
Four = 52
Five = 53
Six = 54
Seven = 55
Eight = 56
Nine = 57
Pi = 112
E = 101
Phi = 102
Gamma = 103
Euler-Mascheroni constant γ ≈ 0.5772156649
Plastic = 80
Plastic constant ρ ≈ 1.3247179572
Apery = 122
Apéry’s constant ζ(3) ≈ 1.2020569032
Catalan = 71
Catalan’s constant G ≈ 0.9159655942
X = 120
UserConstant0 = 128
UserConstant1 = 129
UserConstant2 = 130
UserConstant3 = 131
UserConstant4 = 132
UserConstant5 = 133
UserConstant6 = 134
UserConstant7 = 135
UserConstant8 = 136
UserConstant9 = 137
UserConstant10 = 138
UserConstant11 = 139
UserConstant12 = 140
UserConstant13 = 141
UserConstant14 = 142
UserConstant15 = 143
UserFunction0 = 144
UserFunction1 = 145
UserFunction2 = 146
UserFunction3 = 147
UserFunction4 = 148
UserFunction5 = 149
UserFunction6 = 150
UserFunction7 = 151
UserFunction8 = 152
UserFunction9 = 153
UserFunction10 = 154
UserFunction11 = 155
UserFunction12 = 156
UserFunction13 = 157
UserFunction14 = 158
UserFunction15 = 159
Neg = 110
Recip = 114
Sqrt = 113
Square = 115
Ln = 108
Exp = 69
SinPi = 83
CosPi = 67
TanPi = 84
LambertW = 87
Add = 43
Sub = 45
Mul = 42
Div = 47
Pow = 94
Root = 118
Log = 76
Atan2 = 65
Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn weight(self) -> u32
pub fn weight(self) -> u32
Get the default complexity weight of this symbol
Complexity weights determine how “simple” an expression is, affecting which equations RIES presents first. Lower complexity = simpler expression.
§Calibration Methodology
Weights are calibrated to match original RIES behavior while ensuring intuitive simplicity ordering:
§Constants
-
Small integers (1-9): Range from 3-6, with smaller digits cheaper
- Rationale: Single digits are fundamental building blocks
1and2are cheapest (3) as they appear in most simple equations- Larger digits cost more as they’re less “fundamental”
-
Transcendental constants (π, e): Weight 8
- Higher than integers as they require special notation
- Same weight as they’re equally “fundamental” in mathematics
-
Algebraic constants (φ, ρ): Weight 10
- Higher than π/e as they’re less commonly used
- Plastic constant (ρ) is algebraic (root of x³ = x + 1)
-
Special constants (γ, ζ(3), G): Weight 10-12
- Euler-Mascheroni γ and Catalan’s G: 10
- Apéry’s constant ζ(3): 12 (higher due to obscurity)
§Unary Operators
- Negation (-): Weight 4 - simplest unary operation
- Reciprocal (1/x): Weight 5 - slightly more complex
- Square (x²): Weight 5 - very common, moderate cost
- Square root (√): Weight 6 - inverse of square
- Logarithm (ln): Weight 8 - transcendental operation
- Exponential (e^x): Weight 8 - inverse of ln, transcendental
- Trigonometric (sin(πx), cos(πx)): Weight 9-10 - periodic complexity
- Lambert W: Weight 12 - most complex, rarely used
§Binary Operators
- Addition/Subtraction (+, -): Weight 3 - simplest operations
- Multiplication (*): Weight 3 - fundamental arithmetic
- Division (/): Weight 4 - slightly more complex than multiply
- Power (^): Weight 5 - exponentiation
- Root (ᵃ√b): Weight 6 - inverse of power, more notation
- Logarithm base (log_a b): Weight 7 - two transcendental ops
- Atan2: Weight 7 - two-argument inverse trig
§Example Weight Calculations
Expression Postfix Weight Calculation Total
x = 2 x2= 6(x) + 3(2) 9
x² = 4 xs4= 6(x) + 5(s) + 4(4) 15
2x = 5 2x*5= 3(2) + 6(x) + 3(*) + 5(5) 17
e^x = π xEep 6(x) + 8(E) + 8(p) 22
x^x = π² xx^ps 6+6+5+8+5 30§Design Philosophy
The weight system follows these principles:
- Pedagogical value: Simpler concepts have lower weights
- Historical consistency: Weights approximate original RIES behavior
- Practical usage: Commonly-used operations are cheaper
- Composability: Complex expressions = sum of symbol weights
§See Also
For a detailed explanation of the calibration process and rationale,
see docs/COMPLEXITY.md in the source repository.
Sourcepub const fn default_weight(self) -> u32
pub const fn default_weight(self) -> u32
Get the default complexity weight (without overrides)
This is used by SymbolTable to build per-run weight configurations.
Sourcepub fn legacy_parity_weight(self) -> i32
pub fn legacy_parity_weight(self) -> i32
Legacy (original RIES) per-symbol weight delta used for parity ranking.
Original RIES uses a base symbol cost plus a signed per-symbol delta where many binary operators have negative deltas. This function exposes the signed delta component for output-ranking parity mode.
Sourcepub fn result_type(self, arg_types: &[NumType]) -> NumType
pub fn result_type(self, arg_types: &[NumType]) -> NumType
Get the result type when this operation is applied
Sourcepub const fn inherent_type(self) -> NumType
pub const fn inherent_type(self) -> NumType
Get the inherent numeric type of this symbol (for constants) Returns Transcendental for operators (since they can produce any type)
Sourcepub fn display_name(self) -> String
pub fn display_name(self) -> String
Get the display name for this symbol.
Note: For per-run name overrides, use SymbolTable::name() instead.
Sourcepub fn user_constant_index(self) -> Option<u8>
pub fn user_constant_index(self) -> Option<u8>
Get user constant index (0-15) if this is a user constant symbol
Sourcepub fn user_function_index(self) -> Option<u8>
pub fn user_function_index(self) -> Option<u8>
Get user function index (0-15) if this is a user function symbol
Sourcepub fn binary_ops() -> &'static [Symbol]
pub fn binary_ops() -> &'static [Symbol]
Get all binary operators (Seft::C)
Trait Implementations§
Source§impl Ord for Symbol
impl Ord for Symbol
Source§impl PartialOrd for Symbol
impl PartialOrd for Symbol
impl Copy for Symbol
impl Eq for Symbol
impl StructuralPartialEq for Symbol
Auto Trait Implementations§
impl Freeze for Symbol
impl RefUnwindSafe for Symbol
impl Send for Symbol
impl Sync for Symbol
impl Unpin for Symbol
impl UnsafeUnpin for Symbol
impl UnwindSafe for Symbol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more