import React, { useState } from "react"; const ExponentialExplorer: React.FC = () => { const [a, setA] = useState(2); // Initial Value const [b, setB] = useState(1.5); // Growth Factor const [k, setK] = useState(0); // Horizontal Asymptote shift const width = 300; const range = 5; // x range -5 to 5 // Mapping const toPx = (v: number, isY = false) => { const scale = width / (range * 2); const center = width / 2; return isY ? center - v * scale : center + v * scale; }; const generatePath = () => { let d = ""; for (let x = -range; x <= range; x += 0.1) { const y = a * Math.pow(b, x) + k; if (y > range * 2 || y < -range * 2) continue; // Clip const px = toPx(x); const py = toPx(y, true); d += d ? ` L ${px} ${py}` : `M ${px} ${py}`; } return d; }; return (
Standard Form
y = {a} ยท{" "} {b} x {k >= 0 ? "+" : ""}{" "} {k}
setA(parseFloat(e.target.value))} className="w-full h-2 bg-indigo-100 rounded-lg appearance-none cursor-pointer accent-indigo-600" />
setB(parseFloat(e.target.value))} className="w-full h-2 bg-emerald-100 rounded-lg appearance-none cursor-pointer accent-emerald-600" />

{b > 1 ? "Growth (b > 1)" : "Decay (0 < b < 1)"}

setK(parseFloat(e.target.value))} className="w-full h-2 bg-rose-100 rounded-lg appearance-none cursor-pointer accent-rose-600" />
{/* Asymptote */} y = {k} {/* Function */} {/* Intercept */}
); }; export default ExponentialExplorer;