from operator import itemgetter interval def f1 return 30 24 def f2 re

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from operator import itemgetter
interval = [1, 6]
def f1(x):
return (30 + 5*x**2) / (24 - 2*x)
def f2(x):
return 40 - 7*x
funcs = [f1,f2]
f1_ = 2.5
f2_ = 22
fs_ = [f1_, f2_]
step = 0.001
def argsteps(left, right, step):
return [left + n*step for n in
range(int((right - left) / step))]
def mm(f1, f2):
def wrapped(funcs, fs_, interval, step):
args = argsteps(interval[0], interval[1], step)
def f(x):
return f2(func(x) / func_ for (func, func_) in zip(funcs, fs_))
return f1(zip(args, map(f, args)),key=itemgetter(1))
return wrapped
minmax = mm(min, max)
maxmin = mm(max, min)
def do_stuff():
return [f(funcs, fs_, interval, step) for f in [maxmin, minmax]]