Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import cmath as cm
- def sum_decorator(a, b, f):
- res = 0
- for i in range(a, b + 1):
- res += f(i)
- return res
- def f_a(x):
- return x**2 / (cm.acos(x**4) + 5)
- def f_b(x):
- return (x**2 + np.tan(x + 1)) / (np.exp(x) - 1)
- def mul_decorator(a, b, f):
- res = 1
- for i in range(a, b + 1):
- res *= f(i)
- return res
- def f_c(x):
- return np.sin(x)**2 / (1 + np.exp(-x))
- res_a = sum_decorator(1, 10, f_a)
- res_b = sum_decorator(1, 3, f_b)
- res_c = mul_decorator(5, 10, f_c)
- print(f'а) Відповідь: {res_a}')
- print(f'б) Відповідь: {res_b}')
- print(f'в) Відповідь: {res_c}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement