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>Dividing Decimals — Elementary Mathematics</title><link rel="stylesheet" href="../lib/engine.css"><link rel="expect" href="#bar" blocking="render"><style>.screen .blanks .math{font-size:38px}.side .keys{font-size:20px}</style></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:10,title:'Dividing Decimals',minutes:10,language:'en', next: '../ch11/' };
const ddText=(p,s,x,y,t=0,size=30,col=COL.chalk,anchor='start')=>{const e=T(p,s,{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const ddMath=(p,s,x,y,t=0,size=48,col=COL.chalk,anchor='middle')=>{const e=M(p,Array.isArray(s)?s:[s],{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const ddTitle=(p,s,sub='')=>{ddText(p,s,100,115,.1,43);if(sub)ddText(p,sub,100,165,.15,27,COL.dim);};
function ddBar(p,{x=260,y=360,w=1080,h=130,n=6,total='1.8',group='0.3',t=0}={}){
const g=G(p,{x,y,o:0});g.dataset.groups=String(n);g.dataset.total=total;g.dataset.divisor=group;show(g,t);
for(let i=0;i<n;i++)mk('rect',{x:i*w/n,y:0,width:w/n,height:h,fill:COL.whole,'fill-opacity':i%2?.22:.38,stroke:COL.whole,'stroke-width':2},g);
path(g,`M0 -25V-38H${w}V-25`,{stroke:COL.chalk,'stroke-width':2});
const a=T(g,total,{x:w/2,y:-58,size:45,anchor:'middle'}),b=T(g,group,{x:w/(2*n),y:h+48,size:36,fill:COL.task,anchor:'middle'});
return {g,a,b,w,h,n};
}
function ddScale(p,digits,label,{x=520,y=330,step=125,shift=1,t=0,tm=1}={}){
const g=G(p,{x,y,o:0});show(g,t);ddText(g,label,-240,10,t,29,COL.dim);
const lead=digits.findIndex(d=>d!=='0');// leading zeros left of the new point fade once it has moved
digits.forEach((d,i)=>{const r=mk('rect',{x:i*step-48,y:-64,width:96,height:99,rx:9,fill:'none',stroke:COL.faint,'stroke-width':2},g),e=T(g,d,{x:i*step,y:10,size:66,font:'monospace',anchor:'middle',fill:i>2?COL.dim:COL.chalk});if(i<lead&&i<=shift)[r,e].forEach(z=>tw(z,{o:.25},tm+1.4,.5));});
const dot=T(g,'.',{x:step*.5,y:10,size:76,font:'monospace',fill:COL.task,anchor:'middle'});dot.dataset.shift=String(shift);dot.dataset.origin=String(step*.5);dot.dataset.target=String((shift+.5)*step);tw(dot,{x:(shift+.5)*step},tm,1.4,io);
const a=path(g,`M${step*.5} 64H${(shift+.5)*step}m-12 -8 12 8-12 8`,{stroke:COL.task,'stroke-width':3},{d:0});draw(a,tm,1.4);ddText(g,'× '+10**shift,700,8,tm,33,COL.task);return {g,dot};
}
function ddBoard(p,j,top,bot){const x=125+j*490,g=G(p);ddText(g,String.fromCharCode(65+j),x+200,285,.1,32,COL.dim,'middle');ddMath(g,top+' ÷ '+bot,x+200,450,.1,64);return {el:g,box:[x-5,310,415,250],label:top+' divided by '+bot};}
function ddLong(p,stage=0,times={}){
// Fewer rows on screen → larger board; centred at x 500, top ~215, last row clear of the caption box (y < 770).
const s=[1.8,1.5,1.25,1][stage],top=[260,225,205,210][stage],g=G(p,{x:500-s*447.5,y:top+s*20,s}),sz=55,xs=[340,430,520,610],rows=[110,180,250,320,390,460,530];
g.dataset.dividend='2.700';g.dataset.divisor='4';g.dataset.quotient='0.675';
const digit=(s,i,y,t=0,col=COL.chalk)=>ddText(g,s,xs[i],y,t,sz,col,'middle');
ddText(g,'4',225,rows[0],0,sz);path(g,`M280 125V44H670`,{stroke:COL.chalk,'stroke-width':3});
['2','7','0','0'].forEach((s,i)=>digit(s,i,rows[0],i>1?(times.zero??0):0,i>1?COL.dim:COL.chalk));
ddText(g,'.',385,rows[0],0,sz,COL.task,'middle');digit('0',0,20,times.ones??0);ddText(g,'.',385,20,times.point??0,sz,COL.task,'middle');
path(g,'M385 35V80',{stroke:COL.task,'stroke-width':1.5,'stroke-dasharray':'5 5'});
// bring-down arrows stop above the digit they bring down, so the 0 is not struck through
const down=(x,r,t)=>{const a=path(g,`M${x} 130V${rows[r]-50}m-8 -12 8 12 8-12`,{stroke:COL.task,'stroke-width':2},{d:0});draw(a,t,.7);};
const ul=(x,r,t)=>{const ln=path(g,`M${x} ${rows[r]+20}H${x+156}`,{stroke:COL.chalk,'stroke-width':2},{d:0});draw(ln,t,.3);};
const ts=n=>stage===n?(times.subtract??0):0,td=n=>stage===n?(times.digit??0):0,te=n=>stage===n?(times.exchange??0):0;
if(stage>=1){digit('6',1,20,td(1),COL.task);digit('2',0,rows[1],ts(1));digit('4',1,rows[1],ts(1));ddText(g,'−',265,rows[1],ts(1),sz);ul(310,1,ts(1));digit('3',1,rows[2],ts(1));digit('0',2,rows[2],te(1),COL.task);down(520,2,te(1));}
if(stage>=2){digit('7',2,20,td(2),COL.task);digit('2',1,rows[3],ts(2));digit('8',2,rows[3],ts(2));ddText(g,'−',355,rows[3],ts(2),sz);ul(400,3,ts(2));digit('2',2,rows[4],ts(2));digit('0',3,rows[4],te(2),COL.task);down(610,4,te(2));}
if(stage>=3){digit('5',3,20,td(3),COL.task);digit('2',2,rows[5],ts(3));digit('0',3,rows[5],ts(3));ddText(g,'−',445,rows[5],ts(3),sz);ul(490,5,ts(3));digit('0',3,rows[6],ts(3),COL.task);}
return g;
}
function ddQuotient(p,j,ds){const x=155+j*495,g=G(p),step=72;ddText(g,String.fromCharCode(65+j),x+150,245,.1,29,COL.dim,'middle');ds.forEach((d,i)=>ddText(g,d,x+i*step,365,.1,54,COL.task,'middle'));['2','7','0','0'].forEach((d,i)=>ddText(g,d,x+i*step,490,.1,54,COL.chalk,'middle'));ddText(g,'.',x+step*.5,365,.1,54,COL.task,'middle');ddText(g,'.',x+step*.5,490,.1,54,COL.task,'middle');path(g,`M${x-40} 405H${x+328}`,{stroke:COL.chalk,'stroke-width':2});ddText(g,'dividend 2.700',x+140,585,.1,28,COL.dim,'middle');return {el:g,box:[x-40,280,368,330],label:['0.675','6.75','0.0675'][j]};}
const BEATS=[
['intro','Same-sized groups',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 1 · The Number System · Chapter 10',{x:800,y:265,size:28,fill:COL.dim,anchor:'middle'});T(g,'Dividing',{x:800,y:375,size:82,weight:600,anchor:'middle'});T(g,'Decimals',{x:800,y:475,size:82,weight:600,anchor:'middle'});tw(g,{o:1,y:0},.2,1,out);ddMath(g,'1.8 ÷ 0.3',800,590,.6,60);const s=ddText(scene,'How many groups fit?',800,710,m('sub'),34,COL.dim,'middle');hide(g,D-.8,.7);hide(s,D-.8,.7);}],
['terms','Three jobs in division',m=>{const p=panel(0);ddTitle(p,'1.8 meters ÷ 0.3 meter per piece');ddBar(p);ddText(p,'dividend · total amount',800,240,m('dividend'),32,COL.chalk,'middle');ddText(p,'divisor · size of one group',410,538,m('divisor'),32,COL.task);ddMath(p,'1.8 ÷ 0.3 = 6',800,665,m('groups'),64);ddText(p,'quotient · number of pieces',800,750,m('groups',2),34,COL.dim,'middle');}],
['same','Count the same ribbon in tenths',m=>{const p=panel(0);ddTitle(p,'Scale the total AND each group','Same ribbon · same six sections · different counting unit');const b=ddBar(p);hide(b.a,m('scale'),.5);hide(b.b,m('scale'),.5);ddText(b.g,'18 tenths',b.w/2,-58,m('scale',.5),45,COL.chalk,'middle');ddText(b.g,'3 tenths',90,b.h+48,m('scale',.5),36,COL.task,'middle');ddMath(p,'1.8 ÷ 0.3 = 18 ÷ 3 = 6',800,675,m('answer'),57);ddText(p,'×10 to BOTH → same number of groups',800,785,m('scale',1),34,COL.task,'middle');}],
['q1','Quick check',()=>{const p=panel(0);ddTitle(p,'Original: 1.8 ÷ 0.3 = 6','Which bar has BOTH numbers multiplied by ten?');S.ddBars=[0,1,2].map(j=>{const x=150+j*500,b=ddBar(p,{x,y:345,w:310,h:105,total:j===0?'18':j===1?'18':'1.8',group:j===0?'3':j===1?'0.3':'3'});ddText(p,String.fromCharCode(65+j),x+155,215,0,32,COL.dim,'middle');ddText(p,j===0?'18 ÷ 3':j===1?'18 ÷ 0.3':'1.8 ÷ 3',x+155,570,0,39,COL.chalk,'middle');return {el:b.g,box:[x-30,260,370,355],label:['18 divided by 3','18 divided by 0.3','1.8 divided by 3'][j]};});},{ask:done=>quiz(BAND,[{id:'c-scale',prompt:'Which bar still shows six groups, with both numbers ×10?',build:pickEls(S.ddBars,0,'A multiplies BOTH numbers by 10: 18 ÷ 3 = 6. Each of the six sections is 3 tenths.',i=>i===1?'B scales only the total. 18 ÷ 0.3 = 60, so that bar would need 60 groups, not 6.':'C scales only the divisor. 1.8 ÷ 3 = 0.6, not six groups.',()=>pulseFx(S.ddBars[0].el,1.02))}],done)}],
['rule','Why the quotient stays the same',m=>{const p=panel(0);ddTitle(p,'Same factor on top and bottom','Dividend a · divisor b · b ≠ 0');frac(p,['a'],['b'],590,350,m('both'),{size:63,anchor:'middle'});ddMath(p,'=',740,375,m('both'),63);frac(p,['a × 10',E('k')],['b × 10',E('k')],990,350,m('both'),{size:63,anchor:'middle'});ddText(p,'same nonzero factor',800,520,m('both'),34,COL.task,'middle');ddText(p,'The common factor cancels.',800,625,m('cancel'),38,COL.chalk,'middle');ddText(p,'Divisor 0: undefined',800,780,m('nonzero'),38,COL.task,'middle');}],
['shift','Both decimal points move together',m=>{const p=panel(0);ddTitle(p,'4.68 ÷ 0.12','Faint trailing zeros keep the value unchanged.');S.ddShift=[ddScale(p,['4','6','8','0','0'],'dividend',{shift:2,tm:m('move')}),ddScale(p,['0','1','2','0','0'],'divisor',{y:520,shift:2,tm:m('move')})];ddText(p,'468 ÷ 12',800,710,m('whole'),53,COL.chalk,'middle');ddText(p,'468 ÷ 12 = 39',800,805,m('answer'),53,COL.task,'middle');}],
['minimum','Make the divisor whole',m=>{const p=panel(0);ddTitle(p,'0.27 ÷ 0.4','Only ONE shift is needed for the divisor.');S.ddShift=[ddScale(p,['0','2','7','0','0'],'dividend',{shift:1,tm:m('move')}),ddScale(p,['0','4','0','0','0'],'divisor',{y:520,shift:1,tm:m('move')})];ddMath(p,'2.7 ÷ 4',800,710,m('whole'),59,COL.task);ddText(p,'A decimal dividend is fine.',800,805,m('whole',2),36,COL.dim,'middle');}],
['q2','Quick check',()=>{const p=panel(0);ddTitle(p,'0.27 ÷ 0.4','Which one multiplies BOTH numbers by ten?');S.ddBoards=[ddBoard(p,0,'2.7','4'),ddBoard(p,1,'2.7','0.4'),ddBoard(p,2,'27','4')];},{ask:done=>quiz(BAND,[{id:'c-move',prompt:'Which division gives the same answer as 0.27 ÷ 0.4?',build:pickEls(S.ddBoards,0,'A uses ×10 on both numbers, so 2.7 ÷ 4 has exactly the same answer.',i=>i===1?'B moves only the dividend’s point. You must multiply the divisor by ten too.':'C multiplies the dividend by 100 but the divisor by 10. Both factors must match.',()=>pulseFx(S.ddBoards[0].el,1.02))}],done)}],
['longstart','Place the point before dividing',m=>{const p=panel(0);ddTitle(p,'2.7 ÷ 4','After scaling 0.27 ÷ 0.4 by 10');ddLong(p,0,{point:m('point'),ones:m('point',8.3),zero:m('zero')});ddText(p,'quotient point directly above',1230,300,m('point'),34,COL.task,'middle');ddText(p,'the dividend point',1230,360,m('point'),34,COL.dim,'middle');ddText(p,'0 wholes in the ones place',1230,460,m('point',8.3),34,COL.chalk,'middle');ddMath(p,'2.7 = 2.700',800,660,m('zero'),64);ddText(p,'same value · smaller units available',800,750,m('zero',2),32,COL.dim,'middle');}],
['tenths','Six tenths per group',m=>{const p=panel(0);ddTitle(p,'27 tenths shared among 4 groups');ddLong(p,1,{digit:m('digit',5.7),subtract:m('subtract'),exchange:m('exchange')});ddText(p,'27 tenths − 24 tenths',1210,350,m('subtract'),38,COL.chalk,'middle');ddText(p,'= 3 tenths',1210,430,m('subtract'),42,COL.task,'middle');ddText(p,'3 tenths = 30 hundredths',1210,590,m('exchange'),38,COL.task,'middle');ddText(p,'1 tenth = 10 hundredths',1210,670,m('exchange',2),32,COL.dim,'middle');}],
['hundredths','Seven hundredths per group',m=>{const p=panel(0);ddTitle(p,'30 hundredths shared among 4 groups');ddLong(p,2,{digit:m('digit'),subtract:m('subtract'),exchange:m('exchange')});ddText(p,'30 hundredths − 28 hundredths',1180,390,m('subtract'),34,COL.chalk,'middle');ddText(p,'= 2 hundredths',1180,470,m('subtract'),42,COL.task,'middle');ddText(p,'2 hundredths = 20 thousandths',1180,620,m('exchange'),34,COL.task,'middle');ddText(p,'Bring down 0 to show the exchange.',1180,700,m('exchange',2),30,COL.dim,'middle');}],
['thousandths','Five thousandths; remainder zero',m=>{const p=panel(0);ddTitle(p,'20 thousandths shared among 4 groups');ddLong(p,3,{digit:m('digit'),subtract:m('subtract')});ddText(p,'20 − 20 = 0 thousandths',1150,400,m('subtract'),38,COL.task,'middle');ddMath(p,'0.675 × 4 = 2.7',1150,560,m('check'),52);ddText(p,'0.27 ÷ 0.4 = 0.675',1150,700,m('check',2),44,COL.task,'middle');}],
['q3','Quick check',()=>{const p=panel(0);ddTitle(p,'2.700 ÷ 4','Choose the quotient row. The point stays above the dividend point.');S.ddQ=[ddQuotient(p,0,['0','6','7','5']),ddQuotient(p,1,['6','7','5']),ddQuotient(p,2,['0','0','6','7','5'])];},{ask:done=>quiz(BAND,[{id:'c-point',prompt:'Which row gives 0.675 with every digit in its correct place?',build:pickEls(S.ddQ,0,'A has 0 ones, 6 tenths, 7 hundredths, 5 thousandths. Its point is directly above the dividend point.',i=>i===1?'B places 6 in the ones column instead of the tenths column. Its quotient is ten times too large.':'C places 6 in the hundredths column. Its quotient is ten times too small.',()=>pulseFx(S.ddQ[0].el,1.02))}],done)}],
['sizes','The size of the group matters',m=>{const p=panel(0);ddTitle(p,'Division can make a positive number larger or smaller');const b=ddBar(p,{x:250,y:330,w:324,h:130,total:'1.2',group:'0.2',t:m('small')});ddMath(p,'1.2 ÷ 0.2 = 6',412,640,m('small'),56);ddText(p,'six small groups',412,730,m('small'),32,COL.dim,'middle');const g=G(p,{x:900,y:330,o:0});g.dataset.groupSize='2';g.dataset.amount='1.2';show(g,m('large'));mk('rect',{width:540,height:130,fill:'none',stroke:COL.whole,'stroke-width':3},g);mk('rect',{width:324,height:130,fill:COL.whole,'fill-opacity':.38,stroke:COL.task,'stroke-width':2},g);for(let i=1;i<10;i++)path(g,`M${i*54} 0V130`,{stroke:COL.faint,'stroke-width':1});ddText(g,'one whole group = 2',270,-45,m('large'),34,COL.chalk,'middle');ddText(g,'1.2 fills 6/10 of the group',270,180,m('large'),32,COL.task,'middle');ddMath(p,'1.2 ÷ 2 = 0.6',1170,640,m('large'),56);ddText(p,'six tenths of one larger group',1170,730,m('large'),32,COL.dim,'middle');}],
['unequal','Unequal decimal lengths are fine',m=>{const p=panel(0);ddTitle(p,'0.063 ÷ 0.15');ddMath(p,'0.063 ÷ 0.15',800,300,.2,65);ddText(p,'×100 to both numbers',800,425,m('scale'),36,COL.task,'middle');ddMath(p,'6.3 ÷ 15 = 0.42',800,560,m('answer'),61);ddMath(p,'15 × 0.42 = 6.3',800,740,m('check'),57,COL.task);ddText(p,'Only the divisor’s two fractional places determine the shift.',800,815,m('scale',2),29,COL.dim,'middle');}],
['rate','How many liters per minute?',m=>{const p=panel(0);ddTitle(p,'A pump transfers 9.6 liters in 2.5 minutes.','Find the average rate.');ddText(p,'total liters ÷ total minutes',800,295,m('divide'),39,COL.dim,'middle');ddMath(p,'9.6 ÷ 2.5 = 96 ÷ 25',800,435,m('divide'),57);ddText(p,'3.84 liters per minute',800,580,m('answer'),49,COL.task,'middle');ddMath(p,'3.84 × 2.5 = 9.6',800,735,m('check'),57);ddText(p,'liters/minute × minutes = liters',800,815,m('check',2),29,COL.dim,'middle');}],
['wrap','Four reliable habits',m=>{const p=panel(0);[['Name the terms. Keep the divisor nonzero.','w1'],['Multiply BOTH numbers by the same power of ten.','w2'],['Align points. Exchange remainders; append zeros.','w3'],['Multiply to check the quotient and its units.','w4']].forEach(([s,k],i)=>{const g=G(p,{x:-16,y:235+i*145,o:0});mk('circle',{cx:150,cy:-10,r:26,fill:COL.task},g);T(g,String(i+1),{x:150,y:0,size:30,anchor:'middle',fill:COL.board});T(g,s,{x:215,size:34});tw(g,{x:0,o:1},m(k),.6);});}],
['final1','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-basic',prompt:'Divide exactly. Equivalent trailing zeros are accepted.',build:blanks([
{parts:['6.3 ÷ 0.9 = ',{box:'7'}],why:'Multiply both by 10: 63 ÷ 9 = 7.'},
{parts:['8.64 ÷ 1.2 = ',{box:'7.2'}],why:'Multiply both by 10: 86.4 ÷ 12 = 7.2. Check: 7.2 × 1.2 = 8.64.'},
{parts:['0.045 ÷ 0.15 = ',{box:'0.3'}],why:'Multiply both by 100: 4.5 ÷ 15 = 0.3.'},
{parts:['0.0084 ÷ 0.07 = ',{box:'0.12'}],why:'Multiply both by 100: 0.84 ÷ 7 = 0.12. The dividend may stay a decimal.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-precision',prompt:'Use the divisor to choose the shift. Do not round.',build:blanks([
{parts:['0.18 ÷ 0.8 = ',{box:'0.225'}],why:'1.8 ÷ 8 = 0.225. Append zeros to keep dividing exactly; 0.225 × 0.8 = 0.18.'},
{parts:['2.16 ÷ 3.6 = ',{box:'0.6'}],why:'21.6 ÷ 36 = 0.6. The dividend is smaller than the divisor, so the quotient is below 1.'},
{parts:['1.755 ÷ 0.03 = ',{box:'58.5'}],why:'175.5 ÷ 3 = 58.5. The divisor needs two shifts; both numbers get × 100.'},
{parts:['7.2 ÷ 0.025 = ',{box:'288'}],why:'7200 ÷ 25 = 288. Both numbers get × 1000; 288 × 0.025 = 7.2.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[
{id:'p-speed',prompt:'A cyclist travels 14.4 kilometers in 1.8 hours. Find the average speed.',build:blanks([{parts:[{box:'8'},' kilometers per hour'],why:'14.4 ÷ 1.8 = 144 ÷ 18 = 8 kilometers per hour.'}])},
{id:'p-pump',prompt:'A pump transfers 6.3 liters in 2.4 minutes. Find its average rate.',build:blanks([{parts:[{box:'2.625'},' liters per minute'],why:'6.3 ÷ 2.4 = 63 ÷ 24 = 2.625 liters per minute. The quotient is exact.'}])},
{id:'p-packets',prompt:'There are 0.84 kilogram of seeds. Each packet holds 0.07 kilogram. How many complete packets can be filled?',build:blanks([{parts:[{box:'12'},' packets'],why:'0.84 ÷ 0.07 = 84 ÷ 7 = 12 complete packets.'}])},
{id:'p-rope',prompt:'A 3.6 meter rope is cut into 5 equal pieces. Find the length of each piece.',build:blanks([{parts:[{box:'0.72'},' meter per piece'],why:'3.6 ÷ 5 = 0.72. Appending a zero gives 3.60; 0.72 × 5 = 3.6.'}])}
],done,'Chapter practice · set 3 of 3')}],
['finish','Finished',()=>panel(0),{ask:finishCard}]
].map(([id,title,run,extra])=>({id,title,run,...extra}));
boot();
</script></body></html>