Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

16.4 KB
Raw Blame
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Multiplying 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="audio/en/timings.js"></script><script>
'use strict';
const CHAPTER={number:9,title:'Multiplying Decimals',minutes:12,language:'en', next: '../ch10/' };
const dmText=(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 dmMath=(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 dmTitle=(p,s,sub='')=>{dmText(p,s,100,115,.1,43);if(sub)dmText(p,sub,100,165,.15,27,COL.dim);};
function dmArea(p,{x=210,y=275,size=400,cols=4,rows=3,unit=.1,tWidth=.2,tHeight=.2,tCells=.2,tGrid=.2,label=true}={}){
 const g=G(p,{x,y}),d=size/10,base=unit*10;
 mk('rect',{width:size,height:size,fill:'none',stroke:COL.chalk,'stroke-width':3},g);
 const a=G(g,{o:0});mk('rect',{width:d*cols,height:size,fill:COL.whole,'fill-opacity':.3},a);show(a,tWidth);
 const b=G(g,{o:0});mk('rect',{width:size,height:d*rows,fill:COL.nat,'fill-opacity':.45},b);show(b,tHeight);
 const c=G(g,{o:0});mk('rect',{width:d*cols,height:d*rows,fill:COL.task,'fill-opacity':.55,stroke:COL.task,'stroke-width':3},c);c.dataset.product=String(cols*rows*unit*unit);c.dataset.width=String(cols*unit);c.dataset.height=String(rows*unit);show(c,tCells);
 const grid=G(g,{o:0});for(let i=1;i<10;i++){path(grid,`M${i*d} 0V${size}`,{stroke:COL.chalk,'stroke-width':1,'stroke-opacity':.65});path(grid,`M0 ${i*d}H${size}`,{stroke:COL.chalk,'stroke-width':1,'stroke-opacity':.65});}show(grid,tGrid);
 if(label){dmText(g,`${base===1?'1':base.toFixed(1)} unit wide`,size/2,-32,.2,27,COL.dim,'middle');put(dmText(g,`${base===1?'1':base.toFixed(1)} unit high`,0,0,.2,27,COL.dim,'middle'),{x:-24,y:size/2,r:-90});}
 return {g,a,b,c,grid,d};
}
function dmPlace(p,digits,{x=330,y=400,t=.2,places=['ones','tenths','hundredths','thousandths'],step=160,size=72,tDigits=null,tDot=null,boxW=.86}={}){
 const g=G(p,{x,y,o:0});show(g,t);const ones=Math.max(0,places.indexOf('ones'));
 places.forEach((s,i)=>{const numeric=places[0]==='1',stag=numeric||places.length>6,hy=stag&&i%2===0?-122:-90;T(g,s,{x:i*step,y:hy,size:numeric?22:places.length>6?21:24,anchor:'middle',fill:COL.dim});if(stag)path(g,`M${i*step} ${hy+10}V-68`,{stroke:COL.faint,'stroke-width':1});mk('rect',{x:i*step-step*boxW/2,y:-65,width:step*boxW,height:95,rx:12,fill:'none',stroke:COL.faint,'stroke-width':2},g);const dg=T(g,digits[i]??'',{x:i*step,y:10,size,font:'monospace',anchor:'middle',o:0});show(dg,tDigits?tDigits(i):0);});
 const dot=T(g,'.',{x:(ones+.5)*step,y:10,size,font:'monospace',anchor:'middle',fill:COL.task,o:0});show(dot,tDot??0);return g;
}
function dmWhole(p,{x=470,y=280,t=.2,tOnes=.2,tTens=.2,tSum=.2,wrong=false,mini=false}={}){
 const g=G(p,{x,y}),size=mini?49:68,dy=mini?72:96,end=mini?285:350;
 ['324','× 16'].forEach((s,i)=>dmText(g,s,end,i*dy,t,size,COL.chalk,'end'));
 path(g,`M${end-5*size*.6} ${dy+24}H${end+20}`,{stroke:COL.chalk,'stroke-width':3});
 dmText(g,'1944',end,dy*2,tOnes,size,COL.chalk,'end');dmText(g,wrong?'324':'3240',end,dy*3,tTens,size,COL.task,'end');
 if(!mini){path(g,`M${end-5*size*.6} ${dy*3+28}H${end+20}`,{stroke:COL.chalk,'stroke-width':3});dmText(g,'5184',end,dy*4+24,tSum,size,COL.task,'end');}
 return g;
}
function dmPatch(p,x,cols,rows,label){const g=G(p);dmText(g,label,x+130,255,.2,31,COL.dim,'middle');const model=dmArea(g,{x,y:315,size:260,cols,rows,unit:.1,tWidth:99,tHeight:99,tCells:.2,tGrid:.2,label:false});dmText(g,cols*rows+' hundredths',x+130,625,.2,28,COL.task,'middle');return {el:g,box:[x-15,270,290,375],label:`${label}: ${cols*rows} hundredths`};}
function dmZeroChart(p,x,ds,label){const g=G(p);dmText(g,label,x+225,255,.2,30,COL.dim,'middle');dmPlace(g,ds,{x:x+20,y:415,t:.2,places:['1','0.1','0.01','0.001','0.0001','0.00001'],step:82,size:50,boxW:.78});dmText(g,'0.'+ds.slice(1).join(''),x+225,560,.2,45,COL.task,'middle');return {el:g,box:[x-15,290,490,315],label:'0.'+ds.slice(1).join('')};}
const BEATS=[
['intro','Products have scale',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 1 · The Number System · Chapter 9',{x:800,y:265,size:28,fill:COL.dim,anchor:'middle'});T(g,'Multiplying',{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);dmMath(g,'0.4 × 0.3',800,590,.6,60);const s=dmText(scene,'The decimal point has a reason.',800,710,m('sub'),34,COL.dim,'middle');hide(g,D-.8,.7);hide(s,D-.8,.7);}],
['area','Tenths times tenths',m=>{const p=panel(0);dmTitle(p,'0.4 × 0.3','One full square = 1 square unit');const a=dmArea(p,{tWidth:m('width'),tHeight:m('height'),tCells:m('height',5.235),tGrid:m('cells')});dmText(p,'width: 4 tenths',1050,290,m('width'),36,COL.whole,'middle');dmText(p,'height: 3 tenths',1050,375,m('height'),36,COL.nat,'middle');dmText(p,'4 × 3 = 12 cells',1050,495,m('cells',7.735),38,COL.task,'middle');dmText(p,'each cell = 1 hundredth',1050,565,m('cells',2.5),31,COL.dim,'middle');dmMath(p,'0.4 × 0.3 = 0.12',1050,675,m('answer'),53);}],
['fraction','Why the places add',m=>{const p=panel(0);dmTitle(p,'One tenth × one tenth = one hundredth');dmArea(p,{x:170,y:300,size:330});dmMath(p,[F('4','10'),' × ',F('3','10')],1060,325,m('frac'),58);dmMath(p,[F('4 × 3','10 × 10'),' = ',F('12','100')],1060,505,m('denom'),58);dmMath(p,'0.12',1060,660,m('result'),66,COL.task);dmText(p,'1 place + 1 place = 2 fractional places',800,800,m('result',2),35,COL.task,'middle');}],
['q1','Quick check',()=>{const p=panel(0);dmTitle(p,'Which patch represents 0.4 × 0.3?','All three full squares represent 1 square unit.');S.dmPatch=[dmPatch(p,180,4,3,'A'),dmPatch(p,670,7,10,'B'),dmPatch(p,1160,4,10,'C')];},{ask:done=>quiz(BAND,[{id:'c-area',prompt:'Choose the product area: four tenths wide and three tenths high.',build:pickEls(S.dmPatch,0,'A contains 4 × 3 = 12 hundredth cells: 0.12.',i=>i===1?'B shows 70 hundredths, or 0.7, the sum of 0.4 and 0.3. Multiplication selects an overlap.':'C shows 40 hundredths, or 0.4. We need only three tenths of that height.',()=>pulseFx(S.dmPatch[0].el,1.03))}],done)}],
['scale','Multiply and restore the scale',m=>{const p=panel(0);dmTitle(p,'3.24 × 1.6','Decimals are fractions with powers of ten as denominators.');dmMath(p,['3.24 = ',F('324','100')],390,325,m('first'),56);dmText(p,'2 fractional places',390,420,m('first'),31,COL.whole,'middle');dmMath(p,['1.6 = ',F('16','10')],1120,325,m('second'),56);dmText(p,'1 fractional place',1120,420,m('second'),31,COL.nat,'middle');dmMath(p,[F('324 × 16','100 × 10'),' = ',F('5184','1000')],800,620,m('multiply'),58);dmText(p,'2 + 1 = 3 places → divide by 1000',800,780,m('count'),38,COL.task,'middle');}],
['whole','The whole-number calculation',m=>{const p=panel(0);dmTitle(p,'324 × 16','Align whole-number ones. Each row keeps its place value.');dmWhole(p,{x:170,y:265,tOnes:m('ones'),tTens:m('tens',2.318),tSum:m('sum')});dmText(p,'324 × 6 = 1944',1060,450,m('ones'),36,COL.chalk,'middle');dmText(p,'carry 2, then carry 1',1060,505,m('ones',2),28,COL.dim,'middle');dmText(p,'324 × 10 = 3240',1060,590,m('tens',2.318),36,COL.task,'middle');dmText(p,'The 1 in 16 means ONE TEN.',1060,650,m('tens'),29,COL.dim,'middle');dmText(p,'1944 + 3240 = 5184',1060,760,m('sum'),36,COL.task,'middle');}],
['point','Three fractional places',m=>{const p=panel(0);dmTitle(p,'5184 ÷ 1000','Restore the scales used in 3.24 × 1.6.');dmMath(p,'2 places + 1 place = 3',800,260,.2,48);dmPlace(p,['5','1','8','4'],{x:480,y:495,t:m('restore'),tDot:m('count',5.742),step:210});dmText(p,'4 → thousandths   8 → hundredths   1 → tenths',800,620,m('count'),32,COL.dim,'middle');dmMath(p,'3.24 × 1.6 = 5.184',800,765,m('result'),62,COL.task);}],
['estimate','Check the size',m=>{const p=panel(0);dmTitle(p,'3.24 × 1.6','A reasonable range helps catch a misplaced point.');dmMath(p,'3 < 3.24 < 4',800,285,.2,59);dmMath(p,'4.8 < 3.24 × 1.6 < 6.4',800,435,m('bound'),59);const x=350,y=555,w=900;path(p,`M${x} ${y}H${x+w}`,{stroke:COL.dim,'stroke-width':3});[4.8,5.184,6.4].forEach((v,i)=>{const px=x+(v-4.8)/1.6*w;mk('circle',{cx:px,cy:y,r:i===1?12:7,fill:i===1?COL.task:COL.chalk,opacity:0},p);const e=p.lastChild;show(e,i===1?m('correct'):m('bound'));dmText(p,String(v),px,610,i===1?m('correct'):m('bound'),31,i===1?COL.task:COL.dim,'middle');});dmText(p,'51.84: too large',480,755,m('reject'),38,COL.task,'middle');dmText(p,'0.5184: too small',1120,755,m('reject',3.347),38,COL.task,'middle');}],
['q2','Quick check',()=>{const p=panel(0);dmTitle(p,'The 1 in 16 is in the TENS place.','Which partial-product board preserves that value?');S.dmWhole=[0,1].map(j=>{const x=170+j*780,g=dmWhole(p,{x,y:280,mini:true,wrong:j===1});dmText(p,j?'B':'A',x+225,200,.2,31,COL.dim,'middle');dmText(p,j?'324 × 1':'324 × 10',x+225,590,.2,32,COL.task,'middle');return {el:g,box:[x-5,260,410,370],label:j?'B: partial product 324':'A: partial product 3240'};});},{ask:done=>quiz(BAND,[{id:'c-shift',prompt:'Choose the board with the correct tens-row partial product.',build:pickEls(S.dmWhole,0,'A uses 324 × 10 = 3240. The tens digit needs a shifted row or a zero in the ones place.',()=> 'B uses 324 × 1. But the 1 in 16 means ten, so the partial product must be 3240.',()=>pulseFx(S.dmWhole[0].el,1.03))}],done)}],
['small','A product smaller than both factors',m=>{const p=panel(0);dmTitle(p,'0.06 × 0.04','Reference square: 0.1 × 0.1 = 0.01 square unit · drawn larger');dmArea(p,{x:165,y:285,size:400,cols:6,rows:4,unit:.01,tWidth:m('sides'),tHeight:m('sides'),tCells:m('grid'),tGrid:m('grid')});dmText(p,'width 0.06 · height 0.04',1060,285,m('sides'),32,COL.dim,'middle');dmText(p,'each cell = 0.01 × 0.01',1060,390,m('grid'),32,COL.dim,'middle');dmText(p,'24 ten-thousandths',1060,475,m('grid',2),37,COL.task,'middle');dmMath(p,'24 ÷ 10000 = 0.0024',1060,615,m('result'),46,COL.task);dmText(p,'2 + 2 = 4 fractional places',1060,700,m('result'),30,COL.dim,'middle');dmText(p,'Leading zeros keep the 2 in the thousandths place.',800,815,m('zeros'),31,COL.task,'middle');}],
['tiny','Make room for leading zeros',m=>{const p=panel(0);dmTitle(p,'0.004 × 0.012','An exact product: no rounding.');dmMath(p,[F('4','1000'),' × ',F('12','1000')],800,310,m('fractions'),58);dmMath(p,[F('48','1000000')],800,435,m('product'),54);dmPlace(p,['0','0','0','0','0','4','8'],{x:230,y:625,t:m('pad'),tDigits:i=>i<5?m('pad',5.8):m('pad',3.3),places:['ones','tenths','hundredths','thousandths','ten-thousandths','hundred-thousandths','millionths'],step:190,size:64});dmMath(p,'0.000048',800,795,m('exact'),66,COL.task);}],
['trailing','Keep all the written digits',m=>{const p=panel(0);dmTitle(p,'0.250 × 0.60','Route A: keep every written fractional digit.');dmMath(p,'250 × 60 = 15000',800,310,m('keep'),58);dmText(p,'3 places + 2 places = 5 places',800,425,m('count'),38,COL.task,'middle');dmMath(p,[F('15000','100000'),' = 0.15000'],800,605,m('result'),59);dmMath(p,'0.15000 = 0.15',800,780,m('simplify'),58,COL.task);}],
['trim','Or simplify the factors FIRST',m=>{const p=panel(0);dmTitle(p,'0.250 × 0.60','Route B: shorten the factors before multiplying.');dmMath(p,'0.25 × 0.6',800,305,m('factors'),65);dmMath(p,'25 × 6 = 150',800,435,m('whole'),58);dmText(p,'2 places + 1 place = 3 places',800,555,m('count'),38,COL.task,'middle');dmMath(p,'150 ÷ 1000 = 0.150 = 0.15',800,720,m('same'),57,COL.task);dmText(p,'Matching integers + matching place count',800,815,m('same',2),31,COL.dim,'middle');}],
['integer','A whole-number zero has value',m=>{const p=panel(0);dmTitle(p,'240 × 0.003','240 has ZERO fractional places.');dmMath(p,['240 × ',F('3','1000')],800,305,m('fraction'),59);dmMath(p,'240 × 3 = 720',800,440,m('whole'),59);dmMath(p,'720 ÷ 1000 = 0.720 = 0.72',800,615,m('answer'),57,COL.task);dmText(p,'240 ≠ 24',800,740,m('care'),41,COL.task,'middle');dmText(p,'Dropping an integer zero makes the answer ten times too small.',800,805,m('care',2),31,COL.dim,'middle');}],
['q3','Quick check',()=>{const p=panel(0);dmTitle(p,'0.06 × 0.04 = 24 ÷ 10000','Chart headings show each digit’s place value.');S.dmZero=[dmZeroChart(p,50,['0','0','0','2','4'],'A'),dmZeroChart(p,570,['0','0','2','4'],'B'),dmZeroChart(p,1090,['0','0','0','0','2','4'],'C')];},{ask:done=>quiz(BAND,[{id:'c-small',prompt:'Choose the product chart. Leading zeros must preserve place value.',build:pickEls(S.dmZero,0,'A shows 24 ten-thousandths: 0.0024. The first nonzero digit is in the thousandths place.',i=>i===1?'B shows 0.024, ten times too large. Two places plus two places requires four fractional places.':'C shows 0.00024, ten times too small. Its 2 starts one place too far right.',()=>pulseFx(S.dmZero[0].el,1.02))}],done)}],
['context','Price times amount',m=>{const p=panel(0);dmTitle(p,'Ribbon · $6.40 per meter × 2.75 meters','The price for each meter is multiplied by the number of meters.');dmText(p,'rate × amount = total price',800,290,.2,38,COL.dim,'middle');dmMath(p,'640 × 275 = 176000',800,420,m('multiply'),58);dmText(p,'2 + 2 = 4 written fractional places',800,540,m('places'),36,COL.task,'middle');dmMath(p,'176000 ÷ 10000 = 17.6000',800,650,m('places',2),54);dmMath(p,'$17.60',800,780,m('money'),70,COL.task);}],
['wrap','Four reliable moves',m=>{const p=panel(0);[['Multiply whole numbers; shift each partial product.','w1'],['Add the fractional places of the digits you used.','w2'],['Keep leading zeros. Check the size.','w3'],['Trim fractional zeros carefully; keep scales matched.','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-products',prompt:'Multiply exactly. Equivalent trailing zeros are accepted.',build:blanks([
{parts:['2.35 × 1.4 = ',{box:'3.29'}],why:'235 × 14 = 3290. Three fractional places gives 3.290 = 3.29.',hint:'The whole-number partial products are 940 and 2350.'},
{parts:['36 × 0.025 = ',{box:'0.9'}],why:'36 × 25 = 900. Zero plus three fractional places gives 0.900 = 0.9.'},
{parts:['0.08 × 0.07 = ',{box:'0.0056'}],why:'8 × 7 = 56, with four fractional places: 0.0056.'},
{parts:['0.006 × 0.013 = ',{box:'0.000078'}],why:'6 × 13 = 78, with six fractional places: 0.000078.',hint:'Pad the places before 78 with leading zeros.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-zeros',prompt:'Keep the product and the place count consistent.',build:blanks([
{parts:['0.420 × 0.50 = ',{box:'0.21'}],why:'420 × 50 = 21000 with five places: 0.21000 = 0.21. Or trim FIRST: 42 × 5 = 210 with three places.'},
{parts:['520 × 0.0003 = ',{box:'0.156'}],why:'520 × 3 = 1560, with four fractional places: 0.1560. The integer zero stays.'},
{parts:['0.30 × 0.40 = ',{box:'0.12'}],why:'30 × 40 = 1200, with four fractional places: 0.1200 = 0.12.'},
{parts:['235 × 14: tens-row partial = ',{box:'2350'}],why:'The 1 in 14 means ten. The partial product is 235 × 10 = 2350, then add the ones-row 940.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[
{id:'p-price',prompt:'Cloth costs $4.80 per meter. You buy 3.25 meters. Find the total price.',build:blanks([{parts:['$',{box:'15.60'}],why:'4.80 × 3.25 = 15.6000, displayed as $15.60.'}])},
{id:'p-map',prompt:'Each centimeter on a map represents 2.4 meters. What distance do 3.75 centimeters represent?',build:blanks([{parts:[{box:'9'},' meters'],why:'2.4 × 3.75 = 9.000 = 9 meters.'}])},
{id:'p-distance',prompt:'A walker travels 0.18 kilometers per minute for 7.5 minutes. Find the distance.',build:blanks([{parts:[{box:'1.35'},' kilometers'],why:'0.18 × 7.5 = 1.350 = 1.35 kilometers.'}])},
{id:'p-volume',prompt:'A straight-sided container holds 0.025 liters for each centimeter of water height. It is filled to 0.4 centimeter. Find the volume.',build:blanks([{parts:[{box:'0.01'},' liters'],why:'0.025 × 0.4 = 0.0100 = 0.01 liters. Four fractional places before simplification.'}])}
],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>