Jensen; "begin" "comment" program to integrate f(x,y) over triangle (0,0), (1,0), (1,1); "comment" using Jensen"s device -- David Ho; "real" x, y; "real" "procedure" int(a, b, x, f); "comment" integrates f(x) over range a to b; "value" a, b; "real" a, b, x, f; "begin" "real" "procedure" intint(a, b, fa, fb); "value" a, b, fa, fb; "real" a, b, fa, fb; "begin" "real" c, fc, ff; x := c := (a + b) / 2; fc := f; ff := (fa + 4*fc + fb)/6; "comment" answer is good enough if simrule no better than trapezoidal; "if" abs( fa + fb - ff*2 ) < 0.001 "then" intint := ff * (b - a) "else" intint := 0.0; "end"; "real" fa; x := a; fa := f; x := b; int := intint(a, b, fa, f); "end"; "real" answer; "comment" writetext(30, {int(0, 1, x, int(0, x, y, x*x + y*y)){c}}); answer := int(0, 1, x, x*x); "comment" output(30, answer); "end"