Crate ihateintegrals

Source
Expand description

Computer algebra system for solving integrals.

This crate is does not have a stable api.

Provides types to represent symbolic math expressions and derivation tools to simplify them using equivalence rules.

  • Parse expressions to and from JSON
  • Derive their simplifications automatically
  • Gives steps used during the simplification

Here’s an example of solving/simplifying a trivial integral.

use ihateintegrals::simplify_incremental;
use ihateintegrals::{integral::Integral, integer::Integer, exponent::Exponent, variable::Variable};
use ihateintegrals::product::product_of;
use ihateintegrals::graph::Graph;
use ihateintegrals::EvaluateFirstProfile;

// Create an expression for the integral of 2x with respect to x
let start = Integral::of(
    product_of(&[Integer::of(2), Variable::of("x")]),
    Variable::of("x"),
);

// Create a derivation object for this expression
let mut handle = simplify_incremental(&start, EvaluateFirstProfile::new(), None);

// Do some simplification work
let result = handle.do_pass(20);

assert!(result.finished);
assert_eq!(result.failed, None);
assert_eq!(
    result.steps.unwrap().steps.last().unwrap().1,
    Exponent::of(Variable::of("x"), Integer::of(2))
);

// Assess the produced derivation graph
let graph: &Graph = handle.deriver();

Modules§

absolute_value
constant
derivative
exponent
fraction
graph
integer
integral
logarithm
negation
product
substitution
sum
trig_expression
undefined
variable

Structs§

BruteForceProfile
For every expression including children, apply every derivation rule on every pass.
DerivationDebugInfo
Debug information yielded during a derivation operation.
DerivationHandle
Stores a the data associated with a derivation calculation.
DerivationResult
The resulting simplification and steps from a derivation.
EvaluateFirstProfile
Apply evaluation/associative simplification rules with only one output first. Expressions which are simplified by these rules are then excluded from being used by more complex rules in later passes.
IncrementalResult
Path
A sequence of expressions interspersed with derivation steps.

Enums§

Expression
Expression enum with variants for every expression type. Expressions use flywheel pattern and should be created using the respective static function for that expression type.

Traits§

OptimizationProfile
An object to describe what optimization strategy should be used to minimize derivation steps.

Functions§

expression_from_json
Parses an expression from the given json string.
get_all_equivalents
Generate all the equivalents for the given expression within the given constraints.
simplify
Simplifies the given expression the best possible with the given constraints. This can take a long time for complex expressions, in which case you should use the incremental simplification function.
simplify_incremental
Returns a derivation handle which stores the given expression and parameters and can be used to incrementally simplify the given expression.