Expression

Enum Expression 

Source
pub enum Expression {
Show 15 variants Number(Number), Symbol(Symbol), Add(Arc<Vec<Expression>>), Mul(Arc<Vec<Expression>>), Pow(Arc<Expression>, Arc<Expression>), Function { name: Arc<str>, args: Arc<Vec<Expression>>, }, Constant(MathConstant), Set(Arc<Vec<Expression>>), Complex(Arc<ComplexData>), Matrix(Arc<Matrix>), Relation(Arc<RelationData>), Piecewise(Arc<PiecewiseData>), Interval(Arc<IntervalData>), Calculus(Arc<CalculusData>), MethodCall(Arc<MethodCallData>),
}
Expand description

Memory-optimized Expression enum (target: 32 bytes)

Uses Arc for O(1) clone performance - cloning is just an atomic increment. Hot-path variants (frequently used) are kept inline for performance. Cold-path variants (less common) use Arc to maintain small enum size.

Variants§

§

Number(Number)

§

Symbol(Symbol)

§

Add(Arc<Vec<Expression>>)

§

Mul(Arc<Vec<Expression>>)

§

Pow(Arc<Expression>, Arc<Expression>)

§

Function

Fields

§name: Arc<str>
§

Constant(MathConstant)

§

Set(Arc<Vec<Expression>>)

§

Complex(Arc<ComplexData>)

§

Matrix(Arc<Matrix>)

§

Relation(Arc<RelationData>)

§

Piecewise(Arc<PiecewiseData>)

§

Interval(Arc<IntervalData>)

§

Calculus(Arc<CalculusData>)

§

MethodCall(Arc<MethodCallData>)

Implementations§

Source§

impl Expression

Source

pub fn factorial(arg: Expression) -> Expression

Create factorial expression

Source

pub fn ln(arg: Expression) -> Expression

Create natural logarithm expression

Source§

impl Expression

Source

pub fn is_constant(&self) -> bool

Check if an expression is constant (contains no variables)

Source§

impl Expression

Source

pub fn separate_constants(&self) -> (Expression, Expression)

Separate variables and constants

Source§

impl Expression

Source

pub fn real(&self) -> Expression

Extract the real part of a complex number

Returns the real component of a complex expression. For non-complex expressions, returns the expression itself.

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(3), expr!(4));
let real_part = z.real();
assert_eq!(real_part, expr!(3));
Source

pub fn imag(&self) -> Expression

Extract the imaginary part of a complex number

Returns the imaginary component of a complex expression. For non-complex expressions, returns zero.

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(3), expr!(4));
let imag_part = z.imag();
assert_eq!(imag_part, expr!(4));
Source

pub fn conjugate(&self) -> Expression

Compute the complex conjugate

Returns the complex conjugate (a + bi → a - bi). For non-complex expressions, returns the expression itself.

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(3), expr!(4));
let conjugate = z.conjugate();
if let Expression::Complex(data) = conjugate {
    assert_eq!(data.real, expr!(3));
    assert_eq!(data.imag, expr!(-4));
}
Source

pub fn abs(&self) -> Expression

Compute the absolute value (modulus) of a complex number

Returns |z| = √(re² + im²). For complex numbers, this is the magnitude. For real numbers, this is the absolute value.

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(3), expr!(4));
let magnitude = z.abs();
Source

pub fn arg(&self) -> Expression

Compute the argument (phase angle) of a complex number

Returns the angle θ = atan2(im, re) in radians, in the range (-π, π]. This is the principal value of the argument.

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(1), expr!(1));
let angle = z.arg();
Source

pub fn to_polar(&self) -> (Expression, Expression)

Convert to polar form (magnitude, angle)

Returns (r, θ) where z = r·e^(iθ). The angle is in radians, in the range (-π, π].

§Examples
use mathhook_core::{Expression, expr};

let z = Expression::complex(expr!(3), expr!(4));
let (magnitude, angle) = z.to_polar();
Source

pub fn from_polar(magnitude: Expression, angle: Expression) -> Expression

Create a complex number from polar form

Converts polar coordinates (magnitude, angle) to rectangular form (a + bi). The angle should be in radians.

§Arguments
  • magnitude - The magnitude (r) of the complex number
  • angle - The angle (θ) in radians
§Examples
use mathhook_core::{Expression, expr};

let magnitude = expr!(5);
let angle = Expression::pi();
let z = Expression::from_polar(magnitude, angle);
Source

pub fn from_polar_form(magnitude: Expression, angle: Expression) -> Expression

Create a complex number from polar form

Converts polar coordinates (magnitude, angle) to rectangular form (a + bi).

§Examples
use mathhook_core::{Expression, expr};

let magnitude = expr!(5);
let angle = Expression::pi();
let z = Expression::from_polar_form(magnitude, angle);
Source

pub fn simplify_complex(expr: &Expression) -> Expression

Simplify complex expressions by removing zero parts

Converts complex numbers to their simplest form by removing zero real or imaginary components.

§Examples
use mathhook_core::{Expression, expr};
use mathhook_core::simplify::Simplify;

let z = Expression::complex(expr!(3), expr!(0));
let simplified = z.simplify();
Source§

impl Expression

Source

pub fn expand_binomial( &self, a: &Expression, b: &Expression, n: u32, ) -> Expression

Expand binomial expressions: (a + b)^n using binomial theorem

For commutative terms, uses binomial theorem: C(n,k) * a^k * b^(n-k) For noncommutative terms, uses direct multiplication to preserve order

Source§

impl Expression

Source

pub fn factor_numeric_coefficient(&self) -> (BigInt, Expression)

Factor out numeric coefficients

Source§

impl Expression

Source

pub fn factor_perfect_square(&self, terms: &[Expression]) -> Option<Expression>

Factor perfect square trinomials: a^2 + 2ab + b^2 = (a + b)^2

Source

pub fn factor_difference_of_squares( &self, a: &Expression, b: &Expression, ) -> Expression

Factor difference of squares: a^2 - b^2 = (a + b)(a - b)

Source§

impl Expression

Source

pub fn add_rationals(&self, other: &Expression) -> Expression

Add rational expressions: a/b + c/d = (ad + bc)/(bd)

Source

pub fn multiply_rationals(&self, other: &Expression) -> Expression

Multiply rational expressions: (a/b) * (c/d) = (ac)/(bd)

Source

pub fn simplify_complex_rational(&self) -> Expression

Simplify complex rational expressions

Source

pub fn extract_rational_coefficient(&self) -> (Ratio<BigInt>, Expression)

Extract rational coefficient from expression

Source

pub fn extract_rational_parts(&self) -> (String, String, Expression)

Extract rational coefficient as string parts (FFI-friendly, no BigRational)

Returns (numerator, denominator, remainder) where numerator/denominator is the rational coefficient and remainder is the non-rational part.

Source§

impl Expression

Source

pub fn is_valid_expression(&self) -> bool

Check if expression is a valid mathematical expression

Source

pub fn solver_to_latex(&self) -> String

Convert to LaTeX representation for solvers (avoid conflict)

Source

pub fn flatten_add_terms(&self) -> Vec<Expression>

Source

pub fn negate(&self) -> Expression

Negate an expression

Source§

impl Expression

Source

pub fn detect_advanced_zero_patterns(&self) -> bool

Advanced zero detection for specific algebraic patterns

Source§

impl Expression

Source

pub fn number<T>(value: T) -> Expression
where T: Into<Number>,

Create a number expression

§Examples
use mathhook_core::{Expression, Number};

let expr = Expression::number(42);
let expr = Expression::number(3.14);
Source

pub fn integer(value: i64) -> Expression

Create an integer expression

§Examples
use mathhook_core::Expression;

let expr = Expression::integer(42);
Source

pub fn big_integer(value: BigInt) -> Expression

Create an integer expression from BigInt

§Examples
use mathhook_core::Expression;
use num_bigint::BigInt;

let big_val = BigInt::from(42);
let expr = Expression::big_integer(big_val);
Source

pub fn rational(numerator: i64, denominator: i64) -> Expression

Create a rational number expression

§Examples
use mathhook_core::Expression;

let expr = Expression::rational(3, 4); // 3/4
let expr = Expression::rational(-1, 2); // -1/2
Source

pub fn float(value: f64) -> Expression

Create a float expression

§Examples
use mathhook_core::Expression;

let expr = Expression::float(3.14159);
Source

pub fn symbol<T>(symbol: T) -> Expression
where T: Into<Symbol>,

Create a symbol expression

§Examples
use mathhook_core::{symbol, Expression};

let expr = Expression::symbol(symbol!(x));
Source

pub fn add(terms: Vec<Expression>) -> Expression

Create an addition expression in canonical form

This constructor automatically produces a canonical form expression by:

  • Flattening nested additions: (a + b) + ca + b + c
  • Removing identity elements: x + 0x
  • Combining like terms: 2x + 3x5x
  • Sorting terms in canonical order: y + xx + y
  • Evaluating constant subexpressions: 2 + 35
§Examples
use mathhook_core::{Expression, expr};

// Constant folding
let expression = Expression::add(vec![
    Expression::integer(1),
    Expression::integer(2),
]);
assert_eq!(expression, Expression::integer(3));

// Identity element removal
let x = expr!(x);
let expression = Expression::add(vec![x.clone(), Expression::integer(0)]);
assert_eq!(expression, x);

// Commutativity (canonical ordering)
let y = expr!(y);
let expr1 = Expression::add(vec![x.clone(), y.clone()]);
let expr2 = Expression::add(vec![y.clone(), x.clone()]);
assert_eq!(expr1, expr2); // Both produce x + y in canonical order
Source

pub fn mul(factors: Vec<Expression>) -> Expression

Create a multiplication expression in canonical form

This constructor automatically produces a canonical form expression by:

  • Flattening nested multiplications: (a * b) * ca * b * c
  • Removing identity elements: x * 1x
  • Handling zero: x * 00
  • Sorting factors in canonical order: y * xx * y
  • Evaluating constant subexpressions: 2 * 36
  • Converting division to multiplication: a / ba * b^(-1)
§Examples
use mathhook_core::{Expression, expr};

// Constant folding
let expression = Expression::mul(vec![
    Expression::integer(2),
    Expression::integer(3),
]);
assert_eq!(expression, Expression::integer(6));

// Identity element removal
let x = expr!(x);
let expr = Expression::mul(vec![x.clone(), Expression::integer(1)]);
assert_eq!(expr, x);

// Zero handling
let expression = Expression::mul(vec![x.clone(), Expression::integer(0)]);
assert_eq!(expression, Expression::integer(0));

// Commutativity (canonical ordering)
let y = expr!(y);
let expr1 = Expression::mul(vec![x.clone(), y.clone()]);
let expr2 = Expression::mul(vec![y.clone(), x.clone()]);
assert_eq!(expr1, expr2); // Both produce x * y in canonical order
Source

pub fn pow(base: Expression, exponent: Expression) -> Expression

Create a power expression in canonical form

This constructor automatically produces a canonical form expression by:

  • Applying power identities: x^01, x^1x, 1^x1
  • Evaluating constant powers: 2^38
  • Converting negative exponents to rationals: x^(-1)1/x
  • Flattening nested powers: (x^a)^bx^(a*b)
  • Handling special cases: 0^n0 for positive n
§Examples
use mathhook_core::{Expression, expr};

// Power identities
let x = expr!(x);
let expression = Expression::pow(x.clone(), Expression::integer(1));
assert_eq!(expression, x);

let expression = Expression::pow(x.clone(), Expression::integer(0));
assert_eq!(expression, Expression::integer(1));

// Constant evaluation
let expression = expr!(2 ^ 3);
assert_eq!(expression, Expression::integer(8));

// Nested power flattening
let expression = Expression::pow(
    Expression::pow(x.clone(), Expression::integer(2)),
    Expression::integer(3),
);
// Produces x^6 in canonical form
Source

pub fn constant(constant: MathConstant) -> Expression

Create a constant expression

§Examples
use mathhook_core::{Expression, core::MathConstant};

let expr = Expression::constant(MathConstant::Pi);
Source

pub fn pi() -> Expression

Create a pi constant expression

§Examples
use mathhook_core::Expression;

let pi = Expression::pi();
Source

pub fn e() -> Expression

Create an e constant expression

§Examples
use mathhook_core::Expression;

let e = Expression::e();
Source

pub fn i() -> Expression

Create an imaginary unit expression

§Examples
use mathhook_core::Expression;

let i = Expression::i();
Source

pub fn infinity() -> Expression

Create an infinity expression

§Examples
use mathhook_core::Expression;

let inf = Expression::infinity();
Source

pub fn negative_infinity() -> Expression

Create a negative infinity expression

§Examples
use mathhook_core::Expression;

let neg_inf = Expression::negative_infinity();
Source

pub fn undefined() -> Expression

Create an undefined expression

§Examples
use mathhook_core::Expression;

let undef = Expression::undefined();
Source

pub fn golden_ratio() -> Expression

Create a golden ratio (phi) expression

§Examples
use mathhook_core::Expression;

let phi = Expression::golden_ratio();
Source

pub fn euler_gamma() -> Expression

Create an Euler-Mascheroni constant (gamma) expression

§Examples
use mathhook_core::Expression;

let gamma = Expression::euler_gamma();
Source

pub fn equation(left: Expression, right: Expression) -> Expression

Create an equation (equality relation)

§Examples
use mathhook_core::{Expression, expr};

let expr = Expression::equation(
    expr!(x),
    expr!(5),
);
Source

pub fn relation( left: Expression, right: Expression, relation_type: RelationType, ) -> Expression

Create a relation expression

§Examples
use mathhook_core::{Expression, expr};
use mathhook_core::core::expression::RelationType;

let relation = Expression::relation(
    expr!(x),
    expr!(5),
    RelationType::Greater,
);
Source

pub fn div(numerator: Expression, denominator: Expression) -> Expression

Create a division expression (symbolic, always succeeds)

This constructor is for symbolic division where the denominator may be unknown or symbolic. It converts division to multiplication by the reciprocal: a / ba * b^(-1)

For numerical evaluation contexts where you need to detect division by zero, use div_checked() instead.

§Examples
use mathhook_core::{Expression, symbol};

// Symbolic division (denominator is unknown)
let x = symbol!(x);
let expr = Expression::div(Expression::integer(1), Expression::symbol(x));
// Produces: 1 * x^(-1)

// Constant division (still symbolic context)
let expr = Expression::div(Expression::integer(3), Expression::integer(4));
// Produces: 3 * 4^(-1), which simplifies to 3/4
Source

pub fn div_checked( numerator: Expression, denominator: Expression, ) -> Result<Expression, MathError>

Create a division expression with division-by-zero checking

This constructor checks if the denominator is zero and returns an error if so. Use this in evaluation contexts where division by zero should be detected.

For symbolic contexts where the denominator is unknown or symbolic, use div() instead.

§Errors

Returns MathError::DivisionByZero if the denominator is exactly zero.

§Examples
use mathhook_core::{Expression, MathError};

// Valid division
let result = Expression::div_checked(
    Expression::integer(10),
    Expression::integer(2),
);
assert!(result.is_ok());

// Division by zero
let result = Expression::div_checked(
    Expression::integer(1),
    Expression::integer(0),
);
assert!(matches!(result, Err(MathError::DivisionByZero)));
Source§

impl Expression

Source

pub fn function<S>(name: S, args: Vec<Expression>) -> Expression
where S: AsRef<str>,

Create a function expression

§Examples
use mathhook_core::{Expression, expr};

let expression = Expression::function("sin", vec![expr!(x)]);
Source

pub fn sqrt(arg: Expression) -> Expression

Create a square root expression

§Examples
use mathhook_core::Expression;

let sqrt_2 = Expression::sqrt(Expression::integer(2));
Source

pub fn derivative( expression: Expression, variable: Symbol, order: u32, ) -> Expression

Create a derivative expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::derivative(
    Expression::pow(expr!(x), Expression::integer(2)),
    symbol!(x),
    1,
);
Source

pub fn integral(integrand: Expression, variable: Symbol) -> Expression

Create an integral expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::integral(
    expr!(x),
    symbol!(x),
);
Source

pub fn definite_integral( integrand: Expression, variable: Symbol, start: Expression, end: Expression, ) -> Expression

Create a definite integral expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::definite_integral(
    expr!(x),
    symbol!(x),
    Expression::integer(0),
    Expression::integer(1),
);
Source

pub fn limit( expression: Expression, variable: Symbol, point: Expression, ) -> Expression

Create a limit expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::limit(
    expr!(x),
    symbol!(x),
    Expression::integer(0),
);
Source

pub fn sum( expression: Expression, variable: Symbol, start: Expression, end: Expression, ) -> Expression

Create a sum expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::sum(
    expr!(i),
    symbol!(i),
    Expression::integer(1),
    Expression::integer(10),
);
Source

pub fn product( expression: Expression, variable: Symbol, start: Expression, end: Expression, ) -> Expression

Create a product expression

§Examples
use mathhook_core::{Expression, symbol, expr};

let expr = Expression::product(
    expr!(i),
    symbol!(i),
    Expression::integer(1),
    Expression::integer(10),
);
Source§

impl Expression

Source

pub fn complex(real: Expression, imag: Expression) -> Expression

Create a complex number expression

§Examples
use mathhook_core::Expression;

let expr = Expression::complex(
    Expression::integer(3),
    Expression::integer(4),
);
Source

pub fn set(elements: Vec<Expression>) -> Expression

Create a set expression

§Examples
use mathhook_core::Expression;

let set = Expression::set(vec![
    Expression::integer(1),
    Expression::integer(2),
    Expression::integer(3),
]);
Source

pub fn interval( start: Expression, end: Expression, start_inclusive: bool, end_inclusive: bool, ) -> Expression

Create an interval expression

§Examples
use mathhook_core::Expression;

let interval = Expression::interval(
    Expression::integer(0),
    Expression::integer(10),
    true,
    false,
);
Source

pub fn piecewise( pieces: Vec<(Expression, Expression)>, default: Option<Expression>, ) -> Expression

Create a piecewise function expression

§Examples
use mathhook_core::{Expression, symbol};

let piecewise = Expression::piecewise(
    vec![(Expression::symbol(symbol!(x)), Expression::integer(1))],
    Some(Expression::integer(0)),
);
Source

pub fn matrix(rows: Vec<Vec<Expression>>) -> Expression

Create a matrix expression from rows

§Examples
use mathhook_core::Expression;

let matrix = Expression::matrix(vec![
    vec![Expression::integer(1), Expression::integer(2)],
    vec![Expression::integer(3), Expression::integer(4)]
]);
Source

pub fn identity_matrix(size: usize) -> Expression

Create an identity matrix expression

§Examples
use mathhook_core::Expression;
use mathhook_core::matrices::operations::MatrixOperations;

let identity = Expression::identity_matrix(3);
assert!(identity.is_identity_matrix());
Source

pub fn method_call( object: Expression, method_name: impl Into<String>, args: Vec<Expression>, ) -> Expression

Create a method call expression

§Examples
use mathhook_core::{Expression, symbol};

let matrix = Expression::symbol(symbol!(A));
let det_call = Expression::method_call(matrix, "det", vec![]);
let trace_call = Expression::method_call(
    Expression::symbol(symbol!(B)),
    "trace",
    vec![]
);
Source

pub fn zero_matrix(rows: usize, cols: usize) -> Expression

Create a zero matrix expression

§Examples
use mathhook_core::matrices::operations::MatrixOperations;
use mathhook_core::Expression;

let zero = Expression::zero_matrix(2, 3);
assert!(zero.is_zero_matrix());
Source

pub fn diagonal_matrix(diagonal_elements: Vec<Expression>) -> Expression

Create a diagonal matrix expression

§Examples
use mathhook_core::Expression;

let diag = Expression::diagonal_matrix(vec![
    Expression::integer(1),
    Expression::integer(2),
    Expression::integer(3)
]);
Source

pub fn scalar_matrix(size: usize, scalar_value: Expression) -> Expression

Create a scalar matrix expression (c*I)

§Examples
use mathhook_core::Expression;

let scalar = Expression::scalar_matrix(3, Expression::integer(5));
// Creates 5*I (5 times the 3x3 identity matrix)
Source

pub fn matrix_from_arrays<const R: usize, const C: usize>( arrays: [[i64; C]; R], ) -> Expression

Create matrix from nested arrays (convenience method)

§Examples
use mathhook_core::Expression;

let matrix = Expression::matrix_from_arrays([
    [1, 2, 3],
    [4, 5, 6]
]);
Source

pub fn commutator(a: Expression, b: Expression) -> Expression

Create a commutator: [A, B] = AB - BA

The commutator measures the failure of two operators to commute. It is zero for commutative operators and nonzero for noncommutative.

§Examples
use mathhook_core::{Expression, symbol};

let A = Expression::symbol(symbol!(A; matrix));
let B = Expression::symbol(symbol!(B; matrix));
let comm = Expression::commutator(A.clone(), B.clone());
// Represents: AB - BA
§Mathematical Properties
  • [A, B] = -[B, A] (antisymmetry)
  • [A, A] = 0 (self-commutator is zero)
  • Jacobi identity: [A, [B, C]] + [B, [C, A]] + [C, [A, B]] = 0
§Quantum Mechanics Example
use mathhook_core::{Expression, symbol};

let x = Expression::symbol(symbol!(x; operator));
let p = Expression::symbol(symbol!(p; operator));
let comm = Expression::commutator(x, p);
// In quantum mechanics: [x, p] = ih (canonical commutation relation)
Source

pub fn anticommutator(a: Expression, b: Expression) -> Expression

Create an anticommutator: {A, B} = AB + BA

The anticommutator is the symmetric combination of two operators.

§Examples
use mathhook_core::{Expression, symbol};

let A = Expression::symbol(symbol!(A; matrix));
let B = Expression::symbol(symbol!(B; matrix));
let anticomm = Expression::anticommutator(A.clone(), B.clone());
// Represents: AB + BA
§Mathematical Properties
  • {A, B} = {B, A} (symmetry)
  • {A, A} = 2A^2 (self-anticommutator)
§Physics Example
use mathhook_core::{Expression, symbol};

let sigma_x = Expression::symbol(symbol!(sigma_x; operator));
let sigma_y = Expression::symbol(symbol!(sigma_y; operator));
let anticomm = Expression::anticommutator(sigma_x, sigma_y);
// For Pauli matrices: {sigma_x, sigma_y} = 0
Source§

impl Expression

Source

pub fn evaluate(&self) -> Result<Expression, MathError>

Evaluate expression with domain checking

Computes numerical values from expressions while validating mathematical domain constraints. Returns Result<Expression, MathError> to handle domain violations gracefully.

§Evaluation vs Simplification

Use evaluate() when: You need numerical results with domain validation Use simplify() when: You need algebraic reduction without domain checking Use evaluate_with_context() when: You need variable substitution + computation

§Domain Constraints Checked
  • sqrt(x): Requires x >= 0 in real domain
  • log(x): Requires x > 0 (pole at 0)
  • tan(x): Has poles at π/2 + nπ
  • arcsin(x), arccos(x): Require |x| <= 1 in real domain
  • csc(x), sec(x), cot(x): Have poles where sin/cos/tan = 0
  • Division by zero: Checked in x/y and x^(-n) for n > 0
§Returns
  • Ok(Expression): Evaluated result (numerical or symbolic if can’t evaluate)
  • Err(MathError::DomainError): Domain constraint violated
  • Err(MathError::DivisionByZero): Division by zero detected
§Examples
§Successful Evaluation
use mathhook_core::{Expression, MathError};

// Constants evaluate to numbers
let sum = Expression::add(vec![Expression::integer(2), Expression::integer(3)]);
assert_eq!(sum.evaluate().unwrap(), Expression::integer(5));

let product = Expression::mul(vec![Expression::integer(2), Expression::integer(3), Expression::integer(4)]);
assert_eq!(product.evaluate().unwrap(), Expression::integer(24));

// Special values
let sin_zero = Expression::function("sin".to_string(), vec![Expression::integer(0)]);
assert_eq!(sin_zero.evaluate().unwrap(), Expression::integer(0));
§Domain Errors
use mathhook_core::{expr, Expression, MathError};

// sqrt requires non-negative input
let sqrt_neg = Expression::function("sqrt".to_string(), vec![Expression::integer(-1)]);
assert!(matches!(
    sqrt_neg.evaluate(),
    Err(MathError::Pole { .. })
));

// log has pole at 0
assert!(matches!(
    expr!(log(0)).evaluate(),
    Err(MathError::Pole { .. })
));

// Division by zero
assert!(matches!(
    expr!(1 / 0).evaluate(),
    Err(MathError::DivisionByZero)
));
§Symbolic Results (No Variables to Substitute)
use mathhook_core::{expr, symbol};
use mathhook_core::simplify::Simplify;

let x = symbol!(x);

// Can't evaluate without variable value - returns simplified symbolic
let result = expr!(x + 1).evaluate().unwrap();
assert_eq!(result, expr!(x + 1).simplify());

// For variable substitution, use evaluate_with_context() instead
§Handling Errors
use mathhook_core::{Expression, MathError};

let sqrt_neg = Expression::function("sqrt".to_string(), vec![Expression::integer(-1)]);
match sqrt_neg.evaluate() {
    Ok(result) => println!("Result: {}", result),
    Err(MathError::DomainError { operation, value, reason }) => {
        eprintln!("Domain error in {}: {} ({})", operation, value, reason);
    }
    Err(e) => eprintln!("Other error: {:?}", e),
}
Source

pub fn evaluate_with_context( &self, context: &EvalContext, ) -> Result<Expression, MathError>

High-level evaluation with context

This is the PRIMARY user-facing evaluation method following SymPy’s two-level architecture. It handles:

  1. Variable substitution
  2. Optional symbolic simplification
  3. Optional numerical evaluation

This mirrors SymPy’s evalf(subs={...}, ...) high-level API.

§Arguments
  • context - Evaluation context (variables, numeric mode, precision, etc.)
§Returns

Evaluated expression

§Errors

Returns MathError for domain violations, undefined operations, etc.

§Examples
use mathhook_core::{expr, symbol};
use mathhook_core::core::expression::eval_numeric::EvalContext;
use std::collections::HashMap;

// Symbolic evaluation (no substitution)
let x = symbol!(x);
let f = expr!(x ^ 2);
let result = f.evaluate_with_context(&EvalContext::symbolic()).unwrap();
assert_eq!(result, expr!(x ^ 2)); // Unchanged

// Numerical evaluation with substitution
let mut vars = HashMap::new();
vars.insert("x".to_string(), expr!(3));
let ctx = EvalContext::numeric(vars);
let result = f.evaluate_with_context(&ctx).unwrap();
assert_eq!(result, expr!(9));
Source

pub fn evaluate_to_f64(&self) -> Result<f64, MathError>

Convert evaluated expression to f64

First evaluates the expression, then attempts to convert the result to f64. Returns error if the result is non-numerical (symbolic).

§Returns

f64 value if expression evaluates to a number

§Errors

Returns MathError::NonNumericalResult if evaluation produces symbolic expression

§Examples
use mathhook_core::{expr, symbol};

// Numerical expression
let e = expr!(2 + 3);
assert_eq!(e.evaluate_to_f64().unwrap(), 5.0);

// Symbolic expression fails
let x = symbol!(x);
assert!(x.evaluate_to_f64().is_err());
Source§

impl Expression

Source

pub fn substitute( &self, substitutions: &HashMap<String, Expression>, ) -> Expression

Substitute variables with expressions

Recursively replaces all occurrences of symbols with provided expressions.

§Arguments
  • substitutions - Map from symbol name to replacement expression
§Returns

New expression with substitutions applied

§Examples
use mathhook_core::{expr, symbol};
use std::collections::HashMap;

let x = symbol!(x);
let y = symbol!(y);
let e = expr!(x + y);

let mut subs = HashMap::new();
subs.insert("x".to_string(), expr!(3));
subs.insert("y".to_string(), expr!(4));

let result = e.substitute(&subs);
assert_eq!(result, expr!(3 + 4));
Source

pub fn substitute_and_simplify( &self, substitutions: &HashMap<String, Expression>, ) -> Expression

Substitute and simplify in one step

Convenience method that applies substitutions and then simplifies the result.

§Arguments
  • substitutions - Map from symbol name to replacement expression
§Returns

New simplified expression with substitutions applied

Source§

impl Expression

Source

pub fn transpose(&self) -> Expression

Compute transpose of matrix expression

For symbolic matrix expressions, this implements proper order reversal according to the mathematical rule: (AB)^T = B^T A^T

§Mathematical Rules
  • For products: (AB)^T = B^T A^T (order reverses)
  • For sums: (A+B)^T = A^T + B^T (distributes)
  • For scalars: scalar^T = scalar (no change)
  • For matrix symbols: A^T creates transpose function
§Examples
use mathhook_core::{Expression, symbol};

let a = symbol!(A; matrix);
let b = symbol!(B; matrix);

let product = Expression::mul(vec![
    Expression::symbol(a.clone()),
    Expression::symbol(b.clone()),
]);

let transposed = product.transpose();
Source

pub fn inverse(&self) -> Expression

Compute inverse of matrix expression

For symbolic matrix expressions, this implements proper order reversal according to the mathematical rule: (AB)^(-1) = B^(-1) A^(-1)

§Mathematical Rules
  • For products: (AB)^(-1) = B^(-1) A^(-1) (order reverses)
  • For matrix symbols: A^(-1) creates inverse function
  • For identity: I^(-1) = I
  • For scalars: a^(-1) = 1/a (reciprocal)
§Examples
use mathhook_core::{Expression, symbol};

let a = symbol!(A; matrix);
let b = symbol!(B; matrix);

let product = Expression::mul(vec![
    Expression::symbol(a.clone()),
    Expression::symbol(b.clone()),
]);

let inverse = product.inverse();
Source§

impl Expression

Source

pub fn commutativity(&self) -> Commutativity

Compute commutativity of this expression

Commutativity is inferred from the symbols and operations:

  • Numbers, constants: Commutative
  • Symbols: Depends on symbol type (Scalar -> Commutative, Matrix/Operator/Quaternion -> Noncommutative)
  • Mul: Noncommutative if ANY factor is noncommutative
  • Add, Pow, Function: Depends on subexpressions
§Examples

Basic scalar symbols (commutative):

use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::expression::Expression;
use mathhook_core::core::commutativity::Commutativity;

let x = Symbol::scalar("x");
let y = Symbol::scalar("y");
let expr = Expression::mul(vec![
    Expression::symbol(x.clone()),
    Expression::symbol(y.clone()),
]);
assert_eq!(expr.commutativity(), Commutativity::Commutative);

Matrix symbols (noncommutative):

use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::expression::Expression;
use mathhook_core::core::commutativity::Commutativity;

let a = Symbol::matrix("A");
let b = Symbol::matrix("B");
let expr = Expression::mul(vec![
    Expression::symbol(a.clone()),
    Expression::symbol(b.clone()),
]);
assert_eq!(expr.commutativity(), Commutativity::Noncommutative);
Source

pub fn count_variable_occurrences(&self, variable: &Symbol) -> usize

Count occurrences of a variable in the expression

Recursively counts how many times a specific variable symbol appears in the expression tree. This is useful for:

  • Determining if an expression is polynomial in a variable
  • Analyzing variable dependencies
  • Checking if a variable appears in an equation
§Arguments
  • variable - The symbol to count occurrences of
§Returns

The number of times the variable appears in the expression

§Examples

Basic counting in simple expressions:

use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let expr = Expression::mul(vec![
    Expression::integer(2),
    Expression::symbol(x.clone()),
]);
assert_eq!(expr.count_variable_occurrences(&x), 1);

Counting multiple occurrences:

use mathhook_core::{Expression, symbol};
use std::sync::Arc;

let x = symbol!(x);
// x^2 + 2*x + 1 has 2 occurrences of x (in x^2 and in 2*x)
let expr = Expression::Add(Arc::new(vec![
    Expression::pow(Expression::symbol(x.clone()), Expression::integer(2)),
    Expression::mul(vec![Expression::integer(2), Expression::symbol(x.clone())]),
    Expression::integer(1),
]));
assert_eq!(expr.count_variable_occurrences(&x), 2);

Counting in power expressions:

use mathhook_core::{Expression, symbol};

let x = symbol!(x);
// x^x has 2 occurrences (base and exponent)
let expr = Expression::pow(
    Expression::symbol(x.clone()),
    Expression::symbol(x.clone())
);
assert_eq!(expr.count_variable_occurrences(&x), 2);

Counting in functions:

use mathhook_core::{Expression, symbol};

let x = symbol!(x);
// sin(x)
let expr = Expression::function("sin", vec![Expression::symbol(x.clone())]);
assert_eq!(expr.count_variable_occurrences(&x), 1);

// f(x, x, 2) has 2 occurrences
let expr2 = Expression::function("f", vec![
    Expression::symbol(x.clone()),
    Expression::symbol(x.clone()),
    Expression::integer(2),
]);
assert_eq!(expr2.count_variable_occurrences(&x), 2);

Zero occurrences when variable is not present:

use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::symbol(y.clone());
assert_eq!(expr.count_variable_occurrences(&x), 0);
Source

pub fn contains_variable(&self, symbol: &Symbol) -> bool

Source

pub fn is_simple_variable(&self, var: &Symbol) -> bool

Check if expression is just the variable itself

Source

pub fn is_symbol_matching(&self, symbol: &Symbol) -> bool

Check if this expression is a specific symbol

Convenience method for pattern matching against a specific symbol. More readable than inline matches! pattern in complex conditions.

§Arguments
  • symbol - The symbol to check against
§Returns

True if this expression is exactly the given symbol

§Examples
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::symbol(x.clone());

assert!(expr.is_symbol_matching(&x));
assert!(!expr.is_symbol_matching(&y));
Source

pub fn as_pow(&self) -> Option<(&Expression, &Expression)>

Extract the base and exponent from a Pow expression

Returns Some((base, exp)) if this is a Pow expression, None otherwise. This is a helper method for pattern matching with the Arc-based structure.

Source

pub fn as_function(&self) -> Option<(&str, &[Expression])>

Extract the name and args from a Function expression

Returns Some((name, args)) if this is a Function expression, None otherwise. This is a helper method for pattern matching with the Arc-based structure.

Source§

impl Expression

Source

pub fn gcd(&self, other: &Expression) -> Expression

Compute the greatest common divisor of two expressions

For integer expressions, computes the mathematical GCD. For polynomial expressions with integer coefficients, uses fast IntPoly algorithm. For other expressions, returns 1.

§Arguments
  • other - The expression to compute GCD with
§Examples
use mathhook_core::expr;

let a = expr!(12);
let b = expr!(8);
let gcd = a.gcd(&b);
assert_eq!(gcd, expr!(4));
use mathhook_core::expr;

// GCD of zero with any number is that number
let a = expr!(0);
let b = expr!(15);
let gcd = a.gcd(&b);
assert_eq!(gcd, expr!(15));
Source

pub fn lcm(&self, other: &Expression) -> Expression

Compute the least common multiple of two expressions

For integer expressions, computes the mathematical LCM. For other expressions, returns the first expression.

§Arguments
  • other - The expression to compute LCM with
§Examples
use mathhook_core::expr;

let a = expr!(12);
let b = expr!(8);
let lcm = a.lcm(&b);
assert_eq!(lcm, expr!(24));
use mathhook_core::expr;

// LCM with zero is zero
let a = expr!(0);
let b = expr!(15);
let lcm = a.lcm(&b);
assert_eq!(lcm, expr!(0));
Source

pub fn factor_gcd(&self) -> Expression

Factor out the GCD from an expression

Currently a stub that returns the original expression. Will be implemented to extract common factors.

§Examples
use mathhook_core::{expr, Expression};

let expr = Expression::add(vec![
    expr!(6*x),
    expr!(9),
]);
let factored = expr.factor_gcd();
Source

pub fn cofactors( &self, other: &Expression, ) -> (Expression, Expression, Expression)

Compute GCD and cofactors

Returns a tuple of (gcd, cofactor_a, cofactor_b) where:

  • gcd is the greatest common divisor
  • cofactor_a = a / gcd
  • cofactor_b = b / gcd
§Arguments
  • other - The expression to compute cofactors with
§Examples
use mathhook_core::expr;

let a = expr!(12);
let b = expr!(8);
let (gcd, cofactor_a, cofactor_b) = a.cofactors(&b);
assert_eq!(gcd, expr!(4));
assert_eq!(cofactor_a, expr!(3));
assert_eq!(cofactor_b, expr!(2));
Source

pub fn find_variables(&self) -> Vec<Symbol>

Find all variables in expression

Returns a vector of all unique Symbol nodes found in the expression tree. This is used by GCD algorithms to detect univariate polynomials.

Source§

impl Expression

Source

pub fn solve(&self, variable: &Symbol) -> SolverResult

Solve equation for a variable with auto-detection

Solves the equation self = 0 for the given variable. Automatically detects equation type (linear, quadratic, ODE, etc.) and routes to the appropriate solver. For performance-critical code where you already know the equation type, use the fast path methods instead:

  • solve_linear()
  • solve_quadratic()
  • solve_polynomial()
  • solve_ode()
  • solve_pde()
  • solve_system()
§Arguments
  • variable - The variable to solve for
§Returns

The solver result containing solutions or error information

§Examples
use mathhook_core::{Expression, symbol};
use mathhook_core::algebra::solvers::SolverResult;

let x = symbol!(x);
let equation = Expression::add(vec![
    Expression::mul(vec![Expression::integer(2), Expression::symbol(x.clone())]),
    Expression::integer(-6),
]);

let result = equation.solve(&x);
match result {
    SolverResult::Single(solution) => {
        assert_eq!(solution, Expression::integer(3));
    }
    _ => panic!("Expected single solution"),
}
Source

pub fn solve_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Solve equation with step-by-step educational explanation

Solves the equation self = 0 for the given variable and generates an educational explanation showing each solving step. Use this when you need to teach or explain the solving process. For performance-critical code where you only need the answer, use solve() instead.

§Arguments
  • variable - The variable to solve for
§Returns

A tuple of (solver result, step-by-step explanation)

§Examples
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let equation = Expression::add(vec![
    Expression::mul(vec![Expression::integer(2), Expression::symbol(x.clone())]),
    Expression::integer(-6),
]);

let (result, explanation) = equation.solve_with_steps(&x);
// The explanation contains educational content showing how to solve the equation
Source§

impl Expression

Source

pub fn solve_linear(&self, variable: &Symbol) -> SolverResult

Fast path: solve as linear equation (skip classification)

Directly solves equations of the form ax + b = 0 without running equation type classification.

§Arguments
  • variable - The variable to solve for
§Returns

The solver result containing the solution x = -b/a

Source

pub fn solve_linear_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve as linear equation with steps (skip classification)

Source

pub fn solve_quadratic(&self, variable: &Symbol) -> SolverResult

Fast path: solve as quadratic equation (skip classification)

Directly solves equations of the form ax^2 + bx + c = 0 using the quadratic formula without running equation type classification.

§Arguments
  • variable - The variable to solve for
§Returns

The solver result containing solutions from the quadratic formula

Source

pub fn solve_quadratic_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve as quadratic equation with steps (skip classification)

Source

pub fn solve_polynomial(&self, variable: &Symbol) -> SolverResult

Fast path: solve as polynomial equation (skip classification)

Directly solves polynomial equations of degree 3+ (cubic, quartic, etc.) without running equation type classification.

§Arguments
  • variable - The variable to solve for
§Returns

The solver result containing polynomial roots

Source

pub fn solve_polynomial_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve as polynomial equation with steps (skip classification)

Source

pub fn solve_ode( &self, dependent: &Symbol, independent: &Symbol, ) -> SolverResult

Fast path: solve as ordinary differential equation (skip classification)

Directly solves ODEs using the cached ODE solver registry without running equation type classification. Supports separable, linear, and homogeneous first-order ODE types.

Uses a static cached registry for optimal performance on repeated calls.

§Arguments
  • dependent - The dependent variable (e.g., y)
  • independent - The independent variable (e.g., x)
§Returns

The solver result containing the ODE solution

Source

pub fn solve_ode_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve as ODE with steps (skip classification)

Source

pub fn solve_pde( &self, dependent: &Symbol, independent_vars: &[Symbol], ) -> SolverResult

Fast path: solve as partial differential equation (skip classification)

Directly solves PDEs using the cached PDE solver registry without running equation type classification. Supports heat equation, wave equation, Laplace equation, and other types.

Uses a static cached registry for optimal performance on repeated calls.

§Arguments
  • dependent - The dependent variable (e.g., u)
  • independent_vars - The independent variables (e.g., [x, t])
§Returns

The solver result containing the PDE solution

Source

pub fn solve_pde_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve as PDE with steps (skip classification)

Source

pub fn solve_system( equations: &[Expression], variables: &[Symbol], ) -> SolverResult

Fast path: solve system of equations (skip classification)

Directly solves systems of equations without running equation type classification. Supports linear systems (Gaussian elimination) and polynomial systems (Groebner basis).

§Arguments
  • equations - Slice of equations to solve
  • variables - Slice of variables to solve for
§Returns

The solver result containing system solutions

Source

pub fn solve_system_with_steps( equations: &[Expression], variables: &[Symbol], ) -> (SolverResult, StepByStepExplanation)

Fast path: solve system of equations with steps (skip classification)

Source

pub fn solve_matrix_equation(&self, variable: &Symbol) -> SolverResult

Fast path: solve matrix/noncommutative equation (skip classification)

Directly solves equations involving matrices, operators, or quaternions where multiplication order matters.

Handles:

  • Left multiplication: A*X = B (solution: X = A^(-1)*B)
  • Right multiplication: XA = B (solution: X = BA^(-1))
§Arguments
  • variable - The matrix/operator variable to solve for
§Returns

The solver result containing the matrix equation solution

Source

pub fn solve_matrix_equation_with_steps( &self, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Fast path: solve matrix equation with steps (skip classification)

Source§

impl Expression

Source

pub fn is_zero(&self) -> bool

Check if the expression is zero (robust version with simplification)

This method simplifies the expression first before checking if it equals zero. It correctly detects zero for expressions like:

  • Literal zeros: 0, 0.0, 0/1
  • Symbolic zeros: x - x, 0 * y, sin(0)
  • Simplified zeros: (x + 1) - (x + 1)
§Performance Note

This method calls simplify(), which may be expensive for complex expressions. For performance-critical code where you only need to check literal zeros, use is_zero_fast() instead.

§Examples
use mathhook_core::simplify::Simplify;
use mathhook_core::Expression;

// Literal zero
assert!(Expression::integer(0).is_zero());

// Symbolic zero after simplification
let expr = Expression::mul(vec![Expression::integer(0), Expression::integer(5)]);
assert!(expr.is_zero());
Source

pub fn is_zero_fast(&self) -> bool

Fast literal zero check without simplification

This is a performance-optimized version that only checks if the expression is literally Number(0). It does NOT simplify the expression first.

Use this in performance-critical loops where you know the expression is already in simplified form, or where you specifically want to check for literal zeros only.

§Examples
use mathhook_core::Expression;

// Detects literal zero
assert!(Expression::integer(0).is_zero_fast());

// Mul constructor auto-simplifies, so this IS detected
let expr = Expression::mul(vec![Expression::integer(0), Expression::integer(5)]);
assert!(expr.is_zero_fast()); // Simplified to 0 by constructor

// Example of what is_zero_fast() does NOT detect (without simplification):
// If we had a raw unsimplified Mul expression, is_zero_fast() wouldn't detect it
Source

pub fn is_one(&self) -> bool

Check if the expression is one (robust version with simplification)

This method simplifies the expression first before checking if it equals one. It correctly detects one for expressions like:

  • Literal ones: 1, 1.0, 2/2
  • Symbolic ones: x / x, x^0, cos(0)
  • Simplified ones: (x + 1) / (x + 1)
§Performance Note

This method calls simplify(), which may be expensive for complex expressions. For performance-critical code where you only need to check literal ones, use is_one_fast() instead.

§Examples
use mathhook_core::simplify::Simplify;
use mathhook_core::Expression;

// Literal one
assert!(Expression::integer(1).is_one());

// Symbolic one after simplification
let expr = Expression::pow(Expression::integer(5), Expression::integer(0));
assert!(expr.is_one());
Source

pub fn is_one_fast(&self) -> bool

Fast literal one check without simplification

This is a performance-optimized version that only checks if the expression is literally Number(1). It does NOT simplify the expression first.

Use this in performance-critical loops where you know the expression is already in simplified form, or where you specifically want to check for literal ones only.

§Examples
use mathhook_core::Expression;

// Detects literal one
assert!(Expression::integer(1).is_one_fast());

// Pow constructor auto-simplifies, so x^0 = 1 IS detected
let expr = Expression::pow(Expression::integer(5), Expression::integer(0));
assert!(expr.is_one_fast()); // Simplified to 1 by constructor

// is_one_fast() checks ONLY for literal Number(1)
// It does not simplify complex expressions first
Source

pub fn as_number(&self) -> Option<&Number>

Get the numeric coefficient if this is a simple numeric expression

Source

pub fn as_symbol(&self) -> Option<&Symbol>

Get the symbol if this is a simple symbol expression

Source

pub fn is_negative_number(&self) -> bool

Check if this expression is a negative number

Returns true if the expression is a negative integer, rational, or float. Returns false for symbolic expressions (even if they might evaluate to negative).

§Examples
use mathhook_core::Expression;

assert!(Expression::integer(-5).is_negative_number());
assert!(Expression::rational(-1, 2).is_negative_number());
assert!(!Expression::integer(5).is_negative_number());
assert!(!Expression::symbol("x").is_negative_number()); // Symbolic, not a number
Source

pub fn is_positive_number(&self) -> bool

Check if this expression is a positive number

Returns true if the expression is a positive integer, rational, or float. Returns false for symbolic expressions (even if they might evaluate to positive).

§Examples
use mathhook_core::Expression;

assert!(Expression::integer(5).is_positive_number());
assert!(Expression::rational(1, 2).is_positive_number());
assert!(!Expression::integer(-5).is_positive_number());
assert!(!Expression::symbol("x").is_positive_number()); // Symbolic, not a number
Source

pub fn evaluate_method_call(&self) -> Expression

Evaluate method calls on expressions

This handles method calls like matrix.det(), matrix.trace(), etc. by calling the appropriate methods on the underlying objects.

Source

pub fn is_function(&self) -> bool

Check if this expression represents a mathematical function

Returns true for expressions like sin(x), cos(x), etc. Now integrated with Universal Function Intelligence System

Source

pub fn get_function_intelligence(&self) -> Option<&FunctionProperties>

Get function intelligence properties if available

Seamless integration between core expressions and function intelligence

Source

pub fn explain_function(&self) -> Vec<Step>

Generate educational explanation for function expressions

Perfect integration with the educational system

Source§

impl Expression

Convenient formatting methods for Expression without requiring context

Source

pub fn format(&self) -> Result<String, FormattingError>

Format expression using default LaTeX formatting

This is the most convenient way to format expressions when you don’t need specific formatting options. Always uses LaTeX format.

§Examples
use mathhook_core::core::Expression;
use mathhook_core::{expr};

let x_expr = expr!(x);
let formatted = x_expr.format().unwrap();
// Returns LaTeX formatted string
Source

pub fn format_as( &self, language: MathLanguage, ) -> Result<String, FormattingError>

Format expression with specific language/format

§Examples
use mathhook_core::core::Expression;
use mathhook_core::formatter::MathLanguage;
use mathhook_core::expr;

let x_expr = expr!(x);
let latex = x_expr.format_as(MathLanguage::LaTeX).unwrap();
let simple = x_expr.format_as(MathLanguage::Simple).unwrap();
let wolfram = x_expr.format_as(MathLanguage::Wolfram).unwrap();
Source§

impl Expression

Source

pub fn matrix_dimensions(&self) -> Option<(usize, usize)>

Get matrix dimensions for any matrix type

Returns (rows, columns) for all matrix types.

§Examples
use mathhook_core::Expression;

let matrix = Expression::matrix(vec![
    vec![Expression::integer(1), Expression::integer(2)],
    vec![Expression::integer(3), Expression::integer(4)]
]);
assert_eq!(matrix.matrix_dimensions(), Some((2, 2)));

let identity = Expression::identity_matrix(3);
assert_eq!(identity.matrix_dimensions(), Some((3, 3)));
Source

pub fn is_matrix(&self) -> bool

Check if expression is any kind of matrix

Trait Implementations§

Source§

impl Add<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add<i32> for &Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Expression

Performs the + operation. Read more
Source§

impl Add<i32> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Expression

Performs the + operation. Read more
Source§

impl Add for &Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Expression) -> Expression

Performs the + operation. Read more
Source§

impl AdvancedPolynomial for Expression

Source§

fn polynomial_divide(&self, divisor: &Expression) -> (Expression, Expression)

Polynomial division using optimized algorithms

Source§

fn polynomial_remainder(&self, divisor: &Expression) -> Expression

Polynomial remainder

Source§

fn polynomial_degree(&self, var: &Symbol) -> Option<i64>

Polynomial degree computation

Source§

fn polynomial_leading_coefficient(&self, var: &Symbol) -> Expression

Leading coefficient extraction
Source§

fn polynomial_content(&self) -> Expression

Content extraction (GCD of coefficients)
Source§

fn polynomial_primitive_part(&self) -> Expression

Primitive part extraction (polynomial / content)
Source§

fn polynomial_resultant(&self, other: &Expression, var: &Symbol) -> Expression

Resultant computation for polynomial elimination
Source§

fn polynomial_discriminant(&self, var: &Symbol) -> Expression

Discriminant computation
Source§

impl AdvancedSimplify for Expression

Source§

fn advanced_simplify(&self) -> Expression

Perform advanced simplification including special functions

Source§

fn simplify_factorial(&self) -> Expression

Simplify factorial expressions

Source§

fn simplify_logarithms(&self) -> Expression

Simplify logarithmic expressions

Source§

fn simplify_trigonometric(&self) -> Expression

Simplify trigonometric expressions

Source§

fn simplify_special_functions(&self) -> Expression

Simplify other special functions

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

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 Collect for Expression

Source§

fn collect(&self, var: &Symbol) -> Expression

Collect terms with respect to a specific variable

Source§

fn collect_terms(&self) -> Expression

Collect and combine all like terms

Source§

fn combine_like_terms(&self) -> Expression

Combine like terms in the expression

Source§

impl ComplexAnalysis for Expression

Source§

fn is_analytic_at(&self, variable: &Symbol, point: &Expression) -> bool

Check if function is analytic at a point Read more
Source§

fn pole_order(&self, variable: &Symbol, pole: &Expression) -> u32

Determine the order of a pole Read more
Source§

fn is_removable_singularity( &self, variable: &Symbol, point: &Expression, ) -> bool

Check if point is a removable singularity Read more
Source§

fn is_essential_singularity( &self, variable: &Symbol, point: &Expression, ) -> bool

Check if point is an essential singularity Read more
Source§

impl ComplexOperations for Expression

Source§

fn complex_add(&self, other: &Expression) -> Expression

Add two complex expressions Read more
Source§

fn complex_subtract(&self, other: &Expression) -> Expression

Subtract two complex expressions Read more
Source§

fn complex_multiply(&self, other: &Expression) -> Expression

Multiply two complex expressions Read more
Source§

fn complex_divide(&self, other: &Expression) -> Expression

Divide two complex expressions Read more
Source§

fn complex_conjugate(&self) -> Expression

Get the complex conjugate Read more
Source§

fn complex_modulus(&self) -> Expression

Get the modulus (absolute value) Read more
Source§

fn complex_argument(&self) -> Expression

Get the argument (angle in radians) Read more
Source§

fn to_polar_form(&self) -> (Expression, Expression)

Convert to polar form (magnitude, angle) Read more
Source§

fn is_real(&self) -> bool

Check if the expression is real Read more
Source§

fn is_imaginary(&self) -> bool

Check if the expression has an imaginary component Read more
Source§

fn is_pure_imaginary(&self) -> bool

Check if the expression is pure imaginary Read more
Source§

impl Debug for Expression

Source§

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

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

impl Derivative for Expression

Source§

fn derivative(&self, variable: Symbol) -> Expression

Compute the derivative with respect to a variable Read more
Source§

fn nth_derivative(&self, variable: Symbol, order: u32) -> Expression

Compute higher-order derivatives Read more
Source§

fn is_differentiable(&self, variable: Symbol) -> bool

Check if expression is differentiable with respect to variable Read more
Source§

impl DerivativeWithSteps for Expression

Source§

fn derivative_with_steps( &self, variable: &Symbol, order: u32, ) -> StepByStepExplanation

Compute derivative with step-by-step explanation Read more
Source§

impl<'de> Deserialize<'de> for Expression

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Expression, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Expression

Source§

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

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

impl EvalNumeric for Expression

Source§

fn eval_numeric(&self, _precision: u32) -> Result<Expression, MathError>

Evaluate expression to numerical form Read more
Source§

impl Expand for Expression

Source§

fn expand(&self) -> Expression

Expand the expression by distributing multiplication over addition

Source§

impl<C> ExpressionFormatter<C> for Expression

Source§

fn format(&self, context: &C) -> Result<String, FormattingError>

Source§

impl Factor for Expression

Source§

fn factor(&self) -> Expression

Factor the expression by extracting common factors

Source§

fn factor_out_gcd(&self) -> Expression

Factor out the GCD from an expression

Source§

fn factor_common(&self) -> Expression

Factor common elements

Source§

impl From<&str> for Expression

Source§

fn from(name: &str) -> Expression

Converts to this type from the input type.
Source§

impl From<Symbol> for Expression

Source§

fn from(symbol: Symbol) -> Expression

Converts to this type from the input type.
Source§

impl From<f64> for Expression

Source§

fn from(value: f64) -> Expression

Converts to this type from the input type.
Source§

impl From<i32> for Expression

Source§

fn from(value: i32) -> Expression

Converts to this type from the input type.
Source§

impl From<i64> for Expression

Source§

fn from(value: i64) -> Expression

Converts to this type from the input type.
Source§

impl Integration for Expression

Source§

fn integrate(&self, variable: Symbol, depth: usize) -> Expression

Compute indefinite integral with recursion depth tracking Read more
Source§

fn definite_integrate( &self, variable: Symbol, lower: Expression, upper: Expression, ) -> Result<Expression, MathError>

Compute definite integral Read more
Source§

impl LaTeXFormatter for Expression

Source§

fn to_latex_with_depth( &self, context: &LaTeXContext, depth: usize, ) -> Result<String, FormattingError>

Format with explicit recursion depth tracking Read more
Source§

fn function_to_latex_with_depth( &self, name: &str, args: &[Expression], context: &LaTeXContext, depth: usize, ) -> Result<String, FormattingError>

Convert function to LaTeX with context and depth tracking
Source§

fn to_latex<C>(&self, context: C) -> Result<String, FormattingError>

Format an Expression as LaTeX mathematical notation Read more
Source§

fn function_to_latex( &self, name: &str, args: &[Expression], context: &LaTeXContext, ) -> Result<String, FormattingError>

Convert function to LaTeX (convenience method)
Source§

impl Limits for Expression

Source§

fn limit(&self, variable: &Symbol, point: &Expression) -> Expression

Compute two-sided limit Read more
Source§

fn limit_directed( &self, variable: &Symbol, point: &Expression, direction: LimitDirection, ) -> Expression

Compute one-sided limit Read more
Source§

fn limit_at_infinity(&self, variable: &Symbol) -> Expression

Compute limit at infinity Read more
Source§

fn limit_at_negative_infinity(&self, variable: &Symbol) -> Expression

Compute limit at negative infinity Read more
Source§

impl Matchable for Expression

Source§

fn matches(&self, pattern: &Pattern) -> Option<HashMap<String, Expression>>

Match this expression against a pattern Read more
Source§

fn replace(&self, pattern: &Pattern, replacement: &Pattern) -> Expression

Replace all occurrences of a pattern with a replacement expression Read more
Source§

impl MatrixOperations for Expression

Source§

fn matrix_add(&self, other: &Expression) -> Expression

Add two matrices Read more
Source§

fn matrix_subtract(&self, other: &Expression) -> Expression

Subtract two matrices
Source§

fn matrix_multiply(&self, other: &Expression) -> Expression

Multiply two matrices
Source§

fn matrix_scalar_multiply(&self, scalar: &Expression) -> Expression

Multiply matrix by scalar
Source§

fn matrix_determinant(&self) -> Expression

Get matrix determinant
Source§

fn matrix_transpose(&self) -> Expression

Get matrix transpose
Source§

fn matrix_inverse(&self) -> Expression

Get matrix inverse
Source§

fn matrix_trace(&self) -> Expression

Get matrix trace (sum of diagonal elements)
Source§

fn matrix_power(&self, exponent: &Expression) -> Expression

Raise matrix to a power
Source§

fn is_identity_matrix(&self) -> bool

Check if matrix is identity matrix
Source§

fn is_zero_matrix(&self) -> bool

Check if matrix is zero matrix
Source§

fn is_diagonal(&self) -> bool

Check if matrix is diagonal
Source§

fn simplify_matrix(&self) -> Expression

Simplify matrix expression
Source§

impl Mul<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul<i32> for &Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Expression

Performs the * operation. Read more
Source§

impl Mul<i32> for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Expression

Performs the * operation. Read more
Source§

impl Mul for &Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Expression) -> Expression

Performs the * operation. Read more
Source§

impl Neg for &Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expression

Performs the unary - operation. Read more
Source§

impl Neg for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expression

Performs the unary - operation. Read more
Source§

impl PartialEq for Expression

Source§

fn eq(&self, other: &Expression) -> 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 PolynomialArithmetic for Expression

Source§

fn poly_div( &self, divisor: &Expression, var: &Symbol, ) -> Result<(Expression, Expression), PolynomialError>

Perform polynomial long division Read more
Source§

fn poly_quo( &self, divisor: &Expression, var: &Symbol, ) -> Result<Expression, PolynomialError>

Get quotient of polynomial division Read more
Source§

fn poly_rem( &self, divisor: &Expression, var: &Symbol, ) -> Result<Expression, PolynomialError>

Get remainder of polynomial division Read more
Source§

fn is_divisible_by(&self, divisor: &Expression, var: &Symbol) -> bool

Check if one polynomial divides another exactly Read more
Source§

impl PolynomialClassification for Expression

Source§

fn is_polynomial(&self) -> bool

Check if expression is a valid polynomial Read more
Source§

fn is_polynomial_in(&self, vars: &[Symbol]) -> bool

Check if polynomial in specific variables Read more
Source§

fn polynomial_variables(&self) -> Vec<Symbol>

Get polynomial variables (empty if not polynomial) Read more
Source§

fn classify(&self) -> ExpressionClass

Classify expression type for routing Read more
Source§

fn is_intpoly_compatible(&self) -> bool

Check if expression can be represented as IntPoly Read more
Source§

fn try_as_intpoly(&self) -> Option<(Poly<i64>, Symbol)>

Try to convert to IntPoly Read more
Source§

impl PolynomialEducational for Expression

Source§

fn explain_poly_division( &self, divisor: &Expression, var: &Symbol, ) -> StepByStepExplanation

Generate step-by-step explanation for polynomial division Read more
Source§

fn explain_poly_gcd(&self, other: &Expression) -> StepByStepExplanation

Generate step-by-step explanation for GCD computation Read more
Source§

fn explain_poly_factorization(&self, var: &Symbol) -> StepByStepExplanation

Generate step-by-step explanation for factorization Read more
Source§

impl PolynomialGcd for Expression

Source§

fn gcd(&self, other: &Expression) -> Expression

GCD using IntPoly fast-path (primary path)

Converts to IntPoly at API boundary, performs pure numeric GCD, converts result back. NO Expression tree walking in fast path.

Source§

fn lcm(&self, other: &Expression) -> Expression

Least Common Multiple

Source§

fn factor_gcd(&self) -> Expression

Factor out GCD from expression

Source§

fn cofactors(&self, other: &Expression) -> (Expression, Expression, Expression)

Compute GCD and cofactors: returns (gcd, a/gcd, b/gcd)

Source§

fn div_polynomial( &self, divisor: &Expression, var: &Symbol, ) -> (Expression, Expression)

Divides this polynomial by another, returning (quotient, remainder). Read more
Source§

fn quo_polynomial(&self, divisor: &Expression, var: &Symbol) -> Expression

Returns the quotient of polynomial division. Read more
Source§

fn rem_polynomial(&self, divisor: &Expression, var: &Symbol) -> Expression

Returns the remainder of polynomial division. Read more
Source§

impl PolynomialGcdOps for Expression

Source§

fn polynomial_gcd( &self, other: &Expression, ) -> Result<Expression, PolynomialError>

Compute GCD of two polynomials Read more
Source§

fn polynomial_lcm( &self, other: &Expression, ) -> Result<Expression, PolynomialError>

Compute LCM of two polynomials Read more
Source§

fn polynomial_cofactors( &self, other: &Expression, ) -> Result<(Expression, Expression, Expression), PolynomialError>

Compute GCD and cofactors Read more
Source§

impl PolynomialProperties for Expression

Source§

fn degree(&self, var: &Symbol) -> Option<i64>

Compute degree with respect to a variable Read more
Source§

fn total_degree(&self) -> Option<i64>

Compute total degree (sum of degrees in all variables) Read more
Source§

fn leading_coefficient(&self, var: &Symbol) -> Expression

Get leading coefficient with respect to a variable Read more
Source§

fn content(&self) -> Expression

Extract content (GCD of all coefficients) Read more
Source§

fn primitive_part(&self) -> Expression

Extract primitive part (polynomial divided by content) Read more
Source§

impl RationalSimplify for Expression

Source§

fn simplify_rational(&self) -> Expression

Simplify rational expressions by canceling common factors

Source§

fn to_rational_form(&self) -> (Expression, Expression)

Convert to rational form (numerator/denominator)

Source§

fn rationalize(&self) -> Expression

Rationalize denominators (remove radicals from denominators)

Source§

impl ResidueCalculus for Expression

Source§

fn residue(&self, variable: &Symbol, pole: &Expression) -> Expression

Compute residue at a pole Read more
Source§

fn find_poles(&self, variable: &Symbol) -> Vec<Expression>

Find all poles of the function Read more
Source§

fn contour_integral(&self, variable: &Symbol) -> Expression

Compute contour integral using residue theorem Read more
Source§

impl Serialize for Expression

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SeriesExpansion for Expression

Source§

fn taylor_series( &self, variable: &Symbol, point: &Expression, order: u32, ) -> Expression

Compute Taylor series expansion Read more
Source§

fn laurent_series( &self, variable: &Symbol, point: &Expression, order: u32, ) -> Expression

Compute Laurent series expansion Read more
Source§

fn maclaurin_series(&self, variable: &Symbol, order: u32) -> Expression

Compute Maclaurin series (Taylor around 0) Read more
Source§

fn power_series_coefficients( &self, variable: &Symbol, point: &Expression, order: u32, ) -> Vec<Expression>

Compute power series coefficients Read more
Source§

impl SimpleFormatter for Expression

Source§

fn to_simple_with_depth( &self, context: &SimpleContext, depth: usize, ) -> Result<String, FormattingError>

Format with explicit recursion depth tracking Read more
Source§

fn to_simple(&self, context: &SimpleContext) -> Result<String, FormattingError>

Format an Expression as simple mathematical notation Read more
Source§

impl Simplify for Expression

Source§

fn simplify(&self) -> Expression

Simplify expression using algebraic reduction rules Read more
Source§

impl SolverStepByStep for Expression

Source§

fn solve_with_steps( &self, _variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Solve with complete step-by-step explanation
Source§

fn explain_solving_steps(&self, variable: &Symbol) -> StepByStepExplanation

Generate step-by-step explanation for solving process
Source§

impl StepByStep for Expression

Source§

fn explain_simplification(&self) -> StepByStepExplanation

Generate step-by-step explanation for simplification

Source§

fn explain_expansion(&self) -> StepByStepExplanation

Generate step-by-step explanation for expansion

Source§

fn explain_factorization(&self) -> StepByStepExplanation

Generate step-by-step explanation for factorization

Source§

impl Sub<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub<i32> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Expression

Performs the - operation. Read more
Source§

impl Sub for &Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Expression) -> Expression

Performs the - operation. Read more
Source§

impl Substitutable for Expression

Source§

fn subs(&self, old: &Expression, new: &Expression) -> Expression

Substitute a single expression with another Read more
Source§

fn subs_multiple( &self, substitutions: &[(Expression, Expression)], ) -> Expression

Apply multiple substitutions simultaneously Read more
Source§

impl Summation for Expression

Source§

fn finite_sum( &self, variable: &Symbol, start: &Expression, end: &Expression, ) -> Expression

Compute finite sum Read more
Source§

fn infinite_sum(&self, variable: &Symbol, start: &Expression) -> Expression

Compute infinite sum Read more
Source§

fn finite_product( &self, variable: &Symbol, start: &Expression, end: &Expression, ) -> Expression

Compute finite product Read more
Source§

fn infinite_product(&self, variable: &Symbol, start: &Expression) -> Expression

Compute infinite product Read more
Source§

impl SummationEducational for Expression

Source§

fn explain_finite_sum( &self, variable: &Symbol, start: &Expression, end: &Expression, ) -> StepByStepExplanation

Explain finite sum computation with step-by-step guidance Read more
Source§

fn explain_infinite_sum( &self, variable: &Symbol, start: &Expression, ) -> StepByStepExplanation

Explain infinite sum computation with convergence analysis Read more
Source§

impl WolframFormatter for Expression

Source§

fn format_function_with_depth( &self, name: &str, args: &[Expression], context: &WolframContext, depth: usize, ) -> Result<String, FormattingError>

Convert function to Wolfram Language with depth tracking

Source§

fn to_wolfram_with_depth( &self, context: &WolframContext, depth: usize, ) -> Result<String, FormattingError>

Format with explicit recursion depth tracking Read more
Source§

fn to_wolfram( &self, context: &WolframContext, ) -> Result<String, FormattingError>

Format an Expression as Wolfram Language notation Read more
Source§

impl ZeroDetection for Expression

Source§

fn is_algebraic_zero(&self) -> bool

Detect if an expression is algebraically equivalent to zero

Source§

fn detect_zero_patterns(&self) -> bool

Detect common patterns that equal zero

Source§

fn simplify_to_zero(&self) -> Option<Expression>

Try to simplify expression to zero if it’s algebraically zero

Source§

impl StructuralPartialEq for Expression

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> CalculusOperations for T

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,