Language: C++

import numpy as np
import math

class GradientDescent:
    def __init__(self, f, df, eta=0.01, eps=1e-7):
        self.f = f    # 最適化する関数
        self.df = df    # 関数の勾配（１次導関数）
        self.eta = eta    # 学習率
        self.eps = eps    # 学習のストップ判定に用いる定数
        self.path = None    # 学習の経過、初期値は空

    def solve(self, x, count_max):
        path = []
        grad = self.df(x)    # 勾配
        path.append(x)
        count = 0
        # 多変数の場合のノルムの大きさとself.epsを比較
        # self.epsの二乗より大きい場合、xの更新を続ける
        while (grad**2).sum() > self.eps**2 and count < count_max:
            x = x - self.eta * grad
            grad = self.df(x)
            # print(x, grad)
            path.append(x)
            count += 1
        self.path_ = np.array(path)   # 学習の経過
        self.x_ = x    # 最適化された変数の値
        self.opt_ = f(x)    # 最適化後の f(x)の値
        self.grad_ = grad    # 最適化後の勾配
        
def f(xy):
    x = xy[0]
    y = xy[1]
    ret = 0.
    for i in range(n):
        dx, dy = x - p[i][0], y - p[i][1]
        ret = max(ret, dx**2 + dy**2)
    return math.sqrt(ret)

def df(xy):
    mu = 1e-7
    x = xy[0]
    y = xy[1]
    return np.array([(f([x + mu, y]) - f([x - mu, y])) / (2 * mu), (f([x, y + mu]) - f([x, y - mu])) / (2 * mu)])

n = int(input())
p = []
for i in range(n):
    xy = list(map(float, input().split()))
    p.append(xy)

gd = GradientDescent(f, df, eta=10.)
initial = np.array([500., 500.])
gd.solve(initial, 150)
xy = gd.x_
gd = GradientDescent(f, df, eta=1)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-1)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-2)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-3)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-4)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-5)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-6)
initial = np.array(xy)
gd.solve(initial, 50)
xy = gd.x_
gd = GradientDescent(f, df, eta=1e-7)
initial = np.array(xy)
gd.solve(initial, 50)

print(gd.opt_)

Compiler output:
a.cc:6:23: error: stray '#' in program
    6 |         self.f = f    # 最適化する関数
      |                       ^
a.cc:7:25: error: stray '#' in program
    7 |         self.df = df    # 関数の勾配（１次導関数）
      |                         ^
a.cc:8:27: error: stray '#' in program
    8 |         self.eta = eta    # 学習率
      |                           ^
a.cc:9:27: error: stray '#' in program
    9 |         self.eps = eps    # 学習のストップ判定に用いる定数
      |                           ^
a.cc:10:29: error: stray '#' in program
   10 |         self.path = None    # 学習の経過、初期値は空
      |                             ^
a.cc:10:31: error: extended character 、 is not valid in an identifier
   10 |         self.path = None    # 学習の経過、初期値は空
      |                               ^
a.cc:14:30: error: stray '#' in program
   14 |         grad = self.df(x)    # 勾配
      |                              ^
a.cc:17:11: error: invalid preprocessing directive #\U0000591a\U00005909\U00006570\U0000306e\U00005834\U00005408\U0000306e\U000030ce\U000030eb\U000030e0\U0000306e\U00005927\U0000304d\U00003055\U00003068self
   17 |         # 多変数の場合のノルムの大きさとself.epsを比較
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:18:11: error: invalid preprocessing directive #self
   18 |         # self.epsの二乗より大きい場合、xの更新を続ける
      |           ^~~~
a.cc:18:16: error: extended character 、 is not valid in an identifier
   18 |         # self.epsの二乗より大きい場合、xの更新を続ける
      |                ^
a.cc:22:15: error: invalid preprocessing directive #print
   22 |             # print(x, grad)
      |               ^~~~~
a.cc:25:39: error: stray '#' in program
   25 |         self.path_ = np.array(path)   # 学習の経過
      |                                       ^
a.cc:26:24: error: stray '#' in program
   26 |         self.x_ = x    # 最適化された変数の値
      |                        ^
a.cc:27:29: error: stray '#' in program
   27 |         self.opt_ = f(x)    # 最適化後の f(x)の値
      |                             ^
a.cc:28:30: error: stray '#' in program
   28 |         self.grad_ = grad    # 最適化後の勾配
      |                              ^
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'