colors = ({
navy: "#2C3E50",
teal: "#16A085",
orange: "#E67E22",
blue: "#3498DB",
gray: "#7F8C8D",
purple: "#9B59B6",
red: "#E74C3C"
})
viewof initialCost = Inputs.range([1, 1000], {
value: 100,
step: 10,
label: "Initial component cost ($)"
})
viewof yearsForward = Inputs.range([0, 15], {
value: 5,
step: 1,
label: "Years forward"
})
viewof costReductionRate = Inputs.select([
{label: "Conservative (halves every 3 years)", value: 0.793700526},
{label: "Moore's Law (halves every 2 years)", value: 0.707},
{label: "Aggressive (halves every 18 months)", value: 0.629960525}
], {
value: 0.707,
label: "Cost reduction rate",
format: x => x.label
})
// Calculate future cost
futureCost = initialCost * Math.pow(costReductionRate.value, yearsForward)
totalReduction = ((initialCost - futureCost) / initialCost * 100).toFixed(1)
costRatio = (initialCost / futureCost).toFixed(1)
// Generate projection data
projectionData = Array.from({length: 16}, (_, i) => ({
year: i,
cost: initialCost * Math.pow(costReductionRate.value, i)
}))
Plot.plot({
width: typeof width === "number" ? Math.min(640, width) : 640,
height: 350,
marginLeft: 60,
marginBottom: 50,
x: {
label: "Years from now →",
domain: [0, 15],
grid: true
},
y: {
label: "↑ Cost ($)",
type: "log",
grid: true,
tickFormat: d => `$${d.toFixed(0)}`
},
marks: [
Plot.line(projectionData, {
x: "year",
y: "cost",
stroke: colors.navy,
strokeWidth: 3
}),
Plot.dot([{year: 0, cost: initialCost}], {
x: "year",
y: "cost",
fill: colors.teal,
r: 6
}),
Plot.dot([{year: yearsForward, cost: futureCost}], {
x: "year",
y: "cost",
fill: colors.orange,
r: 6
}),
Plot.ruleY([initialCost], {
stroke: colors.teal,
strokeDasharray: "4,4",
strokeOpacity: 0.5
}),
Plot.ruleY([futureCost], {
stroke: colors.orange,
strokeDasharray: "4,4",
strokeOpacity: 0.5
})
]
})html`<div style="background: ${colors.navy}; color: white; padding: 20px; border-radius: 8px; margin-top: 20px;">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px;">
<div style="min-width: 0; background: rgba(22,160,133,0.3); padding: 15px; border-radius: 6px; border: 2px solid ${colors.teal};">
<div style="font-size: 0.85em; opacity: 0.9;">Today</div>
<div style="font-size: clamp(1.2rem, 6vw, 1.8rem); font-weight: bold; margin: 5px 0; overflow-wrap: anywhere;">$${initialCost.toFixed(0)}</div>
</div>
<div style="min-width: 0; background: rgba(230,126,34,0.3); padding: 15px; border-radius: 6px; border: 2px solid ${colors.orange};">
<div style="font-size: 0.85em; opacity: 0.9;">In ${yearsForward} years</div>
<div style="font-size: clamp(1.2rem, 6vw, 1.8rem); font-weight: bold; margin: 5px 0; overflow-wrap: anywhere;">$${futureCost.toFixed(2)}</div>
</div>
<div style="min-width: 0; background: rgba(231,76,60,0.3); padding: 15px; border-radius: 6px; border: 2px solid ${colors.red};">
<div style="font-size: 0.85em; opacity: 0.9;">Cost Reduction</div>
<div style="font-size: clamp(1.2rem, 6vw, 1.8rem); font-weight: bold; margin: 5px 0; overflow-wrap: anywhere;">${totalReduction}%</div>
<div style="font-size: 0.85em; opacity: 0.8;">(${costRatio}x cheaper)</div>
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: rgba(255,255,255,0.1); border-radius: 4px; font-size: 0.9em;">
<strong>Business Impact:</strong>
${costRatio > 10 ? `A ${costRatio}x cost reduction unlocks entirely new markets. Applications that seem economically absurd today become profitable.` : ''}
${costRatio >= 5 && costRatio <= 10 ? `A ${costRatio}x cost reduction makes previously premium features accessible to mass markets.` : ''}
${costRatio < 5 ? `Cost improvements of ${costRatio}x expand existing markets but may not create paradigm shifts.` : ''}
</div>
</div>`