   square-wave-series)
 
 ;;------------------------------------------------------------------------------
-;; Constants
+;; Mathy
 ;;------------------------------------------------------------------------------
 
 (def PI (aget js/Math "PI"))
+
+(defn cos [x]
+  (.cos js/Math x))
+
+(defn sin [x]
+  (.sin js/Math x))
 
 ;;------------------------------------------------------------------------------
 ;; Atoms

  (util/slider "#slider" {
    :value @slider-value
    :min 0
    :max 200
    :step 1
    :slide on-slide }))

;;------------------------------------------------------------------------------
;; Square Wave Series
;;------------------------------------------------------------------------------

(defn square-wave-cos-series [n]
  (let [z (/ n 100)]
  {
  :color "blue"
  :data [
    [(* -1 PI) (- -1.2 z)]
    [(/ (* -1 PI) 2) (+ -1.2 z)]
    [(/ (* -1 PI) 2) (+ 1.2 z)]
    [(/ PI 2) (+ 1.2 z)]
    [(/ PI 2) (+ -1.2 z)]
    [PI (- -1.2 z)]]}))

(defn square-wave-sin-series [n]
  (let [z (/ n 200)]
  {
  :color "yellow"
  :data [
    [(* -1 PI) (- -1.2 z)]
    [(/ (* -1 PI) 2) (+ -1.2 z)]
    [(/ (* -1 PI) 2) (+ 1.2 z)]
    [(/ PI 2) (+ 1.2 z)]
    [(/ PI 2) (+ -1.2 z)]
    [PI (- -1.2 z)]]}))

(def square-wave-reference-series {
  :color "orange"

    [(/ PI 2) -1]
    [PI -1]]})

(defn square-wave-cos-series [n]
  { :color "blue"
    :data (square-wave-cos-data n) })

(defn square-wave-best-fit-series [n]
  { :color "red"
    :data (square-wave-best-fit-data n) })

(defn square-wave-series [n]
  (clj->js [
    square-wave-reference-series
    (square-wave-cos-series n)
    (square-wave-best-fit-series n)]))

;;------------------------------------------------------------------------------
;; Charts
