| #21. PHATCATTTT |
| Published: 2026-09-14 [Mon] 02:07, by |
|
the tolerance I specified was kinda wide, which made the big number calculation off by a good amount (oops!). After reducing the tolerance to 0.000000000001 (rest of the code kept the same) i get the same result as my calculator (Casio fx-991EX). Dr racket seems to have rounded the small square roots output to 1e-7, im not sure if this is a fault in my code or just computer stuff (can anyone confirm?) also i noticed that if im just comparing the guesses,i dont need to square them and then divide. I also had redundant (abs ) functions in the code so heres an improvement (define (good-enough? guess x) (< (abs (- (/ guess (improve guess x)) 1)) 0.000000000001)) (sqrt 0.00000000000001) ;very small number test (sqrt 1000000000000000) ;very large number test outputs: 1e-7 31622776.601683907 |
| #19. Excercise 1.7 |
| Published: 2026-09-14 [Mon] 01:50, by |
|
The full code is VERY long and has multiple things needing to be defined so ill only post what was changed from the procedure defined in SICP. My thought process was: need to compare guesses, so need to know guess-1 and guess-2 modify the improve definition to "save" the old guess? (oh no...) OR just use (improve guess x) itself as the guess 2 then ;modified from 1.1.7 for Exercise 1.7 (define (good-enough? guess x) ;(< (abs (- (square guess) x)) 0.001));old/original code [from SICP] (< ;check if guess is within tolerance (abs ; stops it from breaking if it gives a negative number (- ;small difference between subsequent guesses => fraction ~1, so fraction-1 ~0 (/ (abs (square guess)) (abs (square (improve guess x)))) 1)) 0.001)) ... (sqrt 0.00000000000001) ;very small number test (sqrt 1000000000000000) ;very large number test answers were correct |
| #4. Chapter 1 |
| Published: 2026-09-08 [Tue] 19:21, by |
|
SICP chapter 1 > Building Abstractions with Procedures https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-9.html#%_chap_1 |
| #1. SICP : Let's Read! |
| Published: 2026-09-08 [Tue] 19:18, by |
|
> SICP Book: https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-4.html > SICP Lectures: https://www.youtube.com/playlist?list=PLE18841CABEA24090 > Racket Scheme https://racket-lang.org/download/ > SICP Racket https://docs.racket-lang.org/sicp-manual/Installation.html Let's embrace the tree structure of Pohon BBS. Top level comments for chapters of the book, replies to top level comments for discussions of the chapter. Comment #2 will be for general help installing Scheme Comment #3 will be for random Scheme discussion that doesn't fit into chapter discussion. Ready, start, go! |