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
0ac663f1
Commit
0ac663f1
authored
Dec 25, 2021
by
Величко Арсений Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented static solvers
parent
661b2cb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
16 deletions
+41
-16
static_solvers.py
src/static_solvers/static_solvers.py
+41
-16
No files found.
src/static_solvers/static_solvers.py
View file @
0ac663f1
import
typing
as
tp
# TODO Метод левых прямоугольников
def
left_rectangle_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
"""Метод левых прямоугольников"""
h
=
(
b
-
a
)
/
steps
x
=
a
area
=
0.0
for
_
in
range
(
steps
):
area
+=
h
*
fx
(
x
)
x
+=
h
# TODO Метод правых прямоугольников
def
right_rectangle_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
return
area
def
right_rectangle_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
"""Метод правых прямоугольников"""
h
=
(
b
-
a
)
/
steps
x
=
a
+
h
area
=
0.0
for
_
in
range
(
steps
):
area
+=
h
*
fx
(
x
)
x
+=
h
return
area
# TODO Метод трапеций
def
trapezium_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
"""Метод трапеций"""
h
:
float
=
(
b
-
a
)
/
steps
ans
:
float
=
0.0
x
:
float
=
a
for
_
in
range
(
steps
):
ans
+=
h
*
(
fx
(
x
)
+
fx
(
x
+
h
))
/
2
x
+=
h
return
ans
# TODO Метод парабол
def
parabola_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
def
parabola_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
"""Метод парабол"""
if
steps
%
2
==
1
:
steps
+=
1
# TODO Метод переменного шага: Двойной пересчет
def
double_count_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
h
:
float
=
(
b
-
a
)
/
steps
summa
:
float
=
fx
(
a
)
+
4
*
fx
(
a
+
h
)
+
fx
(
b
)
for
i
in
range
(
1
,
int
(
steps
/
2
)):
summa
+=
2
*
fx
(
a
+
(
2
*
i
)
*
h
)
+
4
*
fx
(
a
+
(
2
*
i
+
1
)
*
h
)
# TODO Метод переменного шага: Некий секретный алгоритм
def
mysterious_method
(
fx
:
tp
.
Callable
[[
float
],
float
],
a
:
float
,
b
:
float
,
steps
:
int
)
->
float
:
pass
return
summa
*
h
/
3
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