code: def bragg(X: np.ndarray) -> float:
      """
      Cost function for the Bragg mirror problem: maximizing the reflection
      when the refractive index are given for all the layers.
      Input: a vector whose components represent each the thickness of each
      layer.
      https://hal.archives-ouvertes.fr/hal-02613161
      """
      lam = 600
      bar = int(np.size(X) / 2)
      n = np.concatenate(([1], np.sqrt(X[0:bar]), [1.7320508075688772]))
      type_ = np.arange(0, bar + 2)
      hauteur = np.concatenate(([0], X[bar : 2 * bar], [0]))  # type: ignore
      tmp = np.tan(2 * np.pi * n[type_] * hauteur / lam)
      # Specific to this substrate.
      Z = n[-1]
      for k in range(np.size(type_) - 1, 0, -1):
          Z = (Z - 1j * n[type_[k]] * tmp[k]) / (
              1 - 1j * tmp[k] * Z / n[type_[k]]
          )
      # Specific to air.
      r = (1 - Z) / (1 + Z)
      c = np.real(1 - r * np.conj(r))
      return float(c)
  
file_path: nevergrad/nevergrad/functions/photonics/photonics.py
imports: import typing
  from pathlib import Path
  import numpy
  from scipy.linalg import toeplitz
label_desc: Use image node_id 1 for calling a global function with example usage: bragg(X) and returns: float