Skip to content

Add u-substitution rule (f'(x) * g(f(x))) #7

@Pooria-Lari

Description

@Pooria-Lari

Goal

Implement a basic u-substitution integrator rule to handle patterns like:

  • ∫ 2xcos(x^2) dx = sin(x^2)
  • ∫ 3exp(3x) dx = exp(3*x)
  • ∫ (2*x)/(x^2+1) dx = ln(x^2+1)

Scope (v0.4)

  • Only handle multiplication forms: f'(x) * g(f(x))
  • Support g(u) as:
    • sin(u), cos(u), exp(u)
    • 1/u (to produce ln(u))
  • No full general Risch algorithm, no integration by parts yet.

Approach

  • Use existing diff() + simplify() as a checker:
    Try candidates u inside factors and verify if one factor equals diff(u).
  • Extend integrate.py with a new rule before raising IntegrateError.

Acceptance Criteria

  • New tests in tests/test_integrate_subst.py (or extend test_integrate.py) pass:
    • roundtrip: simplify(diff(integrate(f))) == simplify(f)
    • for the listed examples above
  • Existing tests remain green.

Notes

  • Keep implementation conservative: better to reject unknown forms than return wrong answers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions