Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
ode-solver-2021
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Величко Арсений Александрович
ode-solver-2021
Commits
8daac275
Commit
8daac275
authored
Dec 25, 2021
by
Величко Арсений Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented most of the dynamic solvers
parent
0ac663f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
9 deletions
+101
-9
dynamic_solvers.py
src/dynamic_solvers/dynamic_solvers.py
+101
-9
No files found.
src/dynamic_solvers/dynamic_solvers.py
View file @
8daac275
...
@@ -3,19 +3,111 @@ import typing as tp
...
@@ -3,19 +3,111 @@ import typing as tp
# TODO Метод цифра за цифрой
# TODO Метод цифра за цифрой
def
cordic_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
)
->
float
:
def
cordic_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
)
->
float
:
"""Метод цифра за цифрой (CORDIC)"""
pass
pass
# TODO Метод двойного пересчета
def
double_recalculate_method
(
def
double_recalculate_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
)
->
float
:
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
=
1000
,
perc
:
float
=
0.0001
pass
)
->
float
:
"""Двойной пересчет"""
h
=
(
b
-
a
)
/
steps
ln
=
0
l2n
=
0
R
=
0
while
R
<
perc
:
S2
=
0
x
=
a
# TODO Метод Рунге-Кутта
while
x
<=
b
-
h
:
def
runge_kutta_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
)
->
float
:
S2
+=
fx
(
x
)
pass
x
+=
h
l2n
=
h
*
S2
R
=
abs
(
ln
-
l2n
)
ln
=
l2n
h
=
h
/
2
# TODO Метод Эйлера
return
l2n
def
euler_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
)
->
float
:
pass
def
mysterious_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
=
1000
,
eps
:
float
=
0.0001
)
->
float
:
"""Некий секретный алгоритм"""
h
=
(
b
-
a
)
/
steps
x
=
a
S1
=
0
while
x
<=
b
-
steps
:
S1
+=
fx
(
x
)
x
+=
h
S1
*=
h
h2
=
h
/
2
S2
=
0
while
True
:
x
=
a
+
h2
while
x
<=
b
-
h
:
S2
+=
fx
(
x
)
x
+=
h
S2
*=
h
if
(
S1
-
S2
)
<
eps
:
break
h
=
h2
h2
=
h2
/
2
S1
=
S2
S2
=
0
return
S2
def
runge_kutty_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
n
:
int
=
10
,
multi
:
int
=
1
)
->
float
:
"""Метод Рунге-Кутты"""
y
=
1
i
=
1
h
=
((
b
-
a
)
/
n
)
/
multi
x
=
a
while
x
<=
(
b
-
h
):
k1
=
fx
(
x
)
k2
=
fx
(
x
+
h
/
2
)
k3
=
fx
(
x
+
h
/
2
)
k4
=
fx
(
x
+
h
)
y
+=
h
/
6
*
(
k1
+
2
*
k2
+
2
*
k3
+
k4
)
x
+=
h
i
+=
1
return
y
def
euler_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
n
:
int
=
10
,
x0
:
float
=
0.0
,
multi
:
int
=
1
,
)
->
float
:
"""Метод Эйлера"""
x
=
[
x0
]
y
=
[]
i
=
0
h
=
((
b
-
a
)
/
n
)
/
multi
j
=
a
while
j
<
(
b
-
h
):
y
.
append
(
y
[
i
]
+
h
*
fx
(
x
[
i
]))
x
.
append
(
x
[
i
]
+
h
)
j
+=
h
i
+=
1
return
y
[
i
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment