My task is to compare memoized integral and regular one. But I can't see effects of memoization in output. Maybe I did something wrong? Or maybe I shchould use another function for integral, not sin or cos but something heavy with thread/sleep or something
Here's my code:
(ns test0.core
  (:gen-class))

(def h 0.01)

(defn trapezoid [f h x1 x2]
  (* h (/ (+ (f x1) (f x2)) 2)))

;; Мемоизированная версия интеграции
(defn integrate-memoized [f h summ n]
  (let [x1 (* h n), x2 (* h (inc n))]
    (if (zero? n)
      summ
      (recur f h (+ summ (trapezoid f h x1 x2)) (dec n)))))

(defn integral-memoized [f h]
  (let [memo-f (memoize f)]
    (fn [x] (integrate-memoized memo-f h 0 (int (/ x h))))))

;; Обычная версия интеграции без мемоизации
(defn integrate-plain [f h summ n]
  (let [x1 (* h n), x2 (* h (inc n))]
    (if (zero? n)
      summ
      (recur f h (+ summ (trapezoid f h x1 x2)) (dec n)))))

(defn integral-plain [f h]
  (fn [x] (integrate-plain f h 0 (int (/ x h)))))


;; Версия с ленивыми последовательностями
(defn integrate-lazy [f h summ n]
  (let [x1 (* h n), x2 (* h (inc n))]
    (cons summ (lazy-seq (integrate-lazy f h (+ summ (trapezoid f h x1 x2)) (inc n))))))

(defn integral-lazy [f h]
  (let [sequence (integrate-lazy f h 0 0)]
    (fn [x] (nth sequence (dec (int (/ x h)))))))

;; Интегралы для cos и sin
(def integral-cosx-memoized (integral-memoized (fn [x] (Math/cos x)) h))
(def integral-sinx-memoized (integral-memoized (fn [x] (Math/sin x)) h))

(def integral-cosx-plain (integral-plain (fn [x] (Math/cos x)) h))
(def integral-sinx-plain (integral-plain (fn [x] (Math/sin x)) h))

(def integral-cosx-lazy (integral-lazy (fn [x] (Math/cos x)) h))
(def integral-sinx-lazy (integral-lazy (fn [x] (Math/sin x)) h))

(println "Сравнение производительности интегрирования:")
  
  ;; Сравнение для интеграла cosx
  (println "\nmem cos(x):")
  (time (integral-cosx-memoized 0.5))
  (time (integral-cosx-memoized 1))
  (time (integral-cosx-memoized 2))
  (time (integral-cosx-memoized 4))
  (time (integral-cosx-memoized 5))
  
  (println "\nreg cos(x):")
  (time (integral-cosx-plain 0.5))
  (time (integral-cosx-plain 1))
  (time (integral-cosx-plain 2))
  (time (integral-cosx-plain 4))
  (time (integral-cosx-plain 5))

  (println "\nlazy cos(x):")
  (time (integral-cosx-lazy 0.5))
  (time (integral-cosx-lazy 1))
  (time (integral-cosx-lazy 2))
  (time (integral-cosx-lazy 4))
  (time (integral-cosx-lazy 5))
  
  ;; Сравнение для интеграла sinx
  (println "\nmem sin(x):")
  (time (integral-sinx-memoized 0.5))
  (time (integral-sinx-memoized 1))
  (time (integral-sinx-memoized 2))
  (time (integral-sinx-memoized 4))
  (time (integral-sinx-memoized 5))
  
  (println "\nreg sin(x):")
  (time (integral-sinx-plain 0.5))
  (time (integral-sinx-plain 1))
  (time (integral-sinx-plain 2))
  (time (integral-sinx-plain 4))
  (time (integral-sinx-plain 5))

  (println "\nlazy sin(x):")
  (time (integral-sinx-lazy 0.5))
  (time (integral-sinx-lazy 1))
  (time (integral-sinx-lazy 2))
  (time (integral-sinx-lazy 4))
  (time (integral-sinx-lazy 5))

Here's output:
mem cos(x):
"Elapsed time: 17.52859 msecs"
"Elapsed time: 1.009707 msecs"
"Elapsed time: 1.130617 msecs"
"Elapsed time: 1.843007 msecs"
"Elapsed time: 1.075818 msecs"

reg cos(x):
"Elapsed time: 0.191552 msecs"
"Elapsed time: 0.134435 msecs"
"Elapsed time: 0.280298 msecs"
"Elapsed time: 16.599904 msecs"
"Elapsed time: 0.324947 msecs"

lazy cos(x):
"Elapsed time: 0.216109 msecs"
"Elapsed time: 0.106201 msecs"
"Elapsed time: 0.179592 msecs"
"Elapsed time: 0.446896 msecs"
"Elapsed time: 16.901995 msecs"

mem sin(x):
"Elapsed time: 0.287864 msecs"
"Elapsed time: 0.210541 msecs"
"Elapsed time: 0.385772 msecs"
"Elapsed time: 0.846531 msecs"
"Elapsed time: 17.008702 msecs"

reg sin(x):
"Elapsed time: 0.120517 msecs"
"Elapsed time: 0.18626 msecs"
"Elapsed time: 0.142876 msecs"
"Elapsed time: 0.251446 msecs"
"Elapsed time: 0.299387 msecs"

lazy sin(x):
"Elapsed time: 0.109487 msecs"
"Elapsed time: 0.082932 msecs"
"Elapsed time: 0.127553 msecs"
"Elapsed time: 0.266219 msecs"
"Elapsed time: 0.131542 msecs"