import { renderLatex } from "@ofb/katex"; import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js"; import { computeRoots, discriminant, formatNum } from "../../../../frontend/src/lib/math-graph"; const HORIZONTAL_SPEED = 12; function SliderRow(props: { id: string; label: string; value: number; min: number; max: number; step: number; unit?: string; disabled?: boolean; onInput: (v: number) => void; }) { const display = () => props.unit ? `${formatNum(props.value)} ${props.unit}` : formatNum(props.value); return (
A textbook shop sets price ${formatNum(price())}. Higher price means lower demand: {formatNum(quantity())} books sold (demand curve). Revenue, cost, and profit Π are read off the curves at that quantity.
Profit model
{atOptimum() ? `Maximum profit at P = $${formatNum(PROFIT_OPTIMAL_PRICE)} (Q = ${formatNum(demandQuantity(PROFIT_OPTIMAL_PRICE))}, Π = $${formatNum(profitAtPrice(PROFIT_OPTIMAL_PRICE))}).` : "Profit is positive between break-even prices P = $5 and P = $15. Drag toward the peak of the gold curve."}
Blue: demand (P vs Q). Green, gray, gold: revenue, cost, and profit in dollars (right scale).
Each square is 1 m. Perimeter P = {perimeter()} m (fixed while resizing). Drag the corner — snaps to whole metres.
2w + 2ℓ = {perimeter()} m · w + ℓ = {halfP()} m
Area model
{isMax() ? `Maximum area on this grid — ${widthUnits()} m × ${lengthUnits()} m (A = ${area()} m²).` : "\u00a0"}