An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Graphing Quadratic Functions — Elementary Algebra</title>
<link rel="stylesheet" href="../lib/engine.css">
<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
</head>
<body>
<script src="../lib/engine.js"></script>
<script src="../lib/math.js"></script>
<script src="audio/en/timings.js"></script>
<script>
'use strict';
const CHAPTER = { number: 67, title: 'Graphing Quadratic Functions', minutes: 11, next: '../ch68/' };
const PAR = COL.irr, VTX = COL.task, AXC = COL.rat, YI = COL.whole, XI = COL.nat, HIT = COL.good;
/* ---------- chapter drawing helpers ---------- */
const mline = (p, parts, x, y, t0, fill = COL.chalk, size = 48, anchor = 'middle') => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
// A live curve on plane P for y = f(x) whose shape is redrawn by set(f).
function liveCurve(p, P, color) {
const l = path(p, '', { stroke: color, 'stroke-width': 4 });
return { l, set(f) {
let d = '', pen = false;
for (let i = 0; i <= 160; i++) { const x = P.x0 + (P.x1 - P.x0) * i / 160, y = f(x); if (y >= P.y0 - .3 && y <= P.y1 + .3) { d += `${pen ? 'L' : 'M'}${P.PX(x).toFixed(1)} ${P.PY(y).toFixed(1)}`; pen = true; } else pen = false; }
l.setAttribute('d', d);
} };
}
const axisLine = (p, P, x, t0, color = AXC) => { const l = path(p, `M${P.PX(x)} ${P.PY(P.y1 + .3)}V${P.PY(P.y0 - .3)}`, { stroke: color, 'stroke-width': 3, 'stroke-dasharray': '10 8' }, { o: 0 }); show(l, t0); return l; };
const two = (u, v) => ([p, q]) => Math.abs(p - u) + Math.abs(q - v) < 1e-9 || Math.abs(p - v) + Math.abs(q - u) < 1e-9;
/* ---------- beats ---------- */
const BEATS = [
['intro', 'Parabolas', (m, D) => {
const g = G(scene, { o: 0, y: 24 });
T(g, 'Unit 13, Chapter 67', { x: 800, y: 300, size: 28, fill: COL.dim, anchor: 'middle' });
T(g, 'Graphing Quadratic', { x: 800, y: 400, size: 84, weight: 600, anchor: 'middle' });
T(g, 'Functions', { x: 800, y: 495, size: 84, weight: 600, anchor: 'middle' });
tw(g, { o: 1, y: 0 }, .2, 1.1, out);
const r = mline(scene, ['y = ax', E(2), ' + bx + c'], 800, 630, m('sub'), COL.dim, 54);
tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8);
}],
['dir', 'Direction and width', (m) => {
const p = panel(0), P = plane(p, { cx: 1050, cy: 450, u: 52, x0: -5, x1: 5, y0: -6, y1: 6, t0: .2, labels: false });
const C = liveCurve(p, P, PAR), aT = T(p, '', { x: 200, y: 300, size: 64, font: MATH, fill: PAR, o: 0 }), dT = T(p, '', { x: 200, y: 400, size: 36, weight: 700, o: 0 });
mline(p, ['y = ax', E(2)], 200, 180, .2, COL.chalk, 56, 'start');
[aT, dT].forEach(e => show(e, .4));
const set = a => { C.set(x => a * x * x); C.l.setAttribute('stroke', a >= 0 ? PAR : XI); aT.textContent = `a = ${num(Math.round(a * 10) / 10)}`; dT.textContent = a > 0 ? 'opens upward' : a < 0 ? 'opens downward' : 'a line, not a parabola'; dT.setAttribute('fill', a >= 0 ? PAR : XI); };
set(1);
prog(q => set(1 - .7 * q), m('shrink'), 2.3);
prog(q => set(.3 - 1.3 * q), m('flip', -.4), 2.4);
prog(q => set(-1 - 2 * q), m('big'), 1.6);
prog(q => set(-3 + 6 * q), m('big', 1.8), 1.6);
text(p, 'sign of a: direction', 200, 560, m('rule'), { size: 30, fill: VTX, weight: 600 });
text(p, 'size of a: width', 200, 610, m('rule', .6), { size: 30, fill: VTX, weight: 600 });
}],
['vertex', 'The vertex', (m) => {
const p = panel(0), P = plane(p, { cx: 1250, cy: 190, u: 30, x0: -8, x1: 3, y0: -17, y1: 4, t0: .2, labels: false });
P.layer = p;
const r = G(p, { o: 0 });
mk('rect', { x: 140, y: 110, width: 560, height: 120, rx: 18, fill: 'none', stroke: VTX, 'stroke-width': 3 }, r);
M(r, ['vertex: x = −', F('b', '2a')], { x: 420, y: 190, size: 52, fill: VTX });
show(r, m('x'));
mline(p, ['y = x', E(2), ' + 6x − 7'], 160, 320, m('ex'), COL.chalk, 48, 'start');
P.fn(x => x * x + 6 * x - 7, -8, 2.2, PAR, m('ex', .3));
mline(p, ['x = −', F(6, '2 · 1'), ' = −3'], 160, 430, m('calc'), COL.chalk, 46, 'start');
mline(p, ['y = (−3)', E(2), ' + 6(−3) − 7 = −16'], 160, 540, m('y'), COL.chalk, 46, 'start');
P.dot(-3, -16, VTX, m('pt'), { label: '(−3, −16)', dx: -16, dy: 8, anchor: 'end' });
mline(p, 'vertex (−3, −16)', 160, 650, m('pt'), VTX, 48, 'start');
text(p, 'opens up: minimum value −16', 160, 740, m('min'), { size: 30, fill: HIT, weight: 600 });
}],
['q1', 'Quick check', () => {
const p = panel(0), P = S.P = plane(p, { cx: 1100, cy: 470, u: 50, x0: -3, x1: 6, y0: -6, y1: 6, t0: .2 });
P.layer = p;
P.fn(x => x * x - 4 * x + 1, -1, 5, PAR, .3);
mline(p, ['y = x', E(2), ' − 4x + 1'], 200, 200, .2, PAR, 48, 'start');
}, { ask: done => quiz({ x: 120, y: 280, w: 560, cls: 'side' }, [{
id: 'c-vtx', prompt: ['Click the vertex.'],
build: pickPoint(S.P, [2, -3], 'x = −(−4)/2 = 2 and y = 4 − 8 + 1 = −3.', (x, y) => x !== 2 ? 'Find x first: −b/(2a) = 4/2 = 2.' : 'x = 2 is right; substitute it: 4 − 8 + 1.'),
}], done) }],
['vform', 'Vertex form', (m) => {
const p = panel(0), P = plane(p, { cx: 1000, cy: 640, u: 40, x0: -9, x1: 7, y0: -2, y1: 10, t0: .2, labels: false });
P.layer = p;
const r = G(p, { o: 0 });
mk('rect', { x: 120, y: 100, width: 680, height: 120, rx: 18, fill: 'none', stroke: VTX, 'stroke-width': 3 }, r);
M(r, ['y = a(x − h)', E(2), ' + k'], { x: 460, y: 180, size: 56, fill: VTX });
show(r, .2);
text(p, 'vertex (h, k)', 1180, 160, m('hk'), { size: 36, fill: VTX, weight: 700 });
const C = liveCurve(p, P, PAR), dot = put(mk('circle', { r: 11, fill: VTX }, p), { x: P.PX(0), y: P.PY(0), o: 0 });
let h = 0, k = 0;
const set = () => { C.set(x => (x - h) ** 2 + k); put(dot, { x: P.PX(h), y: P.PY(k) }); };
put(C.l, { o: 0 }); show(C.l, m('slide')); show(dot, m('slide'));
set();
prog(q => { h = 3 * q; set(); }, m('h'), 2);
prog(q => { k = 8 * q; set(); }, m('k'), 1.8);
mline(p, ['y = (x − 3)', E(2)], 160, 330, m('h'), COL.chalk, 46, 'start');
text(p, '3 to the right', 520, 322, m('h', .5), { size: 26, fill: VTX, weight: 600 });
mline(p, ['y = (x − 3)', E(2), ' + 8'], 160, 430, m('k'), COL.chalk, 46, 'start');
text(p, '8 up', 600, 422, m('k', .5), { size: 26, fill: VTX, weight: 600 });
mline(p, 'vertex (3, 8)', 160, 530, m('ans'), VTX, 46, 'start');
mline(p, ['y = −', F(1, 2), '(x + 7)', E(2), ' + ', F(3, 4)], 160, 660, m('sign'), COL.chalk, 44, 'start');
mline(p, ['vertex (−7, ', F(3, 4), ')'], 160, 770, m('sign', 2.5), XI, 44, 'start');
}],
['convert', 'From standard to vertex form', (m) => {
const p = panel(0), X = 220;
mline(p, ['y = x', E(2), ' + 10x − 7'], X, 150, m('ex'), COL.chalk, 52, 'start');
text(p, '(10 ÷ 2)² = 25', 1050, 250, m('half'), { size: 30, fill: VTX, weight: 600 });
const row = tokens(p, ['y = ', { t: ['x', E(2), ' + 10x + 25'], fill: PAR }, { t: ' − 25', fill: VTX }, ' − 7'], { x: X, y: 270, size: 52, o: 0 });
row.forEach(e => show(e, m('add')));
mline(p, ['y = (x + 5)', E(2), ' − 32'], X, 400, m('group'), COL.chalk, 52, 'start');
text(p, '−25 − 7 = −32', 1050, 390, m('ans'), { size: 30, fill: VTX, weight: 600 });
mline(p, 'vertex (−5, −32)', X, 530, m('v'), HIT, 54, 'start');
}],
['q2', 'Quick check', () => { panel(0); }, { ask: done => quiz({ x: 260, y: 240, w: 1080, cls: 'side' }, [{
id: 'c-vf', prompt: ['Write ', $m('y = x', E(2), ' − 6x + 5'), ' in vertex form.'],
build: blanks([{ parts: ['y = (x − ', { box: '3' }, ')', E(2), ' + ', { box: '-4' }], why: 'Add and subtract 9: (x − 3)² − 9 + 5 = (x − 3)² − 4.', hint: 'Half of −6 is −3, and (−3)² = 9. Add and subtract 9.' }]),
}], done) }],
['axis', 'Axis of symmetry', (m) => {
const p = panel(0), P = plane(p, { cx: 1050, cy: 600, u: 46, x0: -6, x1: 4, y0: -2, y1: 10, t0: .2, labels: false });
P.layer = p;
const f = x => -.5 * (x - 1) * (x + 8) / 1.2;
P.fn(f, -6, 3.2, PAR, .3);
axisLine(p, P, -3.5, m('line'));
mline(p, ['x = −', F('b', '2a')], 300, 260, m('line'), AXC, 52);
[[-1, -6], [0, -7]].forEach(([a, b], i) => {
const t = m('mirror', i * 1.4);
P.dot(a, f(a), YI, t); P.dot(b, f(b), YI, t + .6);
const l = path(p, `M${P.PX(a)} ${P.PY(f(a))}H${P.PX(b)}`, { stroke: YI, 'stroke-width': 2.5, 'stroke-dasharray': '5 6' }, { o: 0 });
show(l, t + .3);
});
text(p, 'same height, same distance', 300, 400, m('mirror', 1), { size: 30, fill: YI, anchor: 'middle', weight: 600 });
text(p, 'one point gives you its mirror image', 300, 470, m('use'), { size: 28, fill: COL.dim, anchor: 'middle' });
}],
['intercepts', 'Intercepts', (m) => {
const p = panel(0), X = 200;
mline(p, ['y-intercept: x = 0 → y = c'], X, 220, m('yint'), YI, 46, 'start');
mline(p, ['x-intercepts: y = 0 → ax', E(2), ' + bx + c = 0'], X, 360, m('xint'), XI, 46, 'start');
mline(p, ['b', E(2), ' − 4ac: > 0 two, = 0 one, < 0 none'], X, 500, m('count'), VTX, 44, 'start');
}],
['graph', 'Graphing step by step', (m) => {
const p = panel(0), P = S.P = plane(p, { cx: 1050, cy: 380, u: 44, x0: -3, x1: 7, y0: -10, y1: 4, t0: .2 });
P.layer = p;
const X = 120;
mline(p, ['y = x', E(2), ' − 4x − 5'], X, 130, .2, COL.chalk, 48, 'start');
text(p, 'a = 1 > 0: opens up', X, 220, m('dir'), { size: 28, fill: PAR, weight: 600 });
text(p, 'vertex (2, −9)', X, 290, m('v'), { size: 28, fill: VTX, weight: 600 });
P.dot(2, -9, VTX, m('v', 3), { label: '(2, −9)', dx: 16, dy: 30 });
text(p, 'axis x = 2', X, 360, m('ax'), { size: 28, fill: AXC, weight: 600 });
axisLine(p, P, 2, m('ax'));
text(p, 'y-intercept (0, −5)', X, 430, m('yi'), { size: 28, fill: YI, weight: 600 });
P.dot(0, -5, YI, m('yi', .5));
text(p, 'mirror (4, −5)', X, 500, m('m'), { size: 28, fill: YI, weight: 600 });
P.dot(4, -5, YI, m('m', .5));
draw(path(p, `M${P.PX(0)} ${P.PY(-5)}H${P.PX(4)}`, { stroke: YI, 'stroke-width': 2.5, 'stroke-dasharray': '5 6' }, { d: 0 }), m('m', .3), .6);
text(p, 'x-intercepts −1 and 5', X, 570, m('xi'), { size: 28, fill: XI, weight: 600 });
P.dot(-1, 0, XI, m('xi', 3)); P.dot(5, 0, XI, m('xi', 3.4));
P.fn(x => x * x - 4 * x - 5, -2.2, 6.2, PAR, m('draw'), { dur: 1.6 });
}],
['q3', 'Quick check', () => {
const p = panel(0), P = S.P = plane(p, { cx: 1050, cy: 520, u: 50, x0: -4, x1: 5, y0: -4, y1: 6, t0: .2 });
P.layer = p;
P.fn(x => -x * x + 2 * x + 3, -1.8, 3.8, PAR, .3);
mline(p, ['y = −x', E(2), ' + 2x + 3'], 160, 200, .2, PAR, 48, 'start');
}, { ask: done => quiz({ x: 100, y: 280, w: 560, cls: 'side' }, [{
id: 'c-vtx2', prompt: ['Click the vertex.'],
build: pickPoint(S.P, [1, 4], 'x = −2/(2 · (−1)) = 1 and y = −1 + 2 + 3 = 4: a maximum.', (x) => x !== 1 ? 'x = −b/(2a) = −2/(−2) = 1.' : 'Substitute x = 1: −1 + 2 + 3.'),
}], done) }],
['wrap', 'Summary', (m) => {
const p = panel(0);
[['a > 0: up, minimum. a < 0: down, maximum.', 'w1', PAR], ['Vertex: x = −b/(2a); vertex form gives (h, k).', 'w2', VTX],
['The axis of symmetry passes through the vertex.', 'w3', AXC], ['y-intercept c; x-intercepts solve the equation.', 'w4', XI]].forEach(([str, mark, c], i) => {
const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
mk('circle', { cx: 200, cy: -12, r: 26, fill: c }, g);
T(g, String(i + 1), { x: 200, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
T(g, str, { x: 260, size: 34, weight: 600 });
tw(g, { o: 1, x: 0 }, m(mark), .6);
});
}],
['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [
{ id: 'p-dir', prompt: [$m('y = 2x', E(2), ' + 8x − 10'), ': does it have a maximum or a minimum?'], build: choice([['maximum'], ['minimum']], 1, 'a = 2 > 0: opens up, so the vertex is a minimum.', ['a = 2 is positive, so the parabola opens up.', null]) },
{ id: 'p-desc', prompt: ['Describe ', $m('y = x', E(2), ' − 6x + 8'), '.'], build: blanks([
{ parts: ['vertex (', { box: '3' }, ', ', { box: '-1' }, ')'], why: 'x = 6/2 = 3, y = 9 − 18 + 8 = −1.' },
{ parts: ['axis of symmetry x = ', { box: '3' }], why: 'Through the vertex.' },
{ parts: ['discriminant ', { box: '4' }], why: '36 − 32 = 4.' },
{ parts: ['y-intercept (0, ', { box: '8' }, ')'], why: 'y = c when x = 0.' },
{ parts: ['x-intercepts ', { box: '2' }, ' and ', { box: '4' }], test: two(2, 4), why: '(x − 2)(x − 4) = 0.' },
]) },
], done, 'Chapter practice 1 of 3, question') }],
['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
id: 'p-vtx', prompt: ['Find each vertex.'], build: blanks([
{ parts: ['y = −x', E(2), ' + 2x + 3: (', { box: '1' }, ', ', { box: '4' }, ')'], why: 'x = 1, y = −1 + 2 + 3 = 4.' },
{ parts: ['y = 2x', E(2), ' + 8x − 10: (', { box: '-2' }, ', ', { box: '-18' }, ')'], why: 'x = −8/4 = −2, y = 8 − 16 − 10.' },
{ parts: ['y = 4x', E(2), ' + 12x − 7: (', { box: '-3/2' }, ', ', { box: '-16' }, ')'], why: '4(x + 3/2)² − 16.', hint: 'x = −12/8 = −3/2.' },
{ parts: ['y = 3(x − 1)', E(2), ' + 4: (', { box: '1' }, ', ', { box: '4' }, ')'], why: 'Vertex form: h = 1, k = 4.' },
]),
}], done, 'Chapter practice 2 of 3') }],
['final3', 'Chapter practice', () => {
const p = panel(0), P = S.F = plane(p, { cx: 1080, cy: 330, u: 40, x0: -5, x1: 7, y0: -10, y1: 4, t0: .2 });
P.layer = p;
P.fn(x => x * x - 2 * x - 8, -3.2, 5.2, PAR, .3);
mline(p, ['y = x', E(2), ' − 2x − 8'], 160, 140, .2, PAR, 46, 'start');
}, { ask: done => quiz({ x: 100, y: 200, w: 560, cls: 'side' }, [
{ id: 'p-pv', prompt: ['Click the vertex.'], build: pickPoint(S.F, [1, -9], 'x = 1, y = 1 − 2 − 8 = −9.', () => 'x = −b/(2a) = 2/2 = 1.', () => S.F.dot(1, -9, VTX, 0, { run: fx, into: S.F.layer })) },
{ id: 'p-py', prompt: ['Click the y-intercept.'], build: pickPoint(S.F, [0, -8], 'x = 0 gives y = −8.', () => 'The y-intercept is on the y-axis, where x = 0.', () => S.F.dot(0, -8, YI, 0, { run: fx, into: S.F.layer })) },
{ id: 'p-px', prompt: ['Click one of the x-intercepts.'], build: pickPoint(S.F, [4, 0], (x) => `(x − 4)(x + 2) = 0: x = ${num(x)} works.`, () => 'An x-intercept has y = 0. Factor: (x − 4)(x + 2).', null, (x, y) => y === 0 && (x === 4 || x === -2)) },
], done, 'Chapter practice 3 of 3, point') }],
['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
boot();
</script>
</body>
</html>