import React, { useState } from "react";
const PolynomialBehaviorWidget: React.FC = () => {
const [degreeType, setDegreeType] = useState<"even" | "odd">("odd");
const [lcSign, setLcSign] = useState<"pos" | "neg">("pos");
const getPath = () => {
// Create schematic shapes
// Odd +: Low Left -> High Right
// Odd -: High Left -> Low Right
// Even +: High Left -> High Right
// Even -: Low Left -> Low Right
const startY =
(degreeType === "odd" && lcSign === "pos") ||
(degreeType === "even" && lcSign === "neg")
? 180
: 20;
const endY = lcSign === "pos" ? 20 : 180;
// Control points for curvy polynomial look
const cp1Y = startY === 20 ? 150 : 50;
const cp2Y = endY === 20 ? 150 : 50;
return `M 20 ${startY} C 100 ${cp1Y}, 200 ${cp2Y}, 280 ${endY}`;
};
return (
Degree (Highest Power)
Leading Coefficient
End Behavior
{degreeType === "even" &&
lcSign === "pos" &&
"Ends go in the SAME direction (UP)."}
{degreeType === "even" &&
lcSign === "neg" &&
"Ends go in the SAME direction (DOWN)."}
{degreeType === "odd" &&
lcSign === "pos" &&
"Ends go in OPPOSITE directions (Down Left, Up Right)."}
{degreeType === "odd" &&
lcSign === "neg" &&
"Ends go in OPPOSITE directions (Up Left, Down Right)."}