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>Introduction to Quadratic Equations — 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: 61, title: 'Introduction to Quadratic Equations', minutes: 9, next: '../ch62/' };
const CA = COL.int, CB = COL.whole, CC = COL.nat, PAR = COL.irr, 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 verdict tag after a line: ✓/✗ and a word.
const verdict = (p, ok, str, x, y, t0) => text(p, (ok ? '✓ ' : '✗ ') + str, x, y, t0, { size: 30, fill: ok ? HIT : COL.bad, weight: 600 });
/* ---------- beats ---------- */
const BEATS = [
['intro', 'Quadratics', (m, D) => {
const g = G(scene, { o: 0, y: 24 });
T(g, 'Unit 12, Chapter 61', { x: 800, y: 300, size: 28, fill: COL.dim, anchor: 'middle' });
T(g, 'Introduction to', { x: 800, y: 400, size: 80, weight: 600, anchor: 'middle' });
T(g, 'Quadratic Equations', { x: 800, y: 490, size: 80, weight: 600, anchor: 'middle' });
tw(g, { o: 1, y: 0 }, .2, 1.1, out);
const r = mline(scene, ['ax', E(2), ' + bx + c = 0'], 800, 630, m('sub'), COL.dim, 54);
tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8);
}],
['form', 'Standard form', (m) => {
const p = panel(0);
const t = tokens(p, [{ t: ['a'], fill: CA }, ['x', E(2), ' + '], { t: 'b', fill: CB }, 'x + ', { t: 'c', fill: CC }], { x: 800, y: 170, size: 80, anchor: 'middle', o: 0 });
t.forEach(e => show(e, m('std')));
text(p, 'a ≠ 0', 1180, 160, m('std', 1), { size: 34, fill: CA, weight: 600 });
mline(p, ['ax', E(2), ' + bx + c = 0'], 450, 330, m('eq'), COL.chalk, 46);
text(p, 'quadratic equation', 450, 380, m('eq'), { size: 26, fill: COL.dim, anchor: 'middle' });
mline(p, ['y = ax', E(2), ' + bx + c'], 1150, 330, m('fn'), COL.chalk, 46);
text(p, 'quadratic function', 1150, 380, m('fn'), { size: 26, fill: COL.dim, anchor: 'middle' });
const e = tokens(p, ['y = ', { t: '3', fill: CA }, ['x', E(2), ' '], { t: '− 5', fill: CB }, 'x ', { t: '+ 7', fill: CC }], { x: 800, y: 540, size: 64, anchor: 'middle', o: 0 });
e.forEach(x => show(x, m('ex')));
[['a = 3', CA], ['b = −5', CB], ['c = 7', CC]].forEach(([s, c], i) => mline(p, s, 580 + i * 220, 640, m('abc', i * 1), c, 44));
const ring = put(mk('rect', { x: e[3]._px - e[3]._w / 2 - 6, y: 488, width: e[3]._w + 12, height: 72, rx: 12, fill: 'none', stroke: CB, 'stroke-width': 3 }, p), { o: 0 });
show(ring, m('sign'));
text(p, 'the sign belongs to the number', 800, 740, m('sign', .5), { size: 30, fill: CB, anchor: 'middle', weight: 600 });
}],
['which', 'Quadratic or not?', (m) => {
const p = panel(0);
[[['y = 4x', E(2), ' − x + ', F(1, 3)], true, 'highest power 2: quadratic', 'q1'],
[['y = 12x + 5'], false, 'highest power 1: linear', 'q2'],
[['y = 9x', E(3), ' + x', E(2), ' − x + 8'], false, 'highest power 3: cubic', 'q3'],
[['y = −', F(4, 3), 'x', E(2)], true, 'b = 0 and c = 0 are fine: quadratic', 'q4']].forEach(([parts, ok, why, k], i) => {
const y = 200 + i * 160;
mline(p, parts, 200, y, m(k), COL.chalk, 52, 'start');
verdict(p, ok, why, 820, y - 10, m(k, 1.2));
});
}],
['q1', 'Quick check', () => { panel(0); }, { ask: done => quiz({ x: 260, y: 240, w: 1080, cls: 'side' }, [{
id: 'c-abc', prompt: ['Find a, b, and c for ', $m('y = −', F(1, 3), 'x', E(2), ' + 4'), '.'],
build: blanks([{ parts: ['a = ', { box: '-1/3' }, ', b = ', { box: '0' }, ', c = ', { box: '4' }], why: 'There is no x term, so b = 0.', hint: 'The sign belongs to the number. Which term is missing?' }]),
}], done) }],
['sol', 'Checking a solution', (m) => {
const p = panel(0), X = 220;
mline(p, ['x', E(2), ' − 5x + 6 = 0, x = 2?'], X, 130, m('ex'), COL.chalk, 46, 'start');
const r = tokens(p, [{ t: '(2)', fill: CA }, [E(2), ' − 5'], { t: '(2)', fill: CA }, ' + 6'], { x: X, y: 230, size: 50, o: 0 });
r.forEach(e => show(e, m('sub')));
[0, 2].forEach((k, i) => { put(r[k], { y: 120 }); tw(r[k], { y: 230 }, m('sub', i * .3), .6, back); });
mline(p, '= 4 − 10 + 6 = 0', X, 320, m('ans'), COL.chalk, 50, 'start');
verdict(p, true, '0 = 0: x = 2 is a solution', 800, 310, m('ans', 1.4));
mline(p, ['−2x', E(2), ' = 7x + 10, x = −3?'], X, 470, m('ex2'), COL.chalk, 46, 'start');
mline(p, ['left: −2(−3)', E(2), ' = −2 · 9 = −18'], X, 570, m('l'), CB, 46, 'start');
mline(p, 'right: 7(−3) + 10 = −11', X, 650, m('r'), CC, 46, 'start');
verdict(p, false, '−18 ≠ −11: not a solution', 800, 740, m('no'));
}],
['graph', 'Parabolas', (m) => {
const p = panel(0);
const A = plane(p, { cx: 430, cy: 450, u: 50, x0: -4, x1: 4, y0: -5, y1: 5, t0: .2, labels: false });
const B = plane(p, { cx: 1170, cy: 450, u: 50, x0: -4, x1: 4, y0: -5, y1: 5, t0: .3, labels: false });
const gB = G(p);
A.layer = p; B.layer = gB;
A.fn(x => .5 * x * x - 2, -3.3, 3.3, PAR, m('up'));
mline(p, ['a > 0: opens up'], 430, 130, m('up'), PAR, 40);
B.fn(x => -.5 * x * x + 3, -3.6, 3.6, COL.nat, m('down'));
hide(mline(p, ['a < 0: opens down'], 1170, 130, m('down'), COL.nat, 40), m('none'), .4);
A.dot(0, -2, COL.task, m('vertex'), { label: 'vertex', dx: 16, dy: 30 });
B.dot(0, 3, COL.task, m('vertex', .3), { label: 'vertex', dx: 16, dy: -16 });
[-2, 2].forEach((x, i) => A.dot(x, 0, HIT, m('roots', 1 + i * .3)));
text(p, 'x-intercepts = solutions', 430, 800, m('roots', 1.6), { size: 28, fill: HIT, anchor: 'middle', weight: 600 });
hide(gB, m('none'), .4);
B.fn(x => .4 * x * x + 1, -3.6, 3.6, COL.whole, m('none', .3), { into: p });
text(p, 'never crosses the x-axis: no real solution', 1170, 800, m('none', .8), { size: 26, fill: COL.whole, anchor: 'middle', weight: 600 });
}],
['q2', 'Quick check', () => {
const p = panel(0);
S.g = [x => .25 * x * x * x - 1.5 * x, x => -.6 * x * x + 2.5, x => .8 * x - .5].map((f, i) => {
const P = plane(p, { cx: 300 + i * 500, cy: 400, u: 40, x0: -4, x1: 4, y0: -4, y1: 4, t0: .2, labels: false });
P.layer = p;
P.fn(f, -4, 4, COL.chalk, .4 + i * .2, { dur: .8 });
text(p, 'ABC'[i], 300 + i * 500, 180, .2, { size: 32, anchor: 'middle', weight: 700 });
return { P, box: [300 + i * 500 - 200, 200, 400, 400] };
});
}, { ask: done => quiz(BAND, [{
id: 'c-par', prompt: ['Click the graph of a quadratic function.'],
build: pickEls(S.g.map((g, i) => ({ el: null, box: g.box, label: 'Graph ' + 'ABC'[i] })), 1, 'B is a parabola opening downward: a is negative.',
i => i === 0 ? 'A turns twice: that’s a cubic shape, not a parabola.' : 'C is a straight line: a linear function.'),
}], done) }],
['wrap', 'Summary', (m) => {
const p = panel(0);
[['Quadratic: ax² + bx + c, a ≠ 0, nothing higher than x².', 'w1', CA], ['A solution makes the equation true: substitute and check.', 'w2', CB],
['The graph is a parabola: up if a > 0, down if a < 0.', 'w3', PAR], ['x-intercepts are the solutions; there may be none.', 'w4', HIT]].forEach(([str, mark, c], i) => {
const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
mk('circle', { cx: 170, cy: -12, r: 26, fill: c }, g);
T(g, String(i + 1), { x: 170, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
T(g, str, { x: 230, size: 32, weight: 600 });
tw(g, { o: 1, x: 0 }, m(mark), .6);
});
}],
['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
id: 'p-quad', prompt: ['Is it a quadratic equation?'],
build: grid(QUADQ, [['y', 'Quadratic', HIT, 'Y'], ['n', 'Not quadratic', COL.bad, 'N']], { multi: false, text: true }),
}], done, 'Chapter practice 1 of 3') }],
['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
id: 'p-abc', prompt: ['Find a, b, and c.'], build: blanks([
{ parts: ['y = 8x', E(2), ' − 2x + 9: a = ', { box: '8' }, ', b = ', { box: '-2' }, ', c = ', { box: '9' }], why: 'The sign belongs to the number: b = −2.' },
{ parts: ['y = x', E(2), ' − 7: a = ', { box: '1' }, ', b = ', { box: '0' }, ', c = ', { box: '-7' }], why: 'x² is 1x²; there is no x term.' },
{ parts: ['y = 5 − 3x', E(2), ' + x: a = ', { box: '-3' }, ', b = ', { box: '1' }, ', c = ', { box: '5' }], why: 'In order: −3x² + x + 5.', hint: 'Rewrite in standard order first.' },
]),
}], done, 'Chapter practice 2 of 3') }],
['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
id: 'p-sol', prompt: ['Is the value a solution?'],
build: grid(SOLQ, [['y', 'Solution', HIT, 'Y'], ['n', 'Not a solution', COL.bad, 'N']], { multi: false, text: true }),
}], done, 'Chapter practice 3 of 3') }],
['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
/* ---------- chapter practice data ---------- */
const QUADQ = [
{ parts: [$m('y = x', E(2), ' + 3x − 15')], ans: ['y'], why: 'Highest power 2.' },
{ parts: [$m('y = 6x', E(5), ' − 0.7x + π')], ans: ['n'], why: 'Highest power 5.' },
{ parts: [$m('y = 9x')], ans: ['n'], why: 'Linear: highest power 1.' },
{ parts: [$m('y = −', F(4, 3), 'x', E(2))], ans: ['y'], why: 'a = −4/3; b = c = 0 is fine.' },
{ parts: [$m('x', E(2), ' = 16')], ans: ['y'], why: 'x² − 16 = 0.' },
{ parts: [$m('y = 2x', E(3), ' − x', E(2))], ans: ['n'], why: 'Highest power 3.' },
];
const SOLQ = [
{ parts: [$m('x', E(2), ' − 5x + 6 = 0'), ', x = 3'], ans: ['y'], why: '9 − 15 + 6 = 0.' },
{ parts: [$m('x', E(2), ' + 4x = 5'), ', x = 1'], ans: ['y'], why: '1 + 4 = 5.' },
{ parts: [$m('x', E(2), ' = 2x + 8'), ', x = −4'], ans: ['n'], why: 'Left 16, right 0.' },
{ parts: [$m('2x', E(2), ' − 7x + 3 = 0'), ', x = ', $m(F(1, 2))], ans: ['y'], why: '½ − 3½ + 3 = 0.' },
{ parts: [$m('x', E(2), ' + 9 = 0'), ', x = 3'], ans: ['n'], why: '9 + 9 = 18. This equation has no real solution at all.' },
];
boot();
</script>
</body>
</html>