static solver signatures

parent 558802fa
from decimal import Decimal
import typing as tp
# TODO Метод левых прямоугольников
def left_rectangle_method(fx: callable, a, b, steps: int) -> float:
w = (b - a) / steps
return sum(fx(x) * w for x in range(a, b, w))
def left_rectangle_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
# TODO Метод правых прямоугольников
def right_rectangle_method(fx: callable, a, b, steps: int) -> float:
w = (b - a) / steps
return sum(fx(x) * w for x in range(a + w, b + w, w))
def right_rectangle_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
# TODO Метод трапеций
def trapezium_method(fx: callable, a: Decimal, b: Decimal, steps: int) -> Decimal:
w: Decimal = (b - a) / steps
x1 = a
res = Decimal(0)
for x in range(a + w, b + w, w):
y = fx((x1 + x) / 2)
x1 = x
res += y
return res
def trapezium_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
# TODO Метод парабол
def parabola_method(fx: callable, a: Decimal, b: Decimal, steps: int) -> Decimal:
def parabola_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
# TODO Метод переменного шага: Двойной пересчет
def double_count_method(fx: callable, a: Decimal, b: Decimal, steps: int) -> Decimal:
def double_count_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
# TODO Метод переменного шага: Некий секретный алгоритм
def mysterious_method(fx: callable, a: Decimal, b: Decimal, steps: int) -> Decimal:
def mysterious_method(fx: tp.Callable[[float], float], a: float, b: float, steps: int) -> float:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment