You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method uses a rule based approach to integrate a vast class of functions, and it's built using the rules from the Mathematica package [RUBI](https://rulebasedintegration.org/).
133
103
134
104
**Capabilities:**
135
-
- ✅ TODO add others
105
+
- ✅ Fast convergence for a large base of recognized cases
106
+
- ✅ Algebraic functions like `sqrt` and non-integer powers are supported
136
107
- ✅ **More than one symbolic variable**: Integration w.r.t. one variable, with other symbolic variables present in the expression
137
108
138
-
### How it works internally
139
-
The rules are defined using the SymbolicUtils [rule macro](https://symbolicutils.juliasymbolics.org/rewrite/#rule-based_rewriting) and are of this form:
140
-
```julia
141
-
# rule 1_1_1_1_2
142
-
@rule∫((~x)^(~!m),(~x)) =>
143
-
!contains_var((~m), (~x)) &&
144
-
!eq((~m), -1) ?
145
-
(~x)^((~m) +1)⨸((~m) +1) :nothing
146
-
```
147
-
The rule left hand side pattern is the symbolic function `∫(var1, var2)` where first variable is the integrand and second is the integration variable. After the => there are some conditions to determine if the rules are applicable, and after the ? there is the transformation. Note that this may still contain a integral, so a walk in pre order of the tree representing the symbolic expression is done, applying rules to each node containing the integral.
148
-
149
-
The infix operator `⨸` is used to represent a custom division function, if called on integers returns a rational and if called on floats returns a float. This is done because // operator does not support floats. This specific character was chosen because it resembles the division symbol and because it has the same precedence as /.
150
-
151
-
Not all rules are yet translated, I am each day translating more of them. If you want to know how to help translating rules and improving the package read the [contributing](#contributing) section. If you enconunter any issues using the package, please write me or open a issue on the repo.
152
-
153
-
# Test
154
-
To test the package run
155
-
```
156
-
julia --project=. test/runtests.jl
157
-
```
158
-
or in a Repl:
159
-
```
160
-
julia>using Symbolics, SymbolicIntegration
161
-
162
-
julia>include("test/runtests.jl")
163
-
164
-
```
165
109
166
110
# Documentation
167
111
168
112
Complete documentation with method selection guidance, algorithm details, and examples is available at:
In this repo there is also some software that serves the sole purpose of helping with the translation of rules from Mathematica syntax, and not for the actual package working. The important ones are:
177
-
- translator_of_rules.jl is a script that with regex and other string manipulations translates from Mathematica syntax to julia syntax
178
-
- translator_of_testset.jl is a script that translates the testsets into julia syntax (much simpler than translator_of_rules.jl)
179
-
- `reload_rules` function in rules_loader.jl. When developing the package using Revise is not enough because rules are defined with a macro. So this function reloads rules from a specific .jl file or from all files if called without arguments.
180
-
181
-
my typical workflow is:
182
-
- translate a rule file with translator_of_rules.jl. In the resulting file there could be some problems:
183
-
- - maybe a Mathematica function that i never encountered before and therefore not included in the translation script (and in rules_utility_functions.jl)
184
-
- - maybe a Mathematica syntax that I never encountered before and not included in the translation script
185
-
- - others, see [Common problems when translating rules](#common-problems-when-translating-rules)
186
-
- If the problem is quite common in other rules: implement in the translation script and translate the rule again, otherwise fix it manually in the .jl file
187
-
188
-
The rules not yet translated are mainly those from sections 4 to 8
189
-
190
-
## Common problems when translating rules
191
-
### function not translated
192
-
If you encounter a normal function that is not translated by the script, it will stay untranslated, with square brackets, like this:
a trick to find them fast is to search the regex pattern `(?<=^[^#]).*\[` in all the file. If you find them and they are already presen in julia or you implement them in rules_utility_functions.jl, you can simply add the to the smart_replace list in the translator and translate the script again.
197
-
198
-
### Sum function translation
199
-
the `Sum[...]` function gets translated with this regex:
200
-
```
201
-
(r"Sum\[(.*?),\s*\{(.*?),(.*?),(.*?)\}\]", s"sum([\1 for \2 in (\3):(\4)])"),
202
-
```
203
-
its quite common that the \1 is a <=2 letter variable, and so will get translated from the translator into a slot variable, appending ~.
so that will not be translated into slot variable.
222
-
```
223
-
sum([∫(1⨸(1 - sin((~e) + (~f)*(~x))^2⨸((-1)^(4*iii⨸(~n))*rt(-(~a)⨸(~b), (~n)⨸2))), (~x)) for iii in ( 1):( (~n)⨸2)]),
224
-
```
225
-
### Module syntax translation
226
-
The `Module` Syntax is similar to the `With` syntax, but a bit different and for now is not handled by the script
227
-
228
-
### * not present or present as \[Star]
229
-
in Mathematica if you write `a b` or `a \[Star] b` is interpreted as `a*b`. So sometimes in the rules is written like that. When it happens i usually add the * in the mathematica file, and then i translate it
230
-
231
-
## Description of the script `src/translator_of_rules.jl`
232
-
This script is used to translate integration rules from Mathematica syntax
233
-
to julia Syntax.
234
-
235
-
### How to use it
236
-
```bash
237
-
julia src/translator_of_rules.jl "src/rules/4 Trig functions/4.1 Sine/4.1.8 trig^m (a+b cos^p+c sin^q)^n.m"
238
-
```
239
-
and will produce the julia file at the path `src/rules/4 Trig functions/4.1 Sine/4.1.8 trig^m (a+b cos^p+c sin^q)^n.jl`
240
-
241
-
### How it works internally (useful to know if you have to debug it)
242
-
It processes line per line, so the integration rule must be all on only one
243
-
line. Let's say we translate this (fictional) rule:
for which a pretty complete set of reference implementations is provided.
18
-
19
-
Currently, SymbolicIntegration.jl can integrate:
20
-
- Rational functions
21
-
- Integrands involving transcendental elementary functions like `exp`, `log`, `sin`, etc.
22
-
23
-
As in the book, integrands involving algebraic functions like `sqrt` and non-integer powers are not treated.
24
-
25
-
!!! note
26
-
SymbolicIntegration.jl is still in an early stage of development and should not be expected to run stably in all situations.
27
-
It comes with absolutely no warranty whatsoever.
7
+
SymbolicIntegration.jl lets you solve indefinite integrals (finds primitives) in Julia [Symbolics.jl](https://docs.sciml.ai/Symbolics/stable/). It does so using two symbolic integration algorithms: Risch algorithm and Rule based algorithm.
28
8
29
9
## Installation
30
10
@@ -37,22 +17,20 @@ julia> using Pkg; Pkg.add("SymbolicIntegration")
Is implemented in a generic way using [AbstractAlgebra.jl](https://nemocas.github.io/AbstractAlgebra.jl/dev/). Some algorithms require [Nemo.jl](https://nemocas.github.io/Nemo.jl/dev/) for calculations with algebraic numbers.
for which a pretty complete set of reference implementations is provided.
66
+
67
+
Currently, RischMethod can integrate:
68
+
- Rational functions
69
+
- Integrands involving transcendental elementary functions like `exp`, `log`, `sin`, etc.
70
+
71
+
As in the book, integrands involving algebraic functions like `sqrt` and non-integer powers are not treated.
72
+
73
+
!!! note
74
+
SymbolicIntegration.jl is still in an early stage of development and should not be expected to run stably in all situations.
75
+
It comes with absolutely no warranty whatsoever.
76
+
77
+
### RuleBased
78
+
TODO add
86
79
87
80
[→ See complete methods documentation](methods/overview.md)
88
81
@@ -105,7 +98,7 @@ The **RischMethod** implements the complete suite of algorithms from Bronstein's
105
98
106
99
## Contributing
107
100
108
-
We welcome contributions! Please see the [Symbolics.jl contributing guidelines](https://docs.sciml.ai/Symbolics/stable/contributing/).
101
+
We welcome contributions! Please see the [contributing](manual/contributing.md) page and the [Symbolics.jl contributing guidelines](https://docs.sciml.ai/Symbolics/stable/contributing/).
0 commit comments