Gradient descent

Gradient descent preview
remixableManimCE3Doptimisationturntable

manim/gradient_descent.py

"""Gradient descent: a ball stepping down a loss surface into its basin.

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/gradient_descent.py GradientDescent
    ASSET_MODE=motion $P -m manim -qh   -r 1080,1080 manim/gradient_descent.py GradientDescentLoop
"""

import numpy as np
from manim import (
    DOWN,
    LEFT,
    UP,
    Dot,
    Line,
    Surface,

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