Cost curve

Cost curve preview
remixableManimCE2Doptimisationloop

manim/cost_curve.py

"""Cost curve: gradient descent on one weight, the tangent riding the ball.

Render (the driver does this for every palette; these are for eyeballing):
    P=/opt/homebrew/opt/python@3.11/bin/python3.11
    ASSET_MODE=still  $P -m manim -s -r 1600,1600 manim/cost_curve.py CostCurve
    ASSET_MODE=motion $P -m manim -qh   -r 1080,1080 manim/cost_curve.py CostCurveLoop
"""

import numpy as np
from manim import (
    LEFT,
    RIGHT,
    UP,
    Arrow,
    DashedLine,
    Dot,

The full Manim source and the rendered video come with a plan.