Advertisement
mirosh111000

4

Sep 17th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import cmath as cm
  4.  
  5. def sum_decorator(a, b, f):
  6.     res = 0
  7.     for i in range(a, b + 1):
  8.         res += f(i)
  9.     return res
  10.  
  11. def f_a(x):
  12.     return x**2 / (cm.acos(x**4) + 5)
  13.  
  14. def f_b(x):
  15.     return (x**2 + np.tan(x + 1)) / (np.exp(x) - 1)
  16.  
  17. def mul_decorator(a, b, f):
  18.     res = 1
  19.     for i in range(a, b + 1):
  20.         res *= f(i)
  21.     return res
  22.  
  23. def f_c(x):
  24.     return np.sin(x)**2 / (1 + np.exp(-x))
  25.  
  26. res_a = sum_decorator(1, 10, f_a)
  27. res_b = sum_decorator(1, 3, f_b)
  28. res_c = mul_decorator(5, 10, f_c)
  29.  
  30. print(f'а) Відповідь: {res_a}')
  31. print(f'б) Відповідь: {res_b}')
  32. print(f'в) Відповідь: {res_c}')
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement