Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
Last active June 2, 2026 10:34
Show Gist options
  • Select an option

  • Save pgtwitter/963b2d78f0645d14188c1b8339b6b474 to your computer and use it in GitHub Desktop.

Select an option

Save pgtwitter/963b2d78f0645d14188c1b8339b6b474 to your computer and use it in GitHub Desktop.
# %%
import matplotlib.pyplot as plt
import numpy as np
import sympy as sym
xs = np.arange(0, 10, 1E-2)
xs[0] = 1E-7
x = sym.Symbol('x')
def minusLn(x):
return -sym.log(x)
def minusExp(x):
return -sym.exp(x)
fig, ax = plt.subplots(figsize=(11.69, 8.27), dpi=600)
ys = x
for fn in [sym.sqrt, sym.atan, sym.cos, minusLn, minusLn, minusExp, sym.exp, sym.sqrt, minusLn, minusLn, sym.exp, sym.exp]:
ys = fn(ys)
ax.plot(xs, [ys.evalf(subs={x: v}) for v in xs], label=f'${sym.latex(ys)}$')
ax.set_ylim(-4, 8)
ax.set_xticks(range(11))
ax.set_yticks([x-4 for x in range(13)])
ax.grid()
ax.legend(loc='lower right')
ax.set_aspect('equal')
@pgtwitter

Copy link
Copy Markdown
Author
output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment