Date: 27 September 2013

x

xmin = -5
xmax = 5
ymin = -5
ymax = 4
dx: (xmax - xmin) / 3
x4: xmax
x3: xmin + (2 * dx)
x2: xmin + dx
x1: xmin
y1 = 2
y2 = 3
y3 = -1
y4 = 0
a = PolyLine((x1, y1), (x2, y2), (x3, y3), (x4, y4))
mm1: (y2 - y1) / dx
mm2: (y3 - y2) / dx
mm3: (y4 - y3) / dx
z1 = 1
m1options: mm1 + Sequence[i, i, ceil(ymin - mm1), floor(ymax - mm1)]
xs1: ((3 * x1) + x2) / 4
xs2: (x1 + (3 * x2)) / 4
xs3: ((3 * x2) + x3) / 4
xs4: (x2 + (3 * x3)) / 4
xs5: ((3 * x3) + x4) / 4
xs6: (x3 + (3 * x4)) / 4
M1 = Point(Zip[(xs1, a), a, m1options])
m2options: mm2 + Sequence[i, i, ceil(ymin - mm2), floor(ymax - mm2)]
m3options: mm3 + Sequence[i, i, ceil(ymin - mm3), floor(ymax - mm3)]
M2 = Point(Zip[(xs2, a), a, m1options])
M3 = Point(Zip[(xs3, a), a, m2options])
M4 = Point(Zip[(xs4, a), a, m2options])
M5 = Point(Zip[(xs5, a), a, m3options])
M6 = Point(Zip[(xs6, a), a, m3options])
S1 = Segment((x1, y(M1)), ((x1 + x2) / 2, y(M1)))
S2 = Segment(((x1 + x2) / 2, y(M2)), (x2, y(M2)))
S3 = Segment((x2, y(M3)), ((x2 + x3) / 2, y(M3)))
S4 = Segment(((x2 + x3) / 2, y(M4)), (x3, y(M4)))
S5 = Segment((x3, y(M5)), ((x3 + x4) / 2, y(M5)))
S6 = Segment(((x3 + x4) / 2, y(M6)), (x4, y(M6)))
m1a: y(M1)
m1b: y(M2)
m2a: y(M3)
m2b: y(M4)
m3a: y(M5)
m3b: y(M6)
m1acorrect: m1a ≟ mm1
m1bcorrect: m1b ≟ mm1
m2acorrect: m2a ≟ mm2
m2bcorrect: m2b ≟ mm2
m3acorrect: m3a ≟ mm3
m3bcorrect: m3b ≟ mm3
text1: "" + (LaTeX[xlabel]) + ""
fderiv1 = Segment((x1, mm1), (x2, mm1))
fderiv2 = Segment((x2, mm2), (x3, mm2))
fderiv3 = Segment((x3, mm3), (x4, mm3))
showcorrect = false