IntegrationByParts

Struct IntegrationByParts 

Source
pub struct IntegrationByParts;
Expand description

Integration by parts handler

Implementations§

Source§

impl IntegrationByParts

Source

pub fn integrate( expr: &Expression, variable: Symbol, depth: usize, ) -> Option<Expression>

Attempt integration by parts on an expression

Uses LIATE rule to select u and dv:

  • L: Logarithmic functions (ln, log)
  • I: Inverse trigonometric functions (arcsin, arctan, etc.)
  • A: Algebraic functions (polynomials, powers)
  • T: Trigonometric functions (sin, cos, tan)
  • E: Exponential functions (e^x, a^x)
§Examples
use mathhook_core::calculus::integrals::by_parts::IntegrationByParts;
use mathhook_core::calculus::integrals::Integration;
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
// ∫ x·e^x dx
let expr = Expression::mul(vec![
    Expression::symbol(x.clone()),
    Expression::function("exp", vec![Expression::symbol(x.clone())])
]);
let result = IntegrationByParts::integrate(&expr, x, 0);
Source

pub fn integrate_with_context( expr: &Expression, variable: Symbol, context: &StrategyContext, depth: usize, ) -> Option<Expression>

Integration by parts with strategy context tracking

Prevents infinite recursion by using strategy context. The context is already marked with IntegrationByParts active, so recursive calls won’t try by_parts again.

Source

pub fn try_by_parts( u: &Expression, dv: &Expression, variable: Symbol, depth: usize, ) -> Option<Expression>

Try integration by parts with specific u and dv

∫ u dv = uv - ∫ v du

§Examples
use mathhook_core::calculus::integrals::by_parts::IntegrationByParts;
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let u = Expression::symbol(x.clone());
let dv = Expression::function("exp", vec![Expression::symbol(x.clone())]);
let result = IntegrationByParts::try_by_parts(&u, &dv, x, 0);
Source

pub fn is_good_u_choice(expr: &Expression, variable: &Symbol) -> bool

Determine if an expression is a good choice for u (LIATE priority)

§Examples
use mathhook_core::calculus::integrals::by_parts::IntegrationByParts;
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
let expr = Expression::function("ln", vec![Expression::symbol(x.clone())]);
let is_good = IntegrationByParts::is_good_u_choice(&expr, &x);
Source

pub fn integrate_repeated( expr: &Expression, variable: &Symbol, max_iterations: usize, ) -> Option<Expression>

Apply integration by parts multiple times (for cases like ∫ x²·e^x dx)

§Examples
use mathhook_core::calculus::integrals::by_parts::IntegrationByParts;
use mathhook_core::{Expression, symbol};

let x = symbol!(x);
// ∫ x²·e^x dx requires two applications of by parts
let expr = Expression::mul(vec![
    Expression::pow(Expression::symbol(x.clone()), Expression::integer(2)),
    Expression::function("exp", vec![Expression::symbol(x.clone())])
]);
let result = IntegrationByParts::integrate_repeated(&expr, &x, 2);

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> 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, 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.