Equation Solver
Finding polynomial coefficients using genetic algorithm.
Principle
Find coefficients a, b, c, d such that f(x) = ax³ + bx² + cx + d matches a target function.
Technique
- Representation: 4 real coefficients
- Selection: Tournament
- Crossover: Uniform (50% from each parent)
- Mutation: Gaussian (σ = 0.5)
- Fitness: -MSE (negative mean squared error)
Visualization
- Black curve: target function
- Blue curve: best approximation
- Auto-stop when error < 0.001
Generation Prompt
Create an equation solver demo using genetic algorithm.
Requirements:
- Find polynomial coefficients (ax³ + bx² + cx + d) matching a random target
- Population of 100 individuals, elite preservation
- Tournament selection, uniform crossover, Gaussian mutation
- Canvas visualization showing both curves (target in black, evolved in blue)
- Real-time stats: generation count and MSE
- Auto-stop when error < 0.00001
- Use the shared GA library (/_lib/ga_v1.js)
UI:
- Graph canvas 500x300
- Display equations (target and evolved)
- Start/Pause and Reset buttons
- Generation and Error statistics