import React, { useState } from 'react'; const RemainderTheoremWidget: React.FC = () => { const [a, setA] = useState(2); // Dividing by (x - a) // Polynomial P(x) = x^3 - 3x^2 - x + 3 const calculateP = (x: number) => Math.pow(x, 3) - 3 * Math.pow(x, 2) - x + 3; const remainder = calculateP(a); // Visualization const width = 300; const height = 200; const rangeX = 4; const rangeY = 10; const scaleX = width / (rangeX * 2); const scaleY = height / (rangeY * 2); const centerX = width / 2; const centerY = height / 2; const toPx = (x: number, y: number) => ({ x: centerX + x * scaleX, y: centerY - y * scaleY }); const path = []; for(let x = -rangeX; x <= rangeX; x+=0.1) { const y = calculateP(x); if(Math.abs(y) <= rangeY) { path.push(toPx(x, y)); } } const pathD = `M ${path.map(p => `${p.x} ${p.y}`).join(' L ')}`; const point = toPx(a, remainder); return (
Polynomial
P(x) = x³ - 3x² - x + 3
Remainder Theorem Result
Remainder of P(x) ÷ (x - {a}) is P({a})
R = {remainder.toFixed(2)}