Last active
August 30, 2021 08:17
-
-
Save tonyg/c3815225e6d2c49ac12d8e52f22c8025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require tabular) | |
;; A floor of original length x | |
;; that expands by n | |
;; but is constrained to fit in a space of length x | |
;; will buckle. | |
;; | |
;; Let's approximate by treating the resulting shape as an isosceles | |
;; triangle instead of whatever curve will actually result. Call the | |
;; height of the triangle h. | |
;; | |
;; Split the triangle in half to get two right triangles; consider | |
;; just one. It will have sides ½x, h, and ½x + ½n. | |
;; | |
;; (½x + ½n)² = (½x)² + h² | |
;; (½x)² + ½xn + (½n)² = (½x)² + h² | |
;; ½xn + (½n)² = h² | |
;; ½n(x + ½n) = h² | |
(define (height x n) | |
(define half-n (/ n 2)) | |
(sqrt (* half-n (+ x half-n)))) | |
;; Units: metres. | |
;; | |
(->table #:columns (list 'x 'n 'h) | |
(for*/list [(n '(0.001 0.002 0.005 0.01 0.02)) | |
(x '(1 5 10))] | |
(list x n (height x n)))) | |
;; Huh, wow! | |
;; | |
;; x | n | h | |
;; ----------------------------- | |
;; | |
;; 1 |0.001|0.02236626924634504 | |
;; 5 |0.001|0.05000249993750312 | |
;; 10|0.001|0.07071244586351119 | |
;; | |
;; 1 |0.002|0.031638584039112745 | |
;; 5 |0.002|0.07071774883294858 | |
;; 10|0.002|0.10000499987500625 | |
;; | |
;; 1 |0.005|0.050062460986251965 | |
;; 5 |0.005|0.11183134623172522 | |
;; 10|0.005|0.15813364600868468 | |
;; | |
;; 1 |0.01 |0.07088723439378912 | |
;; 5 |0.01 |0.15819292019556375 | |
;; 10|0.01 |0.22366269246345044 | |
;; | |
;; 1 |0.02 |0.1004987562112089 | |
;; 5 |0.02 |0.2238302928559939 | |
;; 10|0.02 |0.3163858403911275 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment