Skip to content
Symi Docs
Rust

The Rust manual covers the recommended facade. The complete native crate is documented in the native Rust API reference.

On this page

Evaluation and constants

Symi distinguishes construction, symbolic execution, direct eager evaluation, and host-language truth queries.

Operation Result
comparison or Boolean constructor symbolic relation or formula
evaluate_truth(predicate) exact three-valued host result
predicate.execute() symbolic logical_true, logical_false, or an unevaluated expression
simplify_logical(predicate) logical form simplification, not a host Boolean conversion
limit(...) deferred limit expression
evaluate_limit(...) explicitly eager limit computation
derivative(...) deferred derivative expression
differentiate(...) eager differentiation
integral(...) deferred integral expression
integrate(...) eager integration

Three-valued results are True, False, or None in Python; true, false, or null in the JavaScript facade; and TruthValue in the Rust facade. Unknown means the proposition was not proved or disproved. It is not false and does not indicate invalid input.

execute recursively evaluates executable symbolic forms. It is the uniform way to evaluate a deferred derivative, integral, limit, sum, product, or decidable predicate while retaining a symbolic result when exact evaluation declines.

Constants#

Constant Python JavaScript facade Rust facade
pi symi.pi / context.pi symi.pi / context.pi session.pi()
Euler's number symi.e / context.e symi.e / context.e session.e()
Euler–Mascheroni symi.euler_gamma symi.euler_gamma session.euler_gamma()
imaginary unit symi.imaginary_unit symi.imaginary_unit session.imaginary_unit()
infinities and common sets module/context properties facade/context properties session methods

Python and JavaScript constants are immutable properties, not zero-argument functions. Each access returns a handle in the owning default or explicit context, so normal provenance rules still apply. Code using pi(), e(), or other former module calls must remove the parentheses.

pi#

api::Session method

pub fn pi(&self) -> Expression

The circle constant π\pi. Exact in every arithmetic operation; use evaluate_numeric for a decimal value to any number of significant digits.

e#

api::Session method

pub fn e(&self) -> Expression

Euler's number ee, the base of the natural logarithm. exp(1) and this constant are the same expression.

euler_gamma#

api::Session method

pub fn euler_gamma(&self) -> Expression

The Euler–Mascheroni constant γ\gamma. It appears in closed forms produced by digamma and related special functions.

imaginary_unit#

api::Session method

pub fn imaginary_unit(&self) -> Expression

The imaginary unit ii with i2=−1i^2 = -1. Use real_part and imaginary_part to decompose a complex expression.

infinity#

api::Session method

pub fn infinity(&self) -> Expression

Unsigned positive infinity ∞\infty. Negate it for −∞-\infty. Both are accepted as bounds by integrate_definite and as approach points by limit.

The remaining constants are documented with the structures that use them: logical_true and logical_false with Boolean algebra, and empty_set, real_line, complex_plane, and integer_set with sets.

Exact structural decomposition uses numerator_denominator, numerator, and denominator. Complex decomposition uses the existing complete names real_part and imaginary_part; no re or im aliases are provided.

Numeric evaluation#

Decimal approximations are produced only on explicit request, by the operations described in Numeric evaluation: evaluate_numeric for the value of a closed expression to any number of significant digits, and the numerical integration, summation, and root-finding operations beside it.

Example#

Construction, symbolic execution, and the exact host query are three separate steps.

Rust
use symi::api::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let session = Session::new();
    let relation = session.less_than(&session.rational(1, 3)?, &session.integer(1))?;

    println!("{}", relation);
    println!("{}", relation.execute()?);
    println!("{:?}", session.evaluate_truth(&relation)?);
    println!("{}", session.multiply(&session.pi(), &session.integer(2))?);
    Ok(())
}

Additional API#

DEFAULT_PRECISION_BITS#

api::analysis constant

pub const DEFAULT_PRECISION_BITS: u32 = numeric::DEFAULT_PRECISION_BITS;

The default working precision, in bits, of the inexact numeric evaluator.