stepsize-strategies 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ersan Erdem
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: stepsize-strategies
3
+ Version: 0.1.0
4
+ Summary: Variable step size strategies for the Euler method: Picard, error analysis, and linear / non-linear systems.
5
+ Author-email: Ersan Erdem <ersanerdem.ee@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://stepsizestrategies.pythonanywhere.com
8
+ Project-URL: Repository, https://github.com/ersanerdem/stepsize-strategies
9
+ Project-URL: Issues, https://github.com/ersanerdem/stepsize-strategies/issues
10
+ Project-URL: Web application, https://github.com/ersanerdem/step-size-strategy-webapp
11
+ Project-URL: Article, https://dergipark.org.tr/en/pub/konuralpjournalmath/article/618922
12
+ Keywords: ordinary differential equations,ODE,Euler method,step size,adaptive step,numerical analysis,Picard theorem,error analysis
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Classifier: Topic :: Education
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: numpy>=1.24
30
+ Requires-Dist: scipy>=1.10
31
+ Requires-Dist: sympy>=1.12
32
+ Provides-Extra: pandas
33
+ Requires-Dist: pandas>=2.0; extra == "pandas"
34
+ Provides-Extra: plot
35
+ Requires-Dist: matplotlib>=3.7; extra == "plot"
36
+ Provides-Extra: all
37
+ Requires-Dist: pandas>=2.0; extra == "all"
38
+ Requires-Dist: matplotlib>=3.7; extra == "all"
39
+ Dynamic: license-file
40
+
41
+ # stepsize-strategies
42
+
43
+ Variable step size strategies for the Euler method, as a Python package.
44
+
45
+ The step of every Euler step is chosen **before** the step is taken, from a bound that
46
+ guarantees either that the next point stays in the rectangle of Picard's theorem or that the
47
+ local error stays below a tolerance. The five strategies come from the work of the research
48
+ group at Necmettin Erbakan University and are the numerical core of the
49
+ [Step Size Strategies web application](https://stepsizestrategies.pythonanywhere.com).
50
+
51
+ | Function | Problem | Step size |
52
+ | --- | --- | --- |
53
+ | `picard` | `x' = f(t, x)` | `h_i = min{a, b / M_i}`, `M_i = max \|f\|` |
54
+ | `error_analysis` | `x' = f(t, x)` | `h_i = sqrt(2 δ / M_ti)`, `M_ti = max \|f_t + f_x f\|` |
55
+ | `picard_error` | `x' = f(t, x)` | `h_i = min{a, b_i / M_i}`, the rectangle `b_i` shrinks with an error estimate |
56
+ | `linear_system` | `X' = A X` | `h_i = (2 δ / β_{i-1})^(1/2) / (α N^(5/4))` |
57
+ | `nonlinear_system` | `X' = A X + φ(t, X)` | `h_i = N^(-1/4) (2 δ / (N² α² β + N α γ + ζ))^(1/2)` |
58
+
59
+ `M`, `β`, `γ`, `ζ` are bounds of the function and its derivatives around the current point;
60
+ `α = max |a_jk|`. All derivatives (`f_t + f_x f`, and `φ_t + J_x(φ)(AX + φ)` for non-linear
61
+ systems) are computed **exactly with SymPy**, not with finite differences.
62
+
63
+ ## Installation
64
+
65
+ ```bash
66
+ pip install stepsize-strategies # numpy, scipy, sympy
67
+ pip install "stepsize-strategies[all]" # + pandas and matplotlib for tables and plots
68
+ ```
69
+
70
+ Python 3.10 or newer.
71
+
72
+ ## Quick start
73
+
74
+ ```python
75
+ import stepsize_strategies as sss
76
+
77
+ # One equation: x' = t + x, x(0) = 1 on [0, 1]
78
+ sol = sss.error_analysis("t + x", x0=1, a=1, b=1, delta=1e-3)
79
+
80
+ sol # Solution(method='error_analysis', steps=..., t_final=1, reached t0 + a)
81
+ sol.t, sol.x # time points and the solution
82
+ sol.h # the step sizes chosen by the strategy
83
+ sol.summary() # steps, final value, smallest / largest step ...
84
+ sol.to_dataframe() # the table of steps (pandas)
85
+ sol.plot() # solution and step sizes (matplotlib)
86
+ ```
87
+
88
+ ```python
89
+ # Linear system X' = A X: a damped oscillator
90
+ sol = sss.linear_system([[0, 1], [-1, -0.3]], x0=[1, 0], a=5, b=1, delta=5e-3)
91
+ sol.x.shape # (steps + 1, 2)
92
+ sol.local_error # local error of every step, || e^{hA} X_i - X_{i+1} ||
93
+
94
+ # Non-linear system X' = A X + φ(t, X): a predator-prey model
95
+ sol = sss.nonlinear_system(
96
+ A=[[1, 0], [0, -0.5]],
97
+ phi=["-0.5*x*y", "0.25*x*y"],
98
+ x0=[2, 1], a=5, b=1, delta=5e-3,
99
+ )
100
+ ```
101
+
102
+ ## Parameters
103
+
104
+ | Name | Meaning |
105
+ | --- | --- |
106
+ | `f`, `phi` | Formulas as text (`"x*(1-x)"`, `"sin(t) - x^2"`, `"exp(-t)*y"`) or SymPy expressions. Variables: `t`, `x` for one equation; `t`, `x, y, z, w` (or `x1 … x4`) for systems. Functions: `sin cos tan cot sec csc asin acos atan sinh cosh tanh exp log ln sqrt abs`, constants `pi`, `E`. |
107
+ | `x0`, `t0` | Initial value `x(t0) = x0` (`t0` defaults to 0). A list for systems. |
108
+ | `A` | Constant `N x N` matrix (lists or a NumPy array). `nonlinear_system` supports `N <= 4`. |
109
+ | `a` | Length of the interval `[t0, t0 + a]` (and the half-width of the rectangle in `t`). |
110
+ | `b` | Half-width of the rectangle around the solution. |
111
+ | `delta` | Desired local error of every step (`error_analysis` and the systems). |
112
+ | `h_min` | The integration stops when the strategy asks for a smaller step; `sol.stopped_by_h_min` is then `True`. Default 0. |
113
+ | `max_steps` | Safety limit (default 100 000); `ComputationError` if more steps are needed. |
114
+ | `legacy` | `True` reproduces the numbers of the original 2018 web application (see below). |
115
+
116
+ Numbers may also be given as text: `"pi/4"`, `"1e-3"`, `"0,5"`. Formulas are parsed by a
117
+ safe parser (no `eval`), so text typed by users can be passed in directly.
118
+
119
+ ## Which strategy?
120
+
121
+ - Existence and uniqueness of the solution known: `picard` or `error_analysis`.
122
+ - Existence not known in advance: `picard_error`.
123
+ - Systems: `linear_system` for `X' = A X`, `nonlinear_system` for `X' = A X + φ(t, X)`.
124
+
125
+ ## Legacy mode
126
+
127
+ By default three details of the original 2018 web application are corrected: the bound `M`
128
+ is taken over the whole rectangle (the original looked at one diagonal), the local error of
129
+ linear systems uses the matrix exponential (the original used the element-wise exponential),
130
+ and the terms of `dφ/dt` are combined in the right order. `legacy=True` gives the original
131
+ numbers, for example to reproduce published tables.
132
+
133
+ ## Try it in the browser
134
+
135
+ The same strategies, with ready-made examples, charts and Excel export:
136
+ <https://stepsizestrategies.pythonanywhere.com> (English) ·
137
+ <https://stepsizestrategies.pythonanywhere.com/tr/> (Türkçe).
138
+
139
+ ## How to cite
140
+
141
+ If you use this package, please cite:
142
+
143
+ > E. Erdem, G. Çelik Kızılkan, A. O. Çıbıkdiken. *Web Application for Step Size Strategies.*
144
+ > Konuralp Journal of Mathematics 7(2), 475–485, 2019.
145
+ > [DergiPark](https://dergipark.org.tr/en/pub/konuralpjournalmath/article/618922)
146
+
147
+ GitHub's "Cite this repository" button gives the same reference (`CITATION.cff`).
148
+
149
+ The package grew out of the master's thesis *Adım Genişliği Stratejileri İçin Web Uygulaması*
150
+ (Web Application for Step Size Strategies), E. Erdem, Necmettin Erbakan University, 2019.
151
+
152
+ ## The strategies in the literature
153
+
154
+ - A new variable step size algorithm for Cauchy problem.
155
+ [ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S0096300306006217)
156
+ - Step Size Strategies Based on Error Analysis.
157
+ [DergiPark](http://dergipark.gov.tr/download/article-file/214950)
158
+ - Step Size Strategy for the Numerical Integration of Systems of the Linear Systems.
159
+ [ResearchGate](https://www.researchgate.net/publication/260391200_Step_Size_Strategies_Based_On_Error_Analysis_For_The_Linear_Systems)
160
+ - Step Size Strategy for the Numerical Integration of Systems of Differential Equations.
161
+ [ScienceDirect](https://www.sciencedirect.com/science/article/pii/S0377042711003682)
162
+
163
+ ## Türkçe
164
+
165
+ Euler yöntemi için değişken adım uzunluğu stratejileri: Picard teoremi, hata analizi,
166
+ Picard + hata analizi, lineer ve lineer olmayan sistemler. Kurulum `pip install
167
+ stepsize-strategies`; kullanım örnekleri yukarıda. Aynı stratejiler tarayıcıda:
168
+ <https://stepsizestrategies.pythonanywhere.com/tr/>.
169
+
170
+ ## License
171
+
172
+ MIT © 2026 Ersan Erdem
@@ -0,0 +1,132 @@
1
+ # stepsize-strategies
2
+
3
+ Variable step size strategies for the Euler method, as a Python package.
4
+
5
+ The step of every Euler step is chosen **before** the step is taken, from a bound that
6
+ guarantees either that the next point stays in the rectangle of Picard's theorem or that the
7
+ local error stays below a tolerance. The five strategies come from the work of the research
8
+ group at Necmettin Erbakan University and are the numerical core of the
9
+ [Step Size Strategies web application](https://stepsizestrategies.pythonanywhere.com).
10
+
11
+ | Function | Problem | Step size |
12
+ | --- | --- | --- |
13
+ | `picard` | `x' = f(t, x)` | `h_i = min{a, b / M_i}`, `M_i = max \|f\|` |
14
+ | `error_analysis` | `x' = f(t, x)` | `h_i = sqrt(2 δ / M_ti)`, `M_ti = max \|f_t + f_x f\|` |
15
+ | `picard_error` | `x' = f(t, x)` | `h_i = min{a, b_i / M_i}`, the rectangle `b_i` shrinks with an error estimate |
16
+ | `linear_system` | `X' = A X` | `h_i = (2 δ / β_{i-1})^(1/2) / (α N^(5/4))` |
17
+ | `nonlinear_system` | `X' = A X + φ(t, X)` | `h_i = N^(-1/4) (2 δ / (N² α² β + N α γ + ζ))^(1/2)` |
18
+
19
+ `M`, `β`, `γ`, `ζ` are bounds of the function and its derivatives around the current point;
20
+ `α = max |a_jk|`. All derivatives (`f_t + f_x f`, and `φ_t + J_x(φ)(AX + φ)` for non-linear
21
+ systems) are computed **exactly with SymPy**, not with finite differences.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install stepsize-strategies # numpy, scipy, sympy
27
+ pip install "stepsize-strategies[all]" # + pandas and matplotlib for tables and plots
28
+ ```
29
+
30
+ Python 3.10 or newer.
31
+
32
+ ## Quick start
33
+
34
+ ```python
35
+ import stepsize_strategies as sss
36
+
37
+ # One equation: x' = t + x, x(0) = 1 on [0, 1]
38
+ sol = sss.error_analysis("t + x", x0=1, a=1, b=1, delta=1e-3)
39
+
40
+ sol # Solution(method='error_analysis', steps=..., t_final=1, reached t0 + a)
41
+ sol.t, sol.x # time points and the solution
42
+ sol.h # the step sizes chosen by the strategy
43
+ sol.summary() # steps, final value, smallest / largest step ...
44
+ sol.to_dataframe() # the table of steps (pandas)
45
+ sol.plot() # solution and step sizes (matplotlib)
46
+ ```
47
+
48
+ ```python
49
+ # Linear system X' = A X: a damped oscillator
50
+ sol = sss.linear_system([[0, 1], [-1, -0.3]], x0=[1, 0], a=5, b=1, delta=5e-3)
51
+ sol.x.shape # (steps + 1, 2)
52
+ sol.local_error # local error of every step, || e^{hA} X_i - X_{i+1} ||
53
+
54
+ # Non-linear system X' = A X + φ(t, X): a predator-prey model
55
+ sol = sss.nonlinear_system(
56
+ A=[[1, 0], [0, -0.5]],
57
+ phi=["-0.5*x*y", "0.25*x*y"],
58
+ x0=[2, 1], a=5, b=1, delta=5e-3,
59
+ )
60
+ ```
61
+
62
+ ## Parameters
63
+
64
+ | Name | Meaning |
65
+ | --- | --- |
66
+ | `f`, `phi` | Formulas as text (`"x*(1-x)"`, `"sin(t) - x^2"`, `"exp(-t)*y"`) or SymPy expressions. Variables: `t`, `x` for one equation; `t`, `x, y, z, w` (or `x1 … x4`) for systems. Functions: `sin cos tan cot sec csc asin acos atan sinh cosh tanh exp log ln sqrt abs`, constants `pi`, `E`. |
67
+ | `x0`, `t0` | Initial value `x(t0) = x0` (`t0` defaults to 0). A list for systems. |
68
+ | `A` | Constant `N x N` matrix (lists or a NumPy array). `nonlinear_system` supports `N <= 4`. |
69
+ | `a` | Length of the interval `[t0, t0 + a]` (and the half-width of the rectangle in `t`). |
70
+ | `b` | Half-width of the rectangle around the solution. |
71
+ | `delta` | Desired local error of every step (`error_analysis` and the systems). |
72
+ | `h_min` | The integration stops when the strategy asks for a smaller step; `sol.stopped_by_h_min` is then `True`. Default 0. |
73
+ | `max_steps` | Safety limit (default 100 000); `ComputationError` if more steps are needed. |
74
+ | `legacy` | `True` reproduces the numbers of the original 2018 web application (see below). |
75
+
76
+ Numbers may also be given as text: `"pi/4"`, `"1e-3"`, `"0,5"`. Formulas are parsed by a
77
+ safe parser (no `eval`), so text typed by users can be passed in directly.
78
+
79
+ ## Which strategy?
80
+
81
+ - Existence and uniqueness of the solution known: `picard` or `error_analysis`.
82
+ - Existence not known in advance: `picard_error`.
83
+ - Systems: `linear_system` for `X' = A X`, `nonlinear_system` for `X' = A X + φ(t, X)`.
84
+
85
+ ## Legacy mode
86
+
87
+ By default three details of the original 2018 web application are corrected: the bound `M`
88
+ is taken over the whole rectangle (the original looked at one diagonal), the local error of
89
+ linear systems uses the matrix exponential (the original used the element-wise exponential),
90
+ and the terms of `dφ/dt` are combined in the right order. `legacy=True` gives the original
91
+ numbers, for example to reproduce published tables.
92
+
93
+ ## Try it in the browser
94
+
95
+ The same strategies, with ready-made examples, charts and Excel export:
96
+ <https://stepsizestrategies.pythonanywhere.com> (English) ·
97
+ <https://stepsizestrategies.pythonanywhere.com/tr/> (Türkçe).
98
+
99
+ ## How to cite
100
+
101
+ If you use this package, please cite:
102
+
103
+ > E. Erdem, G. Çelik Kızılkan, A. O. Çıbıkdiken. *Web Application for Step Size Strategies.*
104
+ > Konuralp Journal of Mathematics 7(2), 475–485, 2019.
105
+ > [DergiPark](https://dergipark.org.tr/en/pub/konuralpjournalmath/article/618922)
106
+
107
+ GitHub's "Cite this repository" button gives the same reference (`CITATION.cff`).
108
+
109
+ The package grew out of the master's thesis *Adım Genişliği Stratejileri İçin Web Uygulaması*
110
+ (Web Application for Step Size Strategies), E. Erdem, Necmettin Erbakan University, 2019.
111
+
112
+ ## The strategies in the literature
113
+
114
+ - A new variable step size algorithm for Cauchy problem.
115
+ [ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S0096300306006217)
116
+ - Step Size Strategies Based on Error Analysis.
117
+ [DergiPark](http://dergipark.gov.tr/download/article-file/214950)
118
+ - Step Size Strategy for the Numerical Integration of Systems of the Linear Systems.
119
+ [ResearchGate](https://www.researchgate.net/publication/260391200_Step_Size_Strategies_Based_On_Error_Analysis_For_The_Linear_Systems)
120
+ - Step Size Strategy for the Numerical Integration of Systems of Differential Equations.
121
+ [ScienceDirect](https://www.sciencedirect.com/science/article/pii/S0377042711003682)
122
+
123
+ ## Türkçe
124
+
125
+ Euler yöntemi için değişken adım uzunluğu stratejileri: Picard teoremi, hata analizi,
126
+ Picard + hata analizi, lineer ve lineer olmayan sistemler. Kurulum `pip install
127
+ stepsize-strategies`; kullanım örnekleri yukarıda. Aynı stratejiler tarayıcıda:
128
+ <https://stepsizestrategies.pythonanywhere.com/tr/>.
129
+
130
+ ## License
131
+
132
+ MIT © 2026 Ersan Erdem
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "stepsize-strategies"
7
+ version = "0.1.0"
8
+ description = "Variable step size strategies for the Euler method: Picard, error analysis, and linear / non-linear systems."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Ersan Erdem", email = "ersanerdem.ee@gmail.com" }]
14
+ keywords = [
15
+ "ordinary differential equations", "ODE", "Euler method", "step size",
16
+ "adaptive step", "numerical analysis", "Picard theorem", "error analysis",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Education",
21
+ "Intended Audience :: Science/Research",
22
+ "Operating System :: OS Independent",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Topic :: Scientific/Engineering :: Mathematics",
30
+ "Topic :: Education",
31
+ "Typing :: Typed",
32
+ ]
33
+ dependencies = ["numpy>=1.24", "scipy>=1.10", "sympy>=1.12"]
34
+
35
+ [project.optional-dependencies]
36
+ pandas = ["pandas>=2.0"]
37
+ plot = ["matplotlib>=3.7"]
38
+ all = ["pandas>=2.0", "matplotlib>=3.7"]
39
+
40
+ [project.urls]
41
+ Homepage = "https://stepsizestrategies.pythonanywhere.com"
42
+ Repository = "https://github.com/ersanerdem/stepsize-strategies"
43
+ Issues = "https://github.com/ersanerdem/stepsize-strategies/issues"
44
+ "Web application" = "https://github.com/ersanerdem/step-size-strategy-webapp"
45
+ Article = "https://dergipark.org.tr/en/pub/konuralpjournalmath/article/618922"
46
+
47
+ [tool.setuptools.packages.find]
48
+ where = ["src"]
49
+
50
+ [tool.setuptools.package-data]
51
+ stepsize_strategies = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,35 @@
1
+ """Variable step size strategies for the Euler method.
2
+
3
+ Five strategies from the work of the research group at Necmettin Erbakan University
4
+ (Çelik Kızılkan; Çelik Kızılkan and Aydın) for
5
+
6
+ * one equation ``x' = f(t, x)``: :func:`picard`, :func:`error_analysis`, :func:`picard_error`
7
+ * linear systems ``X' = A X``: :func:`linear_system`
8
+ * non-linear systems ``X' = A X + phi(t, X)``: :func:`nonlinear_system`
9
+
10
+ Example
11
+ -------
12
+ >>> import stepsize_strategies as sss
13
+ >>> sol = sss.error_analysis("t + x", x0=1, a=1, b=1, delta=1e-3)
14
+ >>> sol.reached_end
15
+ True
16
+ """
17
+
18
+ from ._core import ComputationError
19
+ from ._expr import ExpressionError
20
+ from .api import error_analysis, linear_system, nonlinear_system, picard, picard_error
21
+ from .result import Solution
22
+
23
+ __version__ = "0.1.0"
24
+
25
+ __all__ = [
26
+ "ComputationError",
27
+ "ExpressionError",
28
+ "Solution",
29
+ "error_analysis",
30
+ "linear_system",
31
+ "nonlinear_system",
32
+ "picard",
33
+ "picard_error",
34
+ "__version__",
35
+ ]