 
 (defn left-rule
   "Creates a lazy seque of points to evaluate a function at for a left rule riemann sum
-  Takes a number of particians"
-  [pieces]
-  (range 0 1 (/ 1 pieces)))
+  Takes a number of particians.
+  n defines how many elements in the lazy squence
+  low defines the lower bound of the range
+  high defines the upper bound of the range"
+  [n low high]
+  (range low high (/ (- high low) n)))
 
 (defn right-rule
   "Creates a lazy seque of points to evaluate a function at for a right rule riemann sum
-  Takes a number of particians"
-  [pieces]
-  (range (/ 1 pieces) (+ (/ 1 pieces) 1) (/ 1 pieces)))
+  Takes a number of particians
+  n defines how many elements in the lazy squence
+  low defines the lower bound of the range
+  high defines the upper bound of the range"
+  [n low high]
+  (range (/ (- high low) n) (+ high (/ (- high low) n)) (/ (- high low) n)))
 
 (defn middle-rule
   "Creates a lazy seque of points to evaluate a function at for a right middle riemann sum
   Takes a number of particians"
-  [pieces]
-  (range (/ 1 (* 2 pieces))
-         1
-         (/ 1 pieces)))
+  [n low high]
+  (range (/ (- high low) (* 2 n)) high (/ (- high low) n)))
 
 (defn integral-abstracted
   "Will do a riemann sum on the function:
   State will be a function, either left, right, or middle, based on the style of riemann sum.
   Pices is how boxes it makes, aka the resolution of the riemann sum"
-  [individual function state pieces]
-  (reduce #(+ %1 (* (/ 1 pieces) (function individual %2))) 0 (state pieces)))
+  [individual function state low high n]
+  (reduce #(+ %1 (* (/ (- high low) n) (function individual %2))) 0 (state n low high)))
 
 (defn integral-production
   "same as riemann sum but it might be faster, you need to figure out left, right, middle
-  functions on your own"
+  functions on your own. ONLY WORKS FROM RANGE 0 TO 1"
   [individual function start-x end-x increment pieces]
   (reduce #(+ %1 (* (/ 1 pieces) (function individual %2))) 0 (range start-x end-x increment)))
 
 (defn trapazoid-integral
-  [individual function pieces]
-  (* 0.5 (+ (integral-abstracted individual function left-rule pieces)
-            (integral-abstracted individual function right-rule pieces))))
+  [individual function low high n]
+  (* 0.5 (+ (integral-abstracted individual function left-rule low high n)
+            (integral-abstracted individual function right-rule low high n))))
 
 (defn simpson-integral
-  [individual function pieces]
-  (+ (/ (trapazoid-integral individual function (/ pieces 2)) 3)
-     (/ (* 2 (integral-abstracted individual function middle-rule (/ pieces 2))) 3)))
+  [individual function low high n]
+  (+ (/ (trapazoid-integral individual function low high (/ n 2)) 3)
+     (/ (* 2 (integral-abstracted individual function middle-rule low high (/ n 2))) 3)))
 
 (defn adjusted-upper-function
   "   /////   upper-surface-y-function * d/dx(upper-surface-x-function) /////

        theta-switch-constant (theta-switch individual)]
    (- attack-angle
       (* (/ 1 Math/PI)
          (+ (integral-production individual gradient-forward-polar-function 0 theta-switch-constant (/ theta-switch-constant 90) 90)
             (integral-production individual gradient-aft-polar-function theta-switch-constant Math/PI (/ (- Math/PI theta-switch-constant) 90) 90))))))

(defn A-1
  [individual run-constants]
  (let [theta-switch-constant (theta-switch individual)]
    (* (/ 2 Math/PI)
       (+ (integral-production individual gradient-forward-polar-function 0 theta-switch-constant (/ theta-switch-constant 90) 90)
          (integral-production individual gradient-aft-polar-function theta-switch-constant Math/PI (/ (- Math/PI theta-switch-constant) 90) 90)))))


(defn cambered-coefficient-of-lift

    (* (/ max-camber (Math/pow (- position-camber 1) 2))
       (+ (* -1 1) (* 2 position-camber) (* 1 (Math/cos theta-not))))))

(defn GFPCos
  [individual theta-not]
  (let [position-camber (individual :corrected-position-camber)
        max-camber (individual :corrected-max-camber)]
    (let [position-camber (individual :corrected-position-camber)
        max-camber (individual :corrected-max-camber)]
    (* (/ max-camber (Math/pow position-camber 2))
       (+ -1 (* 2 position-camber) (* 1 (Math/cos theta-not)))
       (Math/cos theta-not)))))

(defn GAPCos
  [individual theta-not]
  (let [position-camber (individual :corrected-position-camber)
        max-camber (individual :corrected-max-camber)]
    (* (/ max-camber (Math/pow (- position-camber 1) 2))
       (+ (* -1 1) (* 2 position-camber) (* 1 (Math/cos theta-not)))
       (Math/cos theta-not))))

(defn theta-switch
  "The angle at which the coefficient-of-lift calculation will switch from one integration to another
  arccos(1 - 2P)"
