randFromArray([
[[ 1, 0, -16, 0, 49], [-5, 5], [-100, 100]],
[[-1, 0, 16, 0, -49], [-5, 5], [-250, 100]],
[[ 1, 3, -14, -35, 21], [-5, 5], [-100, 200]],
[[-1, -3, 14, 35, 0], [-5, 5], [-200, 100]],
[[ 1, 4, -1, -4], [-5, 5], [ -40, 120]],
[[ -1, -4, 1, 4], [-5, 5], [-150, 40]],
[[ 1, 0, -16, 0], [-5, 5], [ -50, 50]],
[[ -1, 0, 16, 0], [-5, 5], [ -70, 60]],
[[ 1, 0, -22, 27], [-5, 5], [ -30, 70]],
[[ -1, 0, 22, -27], [-5, 5], [ -70, 30]],
[[ 1, 1, -13, -14], [-5, 5], [ -40, 40]],
[[ -1, -1, 13, 14], [-5, 5], [ -40, 40]],
[[ 1, 0, -12], [-5, 5], [ -20, 20]],
[[ -1, 0, 12], [-5, 5], [ -20, 20]],
[[ 1, -1, -6], [-5, 5], [ -20, 20]],
[[ -1, 1, 6], [-5, 5], [ -30, 20]],
[[ 1, 0, -3], [-5, 5], [ -20, 30]],
[[ -1, 0, 3], [-5, 5], [ -30, 20]],
[[ 1, 2, 0], [-5, 5], [ -10, 35]],
[[ -1, -2, 0], [-5, 5], [ -40, 20]]
])
new Polynomial(0, COEF.length - 1, COEF.reverse())
function(x) {return POLYNOMIAL.evalOf(x);}
_.reduce(findRootsNumerically(FNX, XRANGE), function(intervals, root) {
var last = _.last(intervals)
return _.initial(intervals).concat([[last[0], root], [root, last[1]]]);
}, [XRANGE])
_.filter(FNX_INTERVALS, function(intv) {
return FNX(intv[0] + (intv[1] - intv[0]) / 2) > 0;
})
_.sortBy(FNX_INTERVALS_POS, function(intv) {
return intv[0] - intv[1];
})[0]
_.filter(FNX_INTERVALS, function(intv) {
return FNX(intv[0] + (intv[1] - intv[0]) / 2) < 0;
})
_.sortBy(FNX_INTERVALS_NEG, function(intv) {
return intv[0] - intv[1];
})[0]
Move the orange window to select part of the function.
graph.slidingWindow.getX()
var correct = _.reduce(_.range(guess, guess + 1, 0.02), function(correct, x) {
return correct && PREDICATE(x);
}, true);
if (!graph.moved && !correct) {
return ""
}
return correct;
graph.slidingWindow.moveTo(guess, 0);
initAutoscaledGraph([XRANGE, YRANGE]);
addMouseLayer();
plot(FNX, XRANGE, {
stroke: BLUE,
strokeWidth: 3
});
graph.moved = false;
// start the selection at the first zero of f(x) which is
// guaranteed to be wrong but not give info about the right answer
var startX = FNX_INTERVALS[0][1] - 0.5;
graph.slidingWindow = addRectGraph({
x: startX,
y: YRANGE[0],
width: 1,
height: YRANGE[1] - YRANGE[0],
normalStyle: {
area: { "fill-opacity": 0.2 },
edges: { "stroke-width": 0 }
},
hoverStyle: {
area: { "fill-opacity": 0.3 }
},
fixed: {
points: [true, true, true, true],
edges: [true, true, true, true]
},
constraints: {
constrainX: false,
constrainY: true,
xmin: XRANGE[0],
xmax: XRANGE[1]
},
onMove: function() {
graph.moved = true;
}
});
f(x) = POLYNOMIAL.text()
function(x) { return FNX(x) > 0; }
A function f(x)
is plotted below.
Highlight an interval where f(x) > 0
.
The function f(x)
is greater than 0
wherever it's positive.
The interval
where f(x)
is positive
is
highlighted above.
The intervals
where f(x)
is positive
are
highlighted above.
plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], {
stroke: ORANGE,
strokeWidth: 16,
opacity: 0.7
}).attr("clip-rect",
scalePoint([range[0][0], range[1][1]])[0] + "," +
scalePoint([range[0][0], range[1][1]])[1] + "," +
scaleVector([range[0][1] - range[0][0], range[1][1]])[0] + "," +
scaleVector([range[0][1] - range[0][0], range[1][1]])[1]
);
Select any part of the function that's highlighted.
graph.slidingWindow.moveTo(
(SOLUTION_INTERVAL_POS[1] - SOLUTION_INTERVAL_POS[0]) / 2 +
SOLUTION_INTERVAL_POS[0] - 0.5, 0);
function(x) { return FNX(x) < 0; }
A function f(x)
is plotted below.
Highlight an interval where f(x) < 0
.
The function f(x)
is less than 0
wherever it's negative.
The interval
where f(x)
is negative
is
highlighted above.
The intervals
where f(x)
is negative
are
highlighted above.
plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], {
stroke: ORANGE,
strokeWidth: 16,
opacity: 0.7
}).attr("clip-rect",
scalePoint([range[0][0], 0])[0] + "," +
scalePoint([range[0][0], 0])[1] + "," +
scaleVector([range[0][1] - range[0][0], -range[1][0]])[0] + "," +
scaleVector([range[0][1] - range[0][0], -range[1][0]])[1]
);
Select any part of the function that's highlighted.
graph.slidingWindow.moveTo(
(SOLUTION_INTERVAL_NEG[1] - SOLUTION_INTERVAL_NEG[0]) / 2 +
SOLUTION_INTERVAL_NEG[0] - 0.5, 0);