pub struct IntegrationByParts;Expand description
Integration by parts handler
Implementations§
Source§impl IntegrationByParts
impl IntegrationByParts
Sourcepub fn integrate(
expr: &Expression,
variable: Symbol,
depth: usize,
) -> Option<Expression>
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);Sourcepub fn integrate_with_context(
expr: &Expression,
variable: Symbol,
context: &StrategyContext,
depth: usize,
) -> Option<Expression>
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.
Sourcepub fn try_by_parts(
u: &Expression,
dv: &Expression,
variable: Symbol,
depth: usize,
) -> Option<Expression>
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);Sourcepub fn is_good_u_choice(expr: &Expression, variable: &Symbol) -> bool
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);Sourcepub fn integrate_repeated(
expr: &Expression,
variable: &Symbol,
max_iterations: usize,
) -> Option<Expression>
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§
impl Freeze for IntegrationByParts
impl RefUnwindSafe for IntegrationByParts
impl Send for IntegrationByParts
impl Sync for IntegrationByParts
impl Unpin for IntegrationByParts
impl UnwindSafe for IntegrationByParts
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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