#math-expressions #expression #integral #algebra #computer #symbolic-math #variables

bin+lib ihateintegrals

A computer algebra library for solving integrals

3 releases

0.1.2 May 8, 2024
0.1.1 May 8, 2024
0.1.0 May 8, 2024

#615 in Math

MIT license

275KB
7.5K SLoC

ihateintegrals

This crate provides types to represent mathematical expressions and simplify them automatically showing the steps used to derive the answer. This includes solving integrals. This crate is used as a backend for my cas website at ihateintegrals.com.

See crate documentation for examples and use.


lib.rs:

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();

Dependencies

~3.5–5MB
~83K SLoC