Skip to content

Commit 5ad8a6d

Browse files
Add getting started tutorial and fix documentation structure
- Add docs/src/manual/getting_started.md: Comprehensive getting started guide covering: * Installation and basic setup * First integration examples with polynomials, rationals, and transcendentals * Method selection guide (RischMethod vs RuleBasedMethod) * Error handling and verification techniques * Common integration patterns and troubleshooting - Update docs/make.jl to reference only existing documentation files: * Remove references to missing basic_usage.md, rational_functions.md, transcendental_functions.md * Add existing method documentation files (rulebased.md, risch_rational_functions.md, risch_transcendental_functions.md) * Include contributing.md in manual section This provides users with a complete getting started experience including method selection guidance. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5dcdcde commit 5ad8a6d

File tree

2 files changed

+241
-5
lines changed

2 files changed

+241
-5
lines changed

docs/make.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ makedocs(
1616
"Home" => "index.md",
1717
"Manual" => [
1818
"manual/getting_started.md",
19-
"manual/basic_usage.md",
19+
"manual/contributing.md",
2020
],
2121
"Integration Methods" => [
2222
"methods/overview.md",
2323
"methods/risch.md",
24-
],
25-
"Algorithm Details" => [
26-
"manual/rational_functions.md",
27-
"manual/transcendental_functions.md",
24+
"methods/rulebased.md",
25+
"methods/risch_rational_functions.md",
26+
"methods/risch_transcendental_functions.md",
2827
],
2928
"API Reference" => "api.md",
3029
],

docs/src/manual/getting_started.md

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Getting Started
2+
3+
This tutorial will help you get started with SymbolicIntegration.jl, covering installation, basic usage, and method selection.
4+
5+
## Installation
6+
7+
Install SymbolicIntegration.jl from the Julia package registry:
8+
9+
```julia
10+
using Pkg
11+
Pkg.add("SymbolicIntegration")
12+
```
13+
14+
## Basic Setup
15+
16+
To start using the package, import both SymbolicIntegration.jl and Symbolics.jl:
17+
18+
```julia
19+
using SymbolicIntegration, Symbolics
20+
21+
# Define symbolic variables
22+
@variables x a b
23+
```
24+
25+
## Your First Integration
26+
27+
Let's start with some basic examples:
28+
29+
```julia
30+
# Basic polynomial
31+
integrate(x^2, x)
32+
# Returns: (1//3)*(x^3)
33+
34+
# Rational function
35+
integrate(1/(x^2 + 1), x)
36+
# Returns: atan(x)
37+
38+
# More complex rational function
39+
f = (x^3 + x^2 + x + 2)/(x^4 + 3*x^2 + 2)
40+
integrate(f, x)
41+
# Returns: (1//2)*log(2 + x^2) + atan(x)
42+
```
43+
44+
## Transcendental Functions
45+
46+
SymbolicIntegration.jl handles exponential, logarithmic, and trigonometric functions:
47+
48+
```julia
49+
# Exponential functions
50+
integrate(exp(x), x) # Returns: exp(x)
51+
integrate(x * exp(x), x) # Returns: -exp(x) + x*exp(x)
52+
53+
# Logarithmic functions
54+
integrate(log(x), x) # Returns: -x + x*log(x)
55+
integrate(1/(x*log(x)), x) # Returns: log(log(x))
56+
57+
# Trigonometric functions
58+
integrate(sin(x), x) # Returns: -cos(x)
59+
integrate(cos(x), x) # Returns: sin(x)
60+
```
61+
62+
## Method Selection
63+
64+
SymbolicIntegration.jl provides two main integration methods that you can select explicitly:
65+
66+
### Automatic Method Selection (Default)
67+
68+
By default, the package automatically chooses the best method:
69+
70+
```julia
71+
f = (x^2 + 1)/(x^3 + x)
72+
integrate(f, x) # Automatically selects the best method
73+
```
74+
75+
### RischMethod
76+
77+
The Risch algorithm is based on Bronstein's "Symbolic Integration I" and provides exact algorithmic integration:
78+
79+
```julia
80+
# Basic usage
81+
integrate(f, x, RischMethod())
82+
83+
# With algebraic closure (for complex roots)
84+
integrate(f, x, RischMethod(use_algebraic_closure=true))
85+
86+
# With error catching
87+
integrate(f, x, RischMethod(catch_errors=true))
88+
```
89+
90+
**RischMethod is best for:**
91+
- Rational functions
92+
- Simple exponential and logarithmic functions
93+
- Cases requiring exact symbolic computation
94+
- When you need guaranteed elementary solutions
95+
96+
### RuleBasedMethod
97+
98+
The rule-based method uses pattern matching with a large database of integration rules:
99+
100+
```julia
101+
# Basic usage
102+
integrate(f, x, RuleBasedMethod())
103+
104+
# Verbose output (shows integration rules applied)
105+
integrate(f, x, RuleBasedMethod(verbose=true))
106+
107+
# Allow gamma functions in results
108+
integrate(f, x, RuleBasedMethod(use_gamma=true))
109+
```
110+
111+
**RuleBasedMethod is best for:**
112+
- Complex trigonometric expressions
113+
- Functions involving special cases
114+
- When you need to see the integration process
115+
- Broader coverage of function types
116+
117+
### Method Comparison Example
118+
119+
```julia
120+
# Compare methods on the same function
121+
f = sin(x)^2 * cos(x)
122+
123+
# Risch method
124+
result_risch = integrate(f, x, RischMethod())
125+
126+
# Rule-based method
127+
result_rules = integrate(f, x, RuleBasedMethod(verbose=false))
128+
129+
println("Risch result: ", result_risch)
130+
println("Rule-based result: ", result_rules)
131+
```
132+
133+
## Error Handling
134+
135+
Sometimes integration may fail or return unevaluated expressions:
136+
137+
```julia
138+
# This integral has no elementary solution
139+
difficult_f = exp(x^2)
140+
141+
try
142+
result = integrate(difficult_f, x)
143+
println("Result: ", result)
144+
catch e
145+
println("Integration failed: ", e)
146+
end
147+
148+
# Use error catching options
149+
safe_result = integrate(difficult_f, x, RischMethod(catch_errors=true))
150+
```
151+
152+
## Verification
153+
154+
You can verify integration results by differentiation:
155+
156+
```julia
157+
using Symbolics: Differential
158+
159+
# Original function
160+
f = x^3 + 2*x^2 + x + 1
161+
162+
# Integrate
163+
F = integrate(f, x)
164+
165+
# Differentiate to verify
166+
D = Differential(x)
167+
f_check = expand_derivatives(D(F))
168+
169+
# Check if they match
170+
simplify(f - f_check) == 0 # Should be true
171+
```
172+
173+
## Method Selection Guidelines
174+
175+
Choose your integration method based on the function type:
176+
177+
| Function Type | Recommended Method | Example |
178+
|---------------|-------------------|---------|
179+
| Rational functions | `RischMethod()` | `(x^2+1)/(x^3+x)` |
180+
| Simple exponentials | `RischMethod()` | `x*exp(x)` |
181+
| Simple logarithms | `RischMethod()` | `log(x)/x` |
182+
| Complex trigonometric | `RuleBasedMethod()` | `sin(x)^3*cos(x)^2` |
183+
| Mixed transcendental | Try both methods | `exp(x)*sin(x)` |
184+
185+
## Common Patterns
186+
187+
### Integration by Parts (Automatic)
188+
```julia
189+
# The algorithms handle integration by parts automatically
190+
integrate(x * exp(x), x) # Returns: -exp(x) + x*exp(x)
191+
integrate(x * log(x), x) # Uses integration by parts internally
192+
```
193+
194+
### Substitution (Automatic)
195+
```julia
196+
# Chain rule substitutions are handled automatically
197+
integrate(sin(x^2) * x, x) # Uses u = x^2 substitution
198+
integrate(exp(x^2) * x, x) # Returns: (1//2)*exp(x^2)
199+
```
200+
201+
### Partial Fractions (Automatic)
202+
```julia
203+
# Rational functions use partial fraction decomposition
204+
integrate((x^2 + 1)/((x-1)*(x+1)), x) # Automatically decomposes
205+
```
206+
207+
## Next Steps
208+
209+
Now that you understand the basics:
210+
211+
1. Explore the [Integration Methods](../methods/overview.md) documentation for detailed algorithm explanations
212+
2. Check the [API Reference](../api.md) for complete function documentation
213+
3. See the [Risch Algorithm](../methods/risch.md) details for advanced usage
214+
215+
## Common Issues
216+
217+
**Issue**: Integration takes too long
218+
**Solution**: Try simplifying the expression first or switch methods:
219+
```julia
220+
f_simplified = simplify(f)
221+
result = integrate(f_simplified, x)
222+
# Or try the other method
223+
result = integrate(f, x, RuleBasedMethod())
224+
```
225+
226+
**Issue**: Method fails with error
227+
**Solution**: Try the alternative method or enable error catching:
228+
```julia
229+
result = integrate(f, x, RischMethod(catch_errors=true))
230+
```
231+
232+
**Issue**: Unexpected result form
233+
**Solution**: Simplify the result:
234+
```julia
235+
result = integrate(f, x)
236+
simplified_result = simplify(result)
237+
```

0 commit comments

Comments
 (0)