Thank you again for your check. I plot the eval_g function, as you see below. It is smooth enough.
I also plot a tangent line when the slope is given by eval_jac_g, which uses an automatic gradient.
How do you see the figure? It confuses me very much…
Thank you again.
# --------------------------------------------------------------------------- #
# Plot the eval_g function
# --------------------------------------------------------------------------- #
krange = np.linspace(0.025, 0.2, 100)
eval_g_var = np.empty_like(krange)

# Compute the Jacobian on k=0.1
eval_jac_g_k = eval_jac_g(np.array([k]), False)
eval_g_k = eval_g(np.array([k]))
# Plot a tangent line
tan_k = eval_jac_g_k * (krange - k) + eval_g_k

for idx, var in enumerate(krange):
    eval_g_var[idx] = eval_g(np.array([var]))
plt.plot(krange, eval_g_var, 'k-', label=r'eval_g')
plt.plot(krange, tan_k, 'b-', label=r'eval_jac_g when $x=0.1$')
plt.xlabel(r"$x$")
plt.xlim([0.025, 0.2])
plt.legend(loc='best')
plt.show()

It produces: