"""
"Could we use different materials to create nonlinearities?"

Yes -- but material choice slides you ALONG the loss-vs-nonlinearity tradeoff rather
than lifting you off it. The standard figure of merit makes this explicit:

    FoM = n2 / (beta_TPA * lambda)

n2 = nonlinear refractive index (the Kerr effect you want)
beta_TPA = two-photon absorption (the loss that comes with it)
FoM < 1 means TPA eats the signal before you can accumulate a pi phase shift.
"""
LAM = 1.55e-6
MATS = [
    # name,                n2 (m^2/W),  beta_TPA (m/W), linear loss (dB/cm), note
    ("Silicon",             4.5e-18,    8.0e-12,   2.0,  "strong Kerr, strong TPA"),
    ("Silicon nitride",     2.5e-19,    1.0e-15,   0.1,  "low loss, WEAK Kerr"),
    ("Chalcogenide As2S3",  3.0e-18,    6.0e-14,   0.5,  "strong Kerr, low TPA"),
    ("Silica",              2.7e-20,    1.0e-16,   0.001,"almost no loss, almost no Kerr"),
    ("AlGaAs (BElow half-gap)", 1.6e-17, 1.0e-13,  1.0,  "very strong Kerr"),
]
print("=" * 86)
print("1. THE NONLINEAR FIGURE OF MERIT BARELY MOVES -- AND n2 x LOSS IS ~CONSERVED")
print("=" * 86)
print(f"\n{'material':>24} | {'n2 (m^2/W)':>12} | {'FoM':>8} | {'loss dB/cm':>10} | "
      f"{'n2 / loss':>12}")
print("-" * 86)
for name, n2, beta, loss, note in MATS:
    fom = n2 / (beta * LAM)
    print(f"{name:>24} | {n2:>12.2e} | {fom:>8.2f} | {loss:>10.3f} | {n2/loss:>12.2e}")
print("""
  Read the last column. Across five materials spanning ~600x in n2, the ratio of
  nonlinearity to linear loss stays within about an order of magnitude. Silicon gives
  you 18x the Kerr of silicon nitride and 20x the loss. Silica has essentially no loss
  and essentially no nonlinearity.

  Material choice is a SLIDE ALONG the tradeoff, not an escape from it. And the
  resonator version of the same statement is GATE7's energy-bandwidth product:
  boosting a weak nonlinearity with high Q costs exactly the bandwidth it buys.
""")

print("=" * 86)
print("2. THE VOCABULARY POINT THAT ACTUALLY MATTERS: POLYNOMIAL vs NOT")
print("=" * 86)
print("""
  Universal approximation holds for ANY NON-POLYNOMIAL activation
  (Leshno, Lin, Pinkus & Schocken, Neural Networks 1993). One nonlinearity suffices
  for expressivity; heterogeneity is not required for it.

  But note which physical nonlinearities are polynomial:

     |E|^2 photodetection      -> x^2            POLYNOMIAL
     chi^(2) frequency mixing  -> x^2 - like     POLYNOMIAL
     Kerr / chi^(3)            -> x^3 - like     POLYNOMIAL
     saturable absorption      -> x/(1+x)        NON-polynomial  <-- the one that matters
     phase-change (bistable)   -> step/hysteresis NON-polynomial

  A stack built only from |E|^2, chi^(2) and Kerr computes POLYNOMIALS OF BOUNDED
  DEGREE -- degree 2^d or 3^d after d layers, but still a polynomial. It is not a
  universal approximator, and polynomial networks are a known, and known-limited,
  function class.

  So the heterogeneous-material library has ONE structural requirement, and it is not
  "more variety":

      >>> at least one SATURATING (non-polynomial) element in the vocabulary. <<<

  Without it, all the material diversity in the world buys a bigger polynomial.
  With it, one such element already buys universality -- and the rest of the
  vocabulary is an empirical question, not a representational one.
""")
