|
1 | 1 | # SymbolicIntegration.jl |
2 | 2 |
|
3 | | -*A unified interface for symbolic integration methods in Julia* |
| 3 | +[](https://github.com/JuliaSymbolics/SymbolicIntegration.jl/actions/workflows/CI.yml?query=branch%3Amain) |
| 4 | +[](https://github.com/JuliaSymbolics/SymbolicIntegration.jl/actions/workflows/spellcheck.yml) |
| 5 | +[](https://github.com/JuliaSymbolics/SymbolicIntegration.jl) |
4 | 6 |
|
5 | | -SymbolicIntegration.jl provides a flexible, extensible framework for symbolic integration with multiple algorithm choices. The package uses method dispatch to allow users to select the most appropriate integration algorithm for their specific needs. |
6 | 7 |
|
7 | | -## Key Features |
| 8 | +SymbolicIntegration.jl solves indefinite integrals using one of the implemented algorithms: Risch method and Rule based method |
8 | 9 |
|
9 | | -- 🎯 **Multiple Integration Methods**: Extensible method dispatch system |
10 | | -- ⚡ **Exact Symbolic Results**: Guaranteed correct symbolic integration |
11 | | -- 🔢 **Complex Root Handling**: Produces exact arctangent terms |
12 | | -- ⚙️ **Configurable Algorithms**: Method-specific options and behavior |
13 | | -- 🏗️ **Professional Interface**: SciML-style method selection |
14 | 10 |
|
15 | | -## Integration Methods |
16 | | - |
17 | | -### RischMethod (Default) |
18 | | -Complete symbolic integration using the Risch algorithm from Manuel Bronstein's "Symbolic Integration I: Transcendental Functions". |
19 | | - |
20 | | -**Capabilities:** |
21 | | -- ✅ **Rational functions**: Complete integration with Rothstein-Trager method |
22 | | -- ✅ **Transcendental functions**: Exponential, logarithmic using differential field towers |
23 | | -- ✅ **Complex roots**: Exact arctangent terms for complex polynomial roots |
24 | | -- ✅ **Integration by parts**: Logarithmic function integration |
25 | | -- ✅ **Trigonometric functions**: Via transformation to exponential form |
26 | | - |
27 | | -**Function Classes:** |
28 | | -- Polynomial functions: `∫x^n dx`, `∫(ax^2 + bx + c) dx` |
29 | | -- Rational functions: `∫P(x)/Q(x) dx` → logarithmic and arctangent terms |
30 | | -- Exponential functions: `∫exp(f(x)) dx`, `∫x*exp(x) dx` |
31 | | -- Logarithmic functions: `∫log(x) dx`, `∫1/(x*log(x)) dx` |
32 | | -- Trigonometric functions: `∫sin(x) dx`, `∫cos(x) dx`, `∫tan(x) dx` |
33 | | - |
34 | | -The framework is designed to support additional integration methods as they are developed. |
35 | | - |
36 | | - |
37 | | - |
38 | | -## Installation |
| 11 | +# Usage |
39 | 12 | ```julia |
40 | | -julia> using Pkg; Pkg.add("SymbolicIntegration") |
41 | | -``` |
| 13 | +julia> using Pkg; Pkg.add("SymbolicIntegration") # installation |
42 | 14 |
|
43 | | -## Usage |
| 15 | +julia> using SymbolicIntegration, Symbolics |
44 | 16 |
|
45 | | -### Basic Integration |
| 17 | +julia> @variables x |
| 18 | +1-element Vector{Num}: |
| 19 | + x |
46 | 20 |
|
47 | | -```julia |
48 | | -using SymbolicIntegration, Symbolics |
49 | | -@variables x |
50 | | - |
51 | | -# Default method (RischMethod) - most cases |
52 | | -integrate(x^2, x) # (1//3)*(x^3) |
53 | | -integrate(1/x, x) # log(x) |
54 | | -integrate(exp(x), x) # exp(x) |
55 | | -integrate(1/(x^2 + 1), x) # atan(x) |
| 21 | +julia> integrate(exp(2x) + 2x^2 + sin(x)) |
| 22 | +(1//2)*exp(2x) + (2//3)*(x^3) - cos(x) |
56 | 23 | ``` |
| 24 | +The first argument is the expression to integrate, second argument is the variable of integration. If the variable is not specified, it will be guessed from the expression. The +c is omitted :) |
57 | 25 |
|
58 | 26 | ### Method Selection |
59 | 27 |
|
| 28 | +You can explicitly choose a integration method like this: |
60 | 29 | ```julia |
61 | | -# Explicit method choice |
62 | | -integrate(f, x, RischMethod()) |
63 | | - |
64 | | -# Method with configuration |
65 | 30 | risch = RischMethod(use_algebraic_closure=true, catch_errors=false) |
66 | 31 | integrate(f, x, risch) |
67 | 32 | ``` |
| 33 | +or like this: |
| 34 | +```julia |
| 35 | +rbm = RuleBasedMethod(verbose=true, use_gamma=false) |
| 36 | +integrate(f, x, rbm) |
| 37 | +``` |
| 38 | + |
| 39 | +If no method is specified, first RischMethod will be tried, then RuleBasedMethod: |
| 40 | +```julia |
| 41 | +julia> integrate(sqrt(x)) |
| 42 | +┌ Warning: NotImplementedError: integrand contains unsupported expression sqrt(x) |
| 43 | +└ @ SymbolicIntegration ~/.julia/dev/SymbolicIntegration.jl_official/src/methods/risch/frontend.jl:826 |
68 | 44 |
|
69 | | -### Complex Examples |
| 45 | + > RischMethod failed returning ∫(sqrt(x), x) |
| 46 | + > Trying with RuleBasedMethod... |
70 | 47 |
|
| 48 | +(2//3)*(x^(3//2)) |
| 49 | +``` |
71 | 50 | ```julia |
72 | | -# Rational function with complex roots |
73 | | -f = (x^3 + x^2 + x + 2)/(x^4 + 3*x^2 + 2) |
74 | | -integrate(f, x) # (1//2)*log(2 + x^2) + atan(x) |
| 51 | +julia> integrate(abs(x)) |
| 52 | +┌ Warning: NotImplementedError: integrand contains unsupported expression abs(x) |
| 53 | +└ @ SymbolicIntegration ~/.julia/dev/SymbolicIntegration.jl_official/src/methods/risch/frontend.jl:826 |
| 54 | + |
| 55 | + > RischMethod failed returning ∫(abs(x), x) |
| 56 | + > Trying with RuleBasedMethod... |
75 | 57 |
|
76 | | -# Integration by parts |
77 | | -integrate(log(x), x) # -x + x*log(x) |
| 58 | +No rule found for ∫(abs(x), x) |
| 59 | + |
| 60 | + > RuleBasedMethod failed returning ∫(abs(x), x) |
| 61 | + > Sorry we cannot integrate this expression :( |
78 | 62 |
|
79 | | -# Nested transcendental functions |
80 | | -integrate(1/(x*log(x)), x) # log(log(x)) |
81 | 63 | ``` |
82 | 64 |
|
83 | | -## Method Framework |
84 | 65 |
|
85 | | -SymbolicIntegration.jl uses a modern method dispatch system similar to other SciML packages: |
| 66 | +# Integration Methods |
| 67 | +Currently two algorithms are implemented: **Risch algorithm** and **Rule based integration**. |
86 | 68 |
|
87 | | -### Current Methods |
88 | | -- **RischMethod**: Complete symbolic integration (default) |
| 69 | +feature | Risch | Rule based |
| 70 | +--------|-------|----------- |
| 71 | +rational functions | ✅ | ✅ |
| 72 | +non integers powers | ❌ | ✅ |
| 73 | +exponential functions | ✅ | ✅ |
| 74 | +logarithms | ✅ | ✅ |
| 75 | +trigonometric functions | ? | sometimes |
| 76 | +hyperbolic functions | ✅ | sometimes |
| 77 | +Nonelementary integrals | ❌ | most of them |
| 78 | +Special functions | ❌ | ❌ |
| 79 | +more than one symbolic<br> variable in the expression | ❌ | ✅ |
89 | 80 |
|
90 | | -### Method Configuration |
91 | | -```julia |
92 | | -# Research configuration (strict, complete) |
93 | | -RischMethod(use_algebraic_closure=true, catch_errors=false) |
| 81 | +More info about them in the [methods documentation](methods/overview.md) |
94 | 82 |
|
95 | | -# Production configuration (robust, graceful) |
96 | | -RischMethod(use_algebraic_closure=true, catch_errors=true) |
| 83 | +### Risch Method |
| 84 | +Complete symbolic integration using the Risch algorithm from Manuel Bronstein's "Symbolic Integration I: Transcendental Functions". |
97 | 85 |
|
98 | | -# Performance configuration (faster, simpler) |
99 | | -RischMethod(use_algebraic_closure=false, catch_errors=true) |
100 | | -``` |
| 86 | +### RuleBasedMethod |
101 | 87 |
|
102 | | -### Extensibility |
103 | | -The framework is designed for easy extension with additional integration methods. The abstract type `AbstractIntegrationMethod` provides the foundation for implementing new algorithms. |
| 88 | +This method uses a large number of integration rules that specify how to integrate various mathematical expressions. There are now more than 3400 rules impelmented. |
104 | 89 |
|
105 | | -## Documentation |
| 90 | +# Documentation |
106 | 91 |
|
107 | 92 | Complete documentation with method selection guidance, algorithm details, and examples is available at: |
108 | 93 | **[https://symbolicintegration.juliasymbolics.org](https://symbolicintegration.juliasymbolics.org)** |
109 | 94 |
|
110 | | -## Citation |
| 95 | +
|
| 96 | +# Citation |
111 | 97 |
|
112 | 98 | If you use SymbolicIntegration.jl in your research, please cite: |
113 | 99 |
|
114 | 100 | ```bibtex |
115 | 101 | @software{SymbolicIntegration.jl, |
116 | | - author = {Harald Hofstätter and contributors}, |
| 102 | + author = {Harald Hofstätter and Mattia Micheletta Merlin and Chris Rackauckas}, |
117 | 103 | title = {SymbolicIntegration.jl: Symbolic Integration for Julia}, |
118 | 104 | url = {https://github.com/JuliaSymbolics/SymbolicIntegration.jl}, |
119 | 105 | year = {2023-2025} |
|
0 commit comments