Skip to content

Commit 5df1ad6

Browse files
Merge pull request #3 from ChrisRackauckas-Claude/migrate-to-symbolics
Add Symbolics.jl support with dual API compatibility
2 parents a4d793c + 438f7e4 commit 5df1ad6

18 files changed

+62
-545
lines changed

Manifest.toml

Lines changed: 0 additions & 499 deletions
This file was deleted.

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ keywords = ["symbolic", "integration", "mathematics", "computer-algebra"]
1111
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
1212
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1313
Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
14-
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
14+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1515

1616
[compat]
1717
AbstractAlgebra = "0.46"
1818
Nemo = "0.51"
19-
SymbolicUtils = "3"
19+
Symbolics = "6"
2020
julia = "1.10"
2121

2222
[extras]

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SymbolicIntegration.jl
22
This package provides Julia implementations of symbolic integration algorithms.
33

4-
The front-end (i.e., the user interface) requires [SymbolicUtils.jl](https://symbolicutils.juliasymbolics.org/).
4+
The front-end (i.e., the user interface) requires [Symbolics.jl](https://docs.sciml.ai/Symbolics/stable/).
55
The actual integration algorithms are implemented in a generic way using [AbstractAlgebra.jl](https://nemocas.github.io/AbstractAlgebra.jl/dev/).
66
Some algorithms require [Nemo.jl](https://nemocas.github.io/Nemo.jl/dev/) for calculations with algebraic numbers.
77

@@ -26,12 +26,12 @@ julia> using Pkg; Pkg.add("SymbolicIntegration")
2626

2727
## Usage
2828
```julia
29-
julia> using SymbolicIntegration, SymbolicUtils
29+
julia> using SymbolicIntegration, Symbolics
3030

31-
julia> @syms x
31+
julia> @variables x
3232
(x,)
3333

34-
julia> f = (x^3 + x^2 + x + 2)//(x^4 + 3*x^2 + 2)
34+
julia> f = (x^3 + x^2 + x + 2)/(x^4 + 3*x^2 + 2)
3535
(2 + x + x^2 + x^3) / (2 + x^4 + 3(x^2))
3636

3737
julia> integrate(f, x)
@@ -43,11 +43,8 @@ julia> f = 1/(x*log(x))
4343
julia> integrate(f, x)
4444
log(log(x))
4545

46-
julia> f = 1/(1+2*cos(x))
47-
1 / (1 + 2cos(x))
48-
49-
julia> g = integrate(f, x)
50-
log(-4 - sqrt(16//3)*tan((1//2)*x))*sqrt(1//3) - log(sqrt(16//3)*tan((1//2)*x) - 4)*sqrt(1//3)
46+
julia> integrate(1/(x^2 + 1), x) # Complex root integration
47+
atan(x)
5148
```
5249

5350
## Tests

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
34
SymbolicIntegration = "315ce56f-eed0-411d-ab8a-2fbdf9327b51"
4-
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
55

66
[compat]
77
Documenter = "1"

docs/src/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CurrentModule = SymbolicIntegration
66

77
SymbolicIntegration.jl provides Julia implementations of symbolic integration algorithms.
88

9-
The front-end (i.e., the user interface) requires [SymbolicUtils.jl](https://symbolicutils.juliasymbolics.org/).
9+
The front-end (i.e., the user interface) uses [Symbolics.jl](https://docs.sciml.ai/Symbolics/stable/).
1010
The actual integration algorithms are implemented in a generic way using [AbstractAlgebra.jl](https://nemocas.github.io/AbstractAlgebra.jl/dev/).
1111
Some algorithms require [Nemo.jl](https://nemocas.github.io/Nemo.jl/dev/) for calculations with algebraic numbers.
1212

@@ -35,27 +35,32 @@ julia> using Pkg; Pkg.add("SymbolicIntegration")
3535
## Quick Start
3636

3737
```julia
38-
using SymbolicIntegration, SymbolicUtils
38+
# Using Symbolics.jl (recommended)
39+
using SymbolicIntegration, Symbolics
3940

40-
@syms x
41+
@variables x
4142

4243
# Basic polynomial integration
4344
integrate(x^2, x) # Returns (1//3)*(x^3)
4445

4546
# Rational function integration
46-
f = (x^3 + x^2 + x + 2)//(x^4 + 3*x^2 + 2)
47+
f = (x^3 + x^2 + x + 2)/(x^4 + 3*x^2 + 2)
4748
integrate(f, x) # Returns (1//2)*log(2 + x^2) + atan(x)
4849

4950
# Transcendental functions
5051
integrate(exp(x), x) # Returns exp(x)
5152
integrate(log(x), x) # Returns -x + x*log(x)
5253
integrate(1/x, x) # Returns log(x)
5354

55+
# Complex root integration (arctangent cases)
56+
integrate(1/(x^2 + 1), x) # Returns atan(x)
57+
5458
# More complex examples
5559
f = 1/(x*log(x))
5660
integrate(f, x) # Returns log(log(x))
5761
```
5862

63+
5964
## Algorithm Coverage
6065

6166
This package implements the complete suite of algorithms from Bronstein's book:

docs/src/manual/basic_usage.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
## Creating Symbolic Variables
44

5-
Before integrating, you need to create symbolic variables using SymbolicUtils.jl:
5+
Before integrating, you need to create symbolic variables using Symbolics.jl:
66

77
```julia
8-
using SymbolicIntegration, SymbolicUtils
8+
using SymbolicIntegration, Symbolics
99

10-
@syms x y z
10+
@variables x y z
1111
```
1212

1313
## The `integrate` Function
@@ -62,6 +62,9 @@ integrate(tan(x), x) # -log(cos(x))
6262
SymbolicIntegration.jl will throw appropriate errors for unsupported cases:
6363

6464
```julia
65+
using SymbolicIntegration, Symbolics
66+
@variables x
67+
6568
# This will throw NotImplementedError for algebraic functions
6669
integrate(sqrt(x), x) # Error: algebraic functions not supported
6770

docs/src/manual/getting_started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ pkg> add SymbolicIntegration
1717

1818
## Basic Usage
1919

20-
After installation, load the package along with SymbolicUtils.jl for symbolic variable creation:
20+
After installation, load the package along with Symbolics.jl for symbolic variable creation:
2121

2222
```julia
23-
using SymbolicIntegration, SymbolicUtils
23+
using SymbolicIntegration, Symbolics
2424

2525
# Create symbolic variables
26-
@syms x
26+
@variables x
2727

2828
# Integrate a simple polynomial
2929
integrate(x^2, x) # Returns (1//3)*(x^3)
@@ -33,7 +33,7 @@ integrate(x^2, x) # Returns (1//3)*(x^3)
3333

3434
SymbolicIntegration.jl builds on several key packages in the Julia ecosystem:
3535

36-
- **[SymbolicUtils.jl](https://symbolicutils.juliasymbolics.org/)**: Provides the symbolic expression system and user interface
36+
- **[Symbolics.jl](https://docs.sciml.ai/Symbolics/stable/)**: Provides the symbolic expression system and user interface
3737
- **[AbstractAlgebra.jl](https://nemocas.github.io/AbstractAlgebra.jl/dev/)**: Generic computer algebra algorithms
3838
- **[Nemo.jl](https://nemocas.github.io/Nemo.jl/dev/)**: Fast calculations with algebraic numbers
3939

docs/src/manual/rational_functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ The integration algorithm consists of three main steps:
2020
### Simple Rational Functions
2121

2222
```julia
23-
using SymbolicIntegration, SymbolicUtils
24-
@syms x
23+
using SymbolicIntegration, Symbolics
24+
@variables x
2525

2626
# Linear over linear
2727
integrate((2*x + 3)/(x + 1), x) # 2*x + log(1 + x)

docs/src/manual/transcendental_functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ SymbolicIntegration.jl implements the Risch algorithm for integrating elementary
77
### Exponential Functions
88

99
```julia
10-
using SymbolicIntegration, SymbolicUtils
11-
@syms x
10+
using SymbolicIntegration, Symbolics
11+
@variables x
1212

1313
integrate(exp(x), x) # exp(x)
1414
integrate(exp(2*x), x) # (1//2)*exp(2*x)

src/frontend.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
using SymbolicUtils
1+
using Symbolics
22
using Logging
33

4+
# Access SymbolicUtils through Symbolics
5+
const SymbolicUtils = Symbolics.SymbolicUtils
6+
47
export integrate
58

69
"""
@@ -728,7 +731,15 @@ function TowerOfDifferentialFields(terms::Vector{Term}) where
728731
end
729732

730733

731-
@syms (f, x)
734+
Symbolics.@syms (f, x)
735+
736+
# Main integration interface for Symbolics.jl
737+
function integrate(f::Symbolics.Num, x::Symbolics.Num; kwargs...)
738+
# Extract SymbolicUtils expressions from Symbolics.Num wrappers
739+
result_symbolic = integrate(f.val, x.val; kwargs...)
740+
# Wrap result back in Symbolics.Num
741+
return Symbolics.Num(result_symbolic)
742+
end
732743

733744
struct AlgebraicNumbersInvolved <: Exception end
734745

0 commit comments

Comments
 (0)