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);}
function(x) {return POLYNOMIAL.derivative().evalOf(x);}
_.reduce(findRootsNumerically(FNX, XRANGE), function(intervals, root) {
var last = _.last(intervals)
return _.initial(intervals).concat([[last[0], root], [root, last[1]]]);
}, [XRANGE])
_.reduce(findRootsNumerically(DDX, 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;
})
_.filter(FNX_INTERVALS, function(intv) {
return FNX(intv[0] + (intv[1] - intv[0]) / 2) < 0;
})
_.filter(DDX_INTERVALS, function(intv) {
return DDX(intv[0] + (intv[1] - intv[0]) / 2) > 0;
})
_.filter(DDX_INTERVALS, function(intv) {
return DDX(intv[0] + (intv[1] - intv[0]) / 2) < 0;
})
_.reduce(
sortNumbers(findRootsNumerically(FNX, XRANGE).concat(findRootsNumerically(DDX, XRANGE))),
function(intervals, root) {
var last = _.last(intervals)
return _.initial(intervals).concat([[last[0], root], [root, last[1]]]);
},
[XRANGE]
)
_.filter(COMBINED_INTERVALS, function(intv) {
return PREDICATE(intv[0] + (intv[1] - intv[0]) / 2);
})
_.sortBy(SOLUTION_INTERVALS, 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 = DDX_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 DDX(x) > 0; }
A function \blue{f(x)}
is plotted below.
Highlight an interval where \blue{f}
is increasing.
\blue{f(x)}
is increasing in an interval if in that interval,
when x
is increasing, \blue{f(x)}
is increasing.
The interval
where \blue{f}
is increasing
is
highlighted above.
The intervals
where \blue{f}
is increasing
are
highlighted above.
_.each(DDX_INTERVALS_POS, function(interval) {
plot(FNX, interval, {
stroke: ORANGE,
strokeWidth: 16,
opacity: 0.7
});
});
Select any part of the function that is highlighted.
graph.slidingWindow.moveTo(
(SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 +
SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return DDX(x) < 0; }
A function \blue{f(x)}
is plotted below.
Highlight an interval where \blue{f}
is decreasing.
\blue{f(x)}
is decreasing in an interval if in that interval,
when x
is increasing, \blue{f(x)}
is decreasing.
The interval
where \blue{f}
is decreasing
is
highlighted above.
The intervals
where \blue{f}
is decreasing
are
highlighted above.
_.each(DDX_INTERVALS_NEG, function(interval) {
plot(FNX, interval, {
stroke: ORANGE,
strokeWidth: 16,
opacity: 0.7
});
});
Select any part of the function that is highlighted.
graph.slidingWindow.moveTo(
(SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 +
SOLUTION_INTERVAL[0] - 0.5, 0);