# Gradient-flow relaxation test (implicit backward Euler + Newton)
# Gradient-flow relaxation test (implicit backward Euler + Newton) # Enhanced with plotting and line-search fallback # Paste into Colab and run. Requires sympy, mpmath, matplotlib. import sympy as sp import mpmath as mp import json, math, os import matplotlib.pyplot as plt from pathlib import Path # ---------------- Config ---------------- WORKING_DPS = 100 PRINT_DPS = 40 mp.mp.dps = WORKING_DPS # time integration dt_base = mp.mpf('1e-2') max_steps = 200 tol_grad_norm = mp.mpf('1e-60') newton_tol = mp.mpf('1e-80') newton_maxsteps = 40 # eps sweep and perturb magnitudes eps_list = [mp.mpf('1e-8'), mp.mpf('1e-10'), mp.mpf('1e-12'), mp.mpf('1e-14')] perturb_mags = [mp.mpf('1e-6'), mp.mpf('1e-3'), mp.mpf('1e-1')] # Stationary point P* (from your sweep) Pstar = ( mp.mpf('0.138302189376114701435582507174521687560324629234971065651174620741053851929006740376715638479605537213341006758403870868'), ...