Skip to content

Commit c0e52ce

Browse files
Merge pull request #7 from ChrisRackauckas-Claude/reorganize-docs-methods
Reorganize documentation to present Risch as one method choice
2 parents 8649adf + 6b234f1 commit c0e52ce

File tree

6 files changed

+326
-9
lines changed

6 files changed

+326
-9
lines changed

docs/make.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ makedocs(
1717
"Manual" => [
1818
"manual/getting_started.md",
1919
"manual/basic_usage.md",
20+
],
21+
"Integration Methods" => [
22+
"methods/overview.md",
23+
"methods/risch.md",
24+
],
25+
"Algorithm Details" => [
2026
"manual/rational_functions.md",
2127
"manual/transcendental_functions.md",
2228
],

docs/src/api.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ CurrentModule = SymbolicIntegration
1010
integrate
1111
```
1212

13+
## Integration Methods
14+
15+
### Available Methods
16+
17+
```@docs
18+
RischMethod
19+
```
20+
21+
### Method Traits
22+
23+
```@docs
24+
method_supports_rational
25+
method_supports_transcendental
26+
```
27+
1328
## Algorithm Overview
1429

1530
SymbolicIntegration.jl implements the complete symbolic integration algorithms from Manuel Bronstein's book "Symbolic Integration I: Transcendental Functions".

docs/src/index.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,60 @@ julia> using Pkg; Pkg.add("SymbolicIntegration")
3535
## Quick Start
3636

3737
```julia
38-
# Using Symbolics.jl (recommended)
3938
using SymbolicIntegration, Symbolics
4039

4140
@variables x
4241

43-
# Basic polynomial integration
42+
# Basic polynomial integration (uses default RischMethod)
4443
integrate(x^2, x) # Returns (1//3)*(x^3)
4544

46-
# Rational function integration
45+
# Rational function integration with complex roots
4746
f = (x^3 + x^2 + x + 2)/(x^4 + 3*x^2 + 2)
4847
integrate(f, x) # Returns (1//2)*log(2 + x^2) + atan(x)
4948

5049
# Transcendental functions
5150
integrate(exp(x), x) # Returns exp(x)
5251
integrate(log(x), x) # Returns -x + x*log(x)
53-
integrate(1/x, x) # Returns log(x)
5452

5553
# Complex root integration (arctangent cases)
5654
integrate(1/(x^2 + 1), x) # Returns atan(x)
5755

58-
# More complex examples
59-
f = 1/(x*log(x))
60-
integrate(f, x) # Returns log(log(x))
56+
# Method selection and configuration
57+
integrate(f, x, RischMethod()) # Explicit method choice
58+
integrate(f, x, RischMethod(use_algebraic_closure=true)) # With options
6159
```
6260

6361

62+
## Integration Methods
63+
64+
SymbolicIntegration.jl provides multiple integration algorithms through a flexible method dispatch system:
65+
66+
### RischMethod (Default)
67+
The complete Risch algorithm for elementary function integration:
68+
- **Exact results**: Guaranteed correct symbolic integration
69+
- **Complex roots**: Produces exact arctangent terms
70+
- **Complete coverage**: Rational and transcendental functions
71+
- **Configurable**: Options for performance vs completeness
72+
73+
```julia
74+
# Default method
75+
integrate(f, x)
76+
77+
# Explicit method with options
78+
integrate(f, x, RischMethod(use_algebraic_closure=true))
79+
```
80+
81+
### Future Methods
82+
The framework supports additional integration algorithms:
83+
- **HeuristicMethod**: Fast pattern-matching integration
84+
- **NumericalMethod**: Numerical integration fallbacks
85+
- **SymPyMethod**: SymPy backend compatibility
86+
87+
[→ See complete methods documentation](methods/overview.md)
88+
6489
## Algorithm Coverage
6590

66-
This package implements the complete suite of algorithms from Bronstein's book:
91+
The **RischMethod** implements the complete suite of algorithms from Bronstein's book:
6792

6893
- **Rational Function Integration** (Chapter 2)
6994
- Hermite reduction

docs/src/manual/basic_usage.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ using SymbolicIntegration, Symbolics
1212

1313
## The `integrate` Function
1414

15-
The main function for symbolic integration is `integrate(expr, var)`:
15+
The main function for symbolic integration uses method dispatch to choose algorithms:
16+
17+
```julia
18+
# Default method (RischMethod)
19+
integrate(expr, var)
20+
21+
# Explicit method selection
22+
integrate(expr, var, method)
23+
```
1624

1725
```julia
1826
# Basic polynomial integration
@@ -57,6 +65,38 @@ integrate(cos(x), x) # sin(x)
5765
integrate(tan(x), x) # -log(cos(x))
5866
```
5967

68+
## Method Selection
69+
70+
SymbolicIntegration.jl supports multiple integration methods through method dispatch:
71+
72+
### Default Method (RischMethod)
73+
```julia
74+
# These are equivalent
75+
integrate(f, x)
76+
integrate(f, x, RischMethod())
77+
```
78+
79+
### Method Configuration
80+
```julia
81+
# Configure method behavior
82+
risch_exact = RischMethod(use_algebraic_closure=true, catch_errors=false)
83+
integrate(1/(x^2 + 1), x, risch_exact) # atan(x) with strict error handling
84+
85+
risch_robust = RischMethod(use_algebraic_closure=true, catch_errors=true)
86+
integrate(difficult_function, x, risch_robust) # Graceful error handling
87+
```
88+
89+
### Method Comparison
90+
```julia
91+
# For exact results with full complex root handling
92+
integrate(f, x, RischMethod(use_algebraic_closure=true))
93+
94+
# For faster computation (may miss some arctangent terms)
95+
integrate(f, x, RischMethod(use_algebraic_closure=false))
96+
```
97+
98+
See the [Integration Methods](../methods/overview.md) section for complete details on available methods and their capabilities.
99+
60100
## Error Handling
61101

62102
SymbolicIntegration.jl will throw appropriate errors for unsupported cases:

docs/src/methods/overview.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Integration Methods Overview
2+
3+
SymbolicIntegration.jl uses a flexible method dispatch system that allows you to choose different integration algorithms based on your needs.
4+
5+
## Available Methods
6+
7+
### RischMethod (Default)
8+
9+
The **Risch method** is the complete algorithm for symbolic integration of elementary functions, based on Manuel Bronstein's algorithms.
10+
11+
```julia
12+
# Default usage
13+
integrate(f, x) # Automatically uses RischMethod
14+
15+
# Explicit usage
16+
integrate(f, x, RischMethod())
17+
18+
# With configuration
19+
integrate(f, x, RischMethod(use_algebraic_closure=true, catch_errors=false))
20+
```
21+
22+
**Capabilities:**
23+
- ✅ Rational functions with exact arctangent terms
24+
- ✅ Exponential and logarithmic functions
25+
- ✅ Trigonometric functions (via transformation)
26+
- ✅ Complex root handling
27+
- ✅ Integration by parts
28+
29+
**Best for:** Complete symbolic integration with guaranteed correctness
30+
31+
[→ See detailed Risch documentation](risch.md)

docs/src/methods/risch.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Risch Method
2+
3+
The Risch method is a complete algorithm for symbolic integration of elementary functions. It implements the algorithms from Manuel Bronstein's "Symbolic Integration I: Transcendental Functions".
4+
5+
## Overview
6+
7+
The Risch method is currently the primary integration method in SymbolicIntegration.jl. It provides exact symbolic integration for:
8+
9+
- **Rational functions**: Using the Rothstein-Trager method
10+
- **Exponential functions**: Using differential field towers
11+
- **Logarithmic functions**: Integration by parts and substitution
12+
- **Trigonometric functions**: Transformation to exponential form
13+
- **Complex root handling**: Exact arctangent terms
14+
15+
## Usage
16+
17+
```julia
18+
using SymbolicIntegration, Symbolics
19+
@variables x
20+
21+
# Default method (uses RischMethod automatically)
22+
integrate(x^2, x) # (1//3)*(x^3)
23+
24+
# Explicit Risch method
25+
integrate(1/(x^2 + 1), x, RischMethod()) # atan(x)
26+
27+
# Risch method with options
28+
risch = RischMethod(use_algebraic_closure=true, catch_errors=false)
29+
integrate(f, x, risch)
30+
```
31+
32+
## Configuration Options
33+
34+
### Constructor
35+
```julia
36+
RischMethod(; use_algebraic_closure=true, catch_errors=true)
37+
```
38+
39+
### Options
40+
41+
#### `use_algebraic_closure::Bool` (default: `true`)
42+
Controls whether the algorithm uses algebraic closure for finding complex roots.
43+
44+
- **`true`**: Finds complex roots, produces exact arctangent terms
45+
- **`false`**: Only rational roots, faster for simple cases
46+
47+
```julia
48+
# With complex roots (produces atan terms)
49+
integrate(1/(x^2 + 1), x, RischMethod(use_algebraic_closure=true)) # atan(x)
50+
51+
# Without complex roots (may miss arctangent terms)
52+
integrate(1/(x^2 + 1), x, RischMethod(use_algebraic_closure=false)) # May return 0
53+
```
54+
55+
#### `catch_errors::Bool` (default: `true`)
56+
Controls error handling behavior.
57+
58+
- **`true`**: Returns unevaluated integrals for unsupported cases
59+
- **`false`**: Throws exceptions for algorithmic failures
60+
61+
```julia
62+
# Graceful error handling
63+
integrate(unsupported_function, x, RischMethod(catch_errors=true)) # Returns ∫(f, x)
64+
65+
# Strict error handling
66+
integrate(unsupported_function, x, RischMethod(catch_errors=false)) # Throws exception
67+
```
68+
69+
## Algorithm Components
70+
71+
The Risch method implementation includes:
72+
73+
### Rational Function Integration (Chapter 2)
74+
- **Hermite reduction**: Simplifies rational functions
75+
- **Rothstein-Trager method**: Finds logarithmic parts
76+
- **Partial fraction decomposition**: Handles complex denominators
77+
- **Complex root finding**: Produces arctangent terms
78+
79+
### Transcendental Function Integration (Chapters 5-6)
80+
- **Differential field towers**: Handles nested transcendental functions
81+
- **Risch algorithm**: Complete method for elementary functions
82+
- **Primitive cases**: Direct integration
83+
- **Hyperexponential cases**: Exponential function handling
84+
85+
### Supporting Algorithms
86+
- **Expression analysis**: Converts symbolic expressions to algebraic form
87+
- **Field extensions**: Builds differential field towers
88+
- **Root finding**: Complex and rational root computation
89+
- **Result conversion**: Transforms back to symbolic form
90+
91+
## Function Classes Supported
92+
93+
### Polynomial Functions
94+
```julia
95+
integrate(x^n, x) # x^(n+1)/(n+1)
96+
integrate(3*x^2 + 2*x + 1, x) # x^3 + x^2 + x
97+
```
98+
99+
### Rational Functions
100+
```julia
101+
integrate(1/x, x) # log(x)
102+
integrate(1/(x^2 + 1), x) # atan(x)
103+
integrate((x+1)/(x+2), x) # x - log(2 + x)
104+
```
105+
106+
### Exponential Functions
107+
```julia
108+
integrate(exp(x), x) # exp(x)
109+
integrate(x*exp(x), x) # -exp(x) + x*exp(x)
110+
integrate(exp(x^2)*x, x) # (1/2)*exp(x^2)
111+
```
112+
113+
### Logarithmic Functions
114+
```julia
115+
integrate(log(x), x) # -x + x*log(x)
116+
integrate(1/(x*log(x)), x) # log(log(x))
117+
integrate(log(x)^2, x) # x*log(x)^2 - 2*x*log(x) + 2*x
118+
```
119+
120+
### Trigonometric Functions
121+
```julia
122+
integrate(sin(x), x) # Transformed to exponential form
123+
integrate(cos(x), x) # Transformed to exponential form
124+
integrate(tan(x), x) # Uses differential field extension
125+
```
126+
127+
## Limitations
128+
129+
The Risch method, following Bronstein's book, does not handle:
130+
131+
- **Algebraic functions**: `√x`, `x^(1/3)`, etc.
132+
- **Non-elementary functions**: Functions without elementary antiderivatives
133+
- **Special functions**: Bessel functions, hypergeometric functions, etc.
134+
135+
For these cases, the algorithm will:
136+
- Return unevaluated integrals if `catch_errors=true`
137+
- Throw appropriate exceptions if `catch_errors=false`
138+
139+
## Performance Considerations
140+
141+
### When to Use Different Options
142+
143+
- **Research/verification**: `catch_errors=false` for strict algorithmic behavior
144+
- **Production applications**: `catch_errors=true` for robust operation
145+
- **Complex analysis**: `use_algebraic_closure=true` for complete results
146+
- **Simple computations**: `use_algebraic_closure=false` for faster execution
147+
148+
### Complexity
149+
- **Polynomial functions**: O(n) where n is degree
150+
- **Rational functions**: Depends on degree and factorization complexity
151+
- **Transcendental functions**: Exponential in tower height
152+
153+
## Examples
154+
155+
### Basic Usage
156+
```julia
157+
@variables x
158+
159+
# Simple cases
160+
integrate(x^3, x, RischMethod()) # (1//4)*(x^4)
161+
integrate(1/x, x, RischMethod()) # log(x)
162+
integrate(exp(x), x, RischMethod()) # exp(x)
163+
```
164+
165+
### Advanced Cases
166+
```julia
167+
# Complex rational function with arctangent
168+
f = (3*x - 4*x^2 + 3*x^3)/(1 + x^2)
169+
integrate(f, x, RischMethod()) # -4x + 4atan(x) + (3//2)*(x^2)
170+
171+
# Integration by parts
172+
integrate(log(x), x, RischMethod()) # -x + x*log(x)
173+
174+
# Nested transcendental functions
175+
integrate(1/(x*log(x)), x, RischMethod()) # log(log(x))
176+
```
177+
178+
### Method Configuration
179+
```julia
180+
# For research (strict error handling)
181+
research_risch = RischMethod(use_algebraic_closure=true, catch_errors=false)
182+
183+
# For production (graceful error handling)
184+
production_risch = RischMethod(use_algebraic_closure=true, catch_errors=true)
185+
186+
# For simple cases (faster computation)
187+
simple_risch = RischMethod(use_algebraic_closure=false, catch_errors=true)
188+
```
189+
190+
## Algorithm References
191+
192+
The implementation follows:
193+
194+
- **Manuel Bronstein**: "Symbolic Integration I: Transcendental Functions", 2nd ed., Springer 2005
195+
- **Chapter 1**: General algorithms (polynomial operations, resultants)
196+
- **Chapter 2**: Rational function integration
197+
- **Chapters 5-6**: Transcendental function integration (Risch algorithm)
198+
- **Additional chapters**: Parametric problems, coupled systems
199+
200+
This provides a complete, reference implementation of the Risch algorithm for elementary function integration.

0 commit comments

Comments
 (0)