Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import math
  2. from tabulate import tabulate
  3.  
  4. function1_ = 20
  5. function2_ = 10
  6.  
  7. def function1(x):
  8. return 20 + 6 * x - 3 * x // 2
  9.  
  10.  
  11. def function2(x):
  12. return 9 * math.log1p(x) + 9
  13.  
  14.  
  15. def calculate(start, end, step):
  16. result = []
  17. x = start
  18. while x <= end:
  19. res1 = function1(x)/function1_
  20. res2 = function2(x)/function2_
  21. res3 = max(res1, res2)
  22. res4 = min(res1,res2)
  23. result.append([res1, res2, res3, res4])
  24. x += step
  25.  
  26. return result
  27.  
  28.  
  29. def main():
  30. result = calculate(2, 5, 0.001)
  31. min_max = result[0][2]
  32. max_min = result[0][3]
  33.  
  34. for index in range(len(result)):
  35. min_max = min(result[index][2], min_max)
  36. max_min = max(result[index][3], max_min)
  37.  
  38. print(tabulate(result, headers=['f1/f1*', 'f2/f2*', 'max(Fi/Fi*)', 'min(Fi/Fi*)']))
  39.  
  40. print("min max(Fi/Fi*) = {}".format(min_max))
  41. print("max min(Fi/Fi*) = {}".format(max_min))
  42.  
  43.  
  44. if __name__ == "__main__":
  45. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement