from matplotlib.pyplot import * import math PN = 15 PU = 1/PN X0 = 0.3 X1 = 6 p0 = 0.6 p1 = 3.7 RNG = 25 X0 = 0 for i in range(RNG+1): p = p0 + i*(p1-p0)/RNG fp = p + 2/p rcp = 1-2/p**2 cnt = fp - p*rcp X2 = -cnt/rcp if rcp < 0: XX0 = X0 XX1 = min(X1,X2) else: XX0 = max(X0,X2) XX1 = X1 x = [XX0 + (XX1-XX0)*i/(PN-1) for i in range(PN)] h = [rcp*xi + cnt for xi in x] plot(x,h, [0, 255*(1-i/RNG), 255*i/RNG]) X0 = 0.3 X1 = 6 PN = 50 x = [X0 + (X1-X0)*i/(PN-1) for i in range(PN)] f = [xi + 2/xi for xi in x] plot(x,f,'r') grid() show()