import numpy as np
import [Link] as plt
[Link]["[Link]"] = 120
def plot_fn(fn, title, x=[Link](-10,10,400)):
[Link]()
[Link](x, fn(x))
[Link](0, lw=1, color='gray')
[Link](0, lw=1, color='gray')
[Link](title)
[Link](True)
[Link]()
Linear and piecewise linear shapes
#1 Rising Line y = 2x + 1
plot_fn(lambda t : 2*t + 1, "Rising Line y = 2x + 1")
#2 Falling line y = -3x + 4
plot_fn(lambda t : -3*t + 4, "Falling line y = -3x + 4")
#3 Horizontal y = 5
plot_fn(lambda t: np.full_like(t,5), "Horizontal y = 5")
#4 Vertical (special - plotted via axvline)
[Link]; [Link](2); [Link]("Vertical line x = 2")
[Link](0,lw=1,color='gray'); [Link](-10,10); [Link](True);
[Link]()
#5 ReLUs
plot_fn(lambda t : [Link](0,t), "ReLU y = max(0,x)")
#6 Shifted ReLU
plot_fn(lambda t : [Link](-2,t), "Shifted ReLU y = mac(-2,x)")
#7 absolute values
plot_fn(lambda t : [Link](t), "V-shape y = |x|")
#8 Slanted V
plot_fn(lambda t : [Link](2*t - 3) + 1, "Slanted V y = |2x-3| + 1")
#9 piece-wise quadratic -> Linear
plot_fn(lambda t : [Link](t < 4, t**2 + 1, 2*t - 3), "Piecw-wise
hybrid x < 4 : x^2+1 else: 2x+3")
Quadratic and cubic shapes
#1 U-parabola
plot_fn(lambda t : t**2 - 3*t + 2, "U-parabola y = x² - 3x + 2")
# n parabola
plot_fn(lambda t : 9 - t**2, "n parabola y = 9 - x²")
#3 Rooted n parabola
plot_fn(lambda t : -(t - 1) * (t - 4), "Rooted n parabola y = -(x-1)
(x-4)")
#4 Shifted U
plot_fn(lambda t : (t + 2)**2 - 5, "Shifted U y = (x+2)² - 5")
#5 Monotonic Cubic
plot_fn(lambda t : 2*t**3 + 1, "Monotonic cubic y = 2x³ + 1")
#6 S-curve cubic
plot_fn(lambda t: t**3 - 7*t**2 + 12*t, "S-curve cubic y = x³ - 7x² +
12x")
#7 Basic symmetric cubic
plot_fn(lambda t : t**3, "Basic symmetric cubic y = x³")
Exponential and Logarithmic shapes
#1 Exponential growth
plot_fn(lambda t: 3**t, "Exponential growth y = 3^x")
#2 Super growth
plot_fn(lambda t: t * np.e**t + 2, "Super growth y = x·e^x + 2")
#3 Decay
plot_fn(lambda t: [Link](-t), "Decay y = e^(-x)")
#4 Exponential shrink
plot_fn(lambda t: 0.5**t, "Exponential shrink y = 0.5^x")
Logarithms (x must be > 0)
#5 log base 2
plot_fn(lambda t: np.log2(t), "Log base 2 y =
log₂(x)", [Link](0.01, 10, 400))
#6 Shifted log base 2
plot_fn(lambda t: np.log2(t - 3) + 5, "Shifted log₂(x-3) + 5",
[Link](3.01, 15, 400))
#7 Natural log
plot_fn(lambda t: [Link](t), "Natural log y = ln(x)",
[Link](0.01, 10, 400))
Sigmoid, Logistic and Hyperbolic Family S-Curves and Saturation zones
# 1. Sigmoid
plot_fn(lambda t: 1 / (1 + [Link](-t)), "Sigmoid y = 1 / (1 + e^{-
x})")
# 2. Shifted sigmoid
plot_fn(lambda t: 1 / (1 + [Link](-(3*t + 5))), "Shifted sigmoid y =
1 / (1 + e^{-(3x+5)})")
# 3. Tanh
plot_fn(lambda t: [Link](t), "Tanh y = tanh(x)")
# 4. Logistic symmetric form
plot_fn(lambda t: ([Link](t) - [Link](-t)) / ([Link](t) + [Link](-t)),
"Hyperbolic form y = (e^x - e^{-x}) / (e^x + e^{-x})")
# 5. x² inside sigmoid
plot_fn(lambda t: 1 / (1 + [Link](-t**2)), "Flattened-center sigmoid
y = 1 / (1 + e^{-x²})")
# 6. Reciprocal tanh (coth x)
plot_fn(lambda t: 1 / [Link](t), "Coth x y = 1 / tanh(x)",
[Link](-10, -0.1, 200))
Absolute Value & Piecewise Family — Kinks, Corners, and Hybrids
# 1. Basic V
plot_fn(lambda t: [Link](t), "Basic V-shape y = |x|")
# 2. Slanted V
plot_fn(lambda t: [Link](2*t - 3) + 1, "Shifted/slanted V y = |2x -
3| + 1")
# 3. Nested Abs
plot_fn(lambda t: [Link]([Link](t - 2) - 4), "Nested abs V y = ||x -
2| - 4|")
# 4. Piecewise U + Line
plot_fn(lambda t: [Link](t < 4, t**2 + 1, 2*t - 3), "Piecewise: x<4
→ U, else linear")
# 5. ReLU
plot_fn(lambda t: [Link](0, t), "ReLU y = max(0, x)")
# 6. Shifted ReLU
plot_fn(lambda t: [Link](-2, t), "Shifted ReLU y = max(-2, x)")
# 7. Triangle wave using mod
plot_fn(lambda t: -[Link](t % 4 - 2) + 2, "Triangle wave y = -|x%4 -
2| + 2")
Trigonometric Family — Waves, Oscillations & Periodic Patterns
# 1. Basic Sine
plot_fn(lambda t: [Link](t), "Sine wave y = sin(x)")
# 2. Cosine
plot_fn(lambda t: [Link](t), "Cosine wave y = cos(x)")
# 3. x·sin(x)
plot_fn(lambda t: t * [Link](t), "Modulated sine y = x·sin(x)")
# 4. sqrt(sin(x)) – only real if sin(x) ≥ 0
plot_fn(lambda t: [Link]([Link](0, [Link](t))), "√sin(x) – only
real for sin≥0")
# 5. Absolute sin
plot_fn(lambda t: [Link]([Link](t)), "Full-wave rectified y = |
sin(x)|")
# 6. sin²(x)
plot_fn(lambda t: ([Link](t))**2, "Sine squared y = sin²(x)")
# 7. Triangle wave (repeated V)
plot_fn(lambda t: -[Link](t % 4 - 2) + 2, "Triangle wave y = -|x%4 -
2| + 2")
# 8. Piecewise sine
plot_fn(lambda t: [Link](t < 0, 0, [Link](t)), "Piecewise sine: 0
when x<0, else sin(x)")
Exotic & Composite Forms — Rare Shapes from Function Combos
# 1. Inverse-exp wall
plot_fn(lambda t: 1 / (1 - [Link](-t**2)), "1 / (1 - e^{-x²})")
# 2. Gaussian bump
plot_fn(lambda t: [Link](-t**2), "Gaussian bell y = e^{-x²}")
# 3. Logistic with x²
plot_fn(lambda t: 1 / (1 + [Link](-t**2)), "Logistic x² y = 1 / (1 +
e^{-x²})")
# 4. Concave arch
plot_fn(lambda t: -t**2 + 1, "Inverted parabola y = -x² + 1")
# [Link] tanh
plot_fn(lambda t: 1 / [Link](t), "1 / tanh(x) – steep around 0",
[Link](-10, -0.1, 200))
# 6. Piecewise ReLU
plot_fn(lambda t: [Link](t > 0, t, 0), "Step ReLU y = x if x>0 else
0")
# 7. Piecewise: quad to line
plot_fn(lambda t: [Link](t >= 4, 2*t-3, t**2 + 1), "Hybrid: quad to
line")
plot_fn(lambda t: [Link]([Link](t) * [Link](-t**2)), "Sine · Gaussian
Envelope")
plot_fn(lambda t: 1 / (1 + [Link](t)**3), "Inverse cubic decay")
plot_fn(lambda t: t * [Link](t) * [Link](-t**2), "Wave packet")
1. Multivariable Surfaces (z = f(x, y))
import numpy as np
import [Link] as plt
from mpl_toolkits.mplot3d import Axes3D
x = y = [Link](-5, 5, 200)
X, Y = [Link](x, y)
fig = [Link](figsize=(6, 5))
ax = fig.add_subplot(111, projection='3d')
# Try different Z formulas:
Z = [Link]([Link](X**2 + Y**2)) # ripple surface
ax.plot_surface(X, Y, Z, cmap='viridis')
[Link]("z = sin(√(x² + y²))")
[Link]()
1. Decision Boundaries in 2D
x = y = [Link](-5, 5, 500)
X, Y = [Link](x, y)
Z = X**2 + Y**2 - 4 # Circle boundary (Z=0 is the boundary)
[Link](X, Y, Z, levels=[0], colors='red')
[Link]("Decision Boundary: x² + y² = 4")
[Link]().set_aspect('equal')
[Link](True)
[Link]()
1. Polar Plots & Parametric Curves
theta = [Link](0, 2*[Link], 500)
r = [Link](2*theta)
[Link](theta, r)
[Link]("Polar Plot: r = sin(2θ)")
[Link]()
t = [Link](0, 2*[Link], 500)
x = [Link](3*t)
y = [Link](4*t)
[Link](x, y)
[Link]("Lissajous Curve")
[Link]('equal')
[Link](True)
[Link]()