<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: SICP section 1.1</title>
	<atom:link href="http://eli.thegreenplace.net/2007/06/21/sicp-section-11/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Thu, 04 Dec 2008 01:11:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Mike Sluyter</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-125708</link>
		<dc:creator>Mike Sluyter</dc:creator>
		<pubDate>Thu, 14 Aug 2008 15:42:43 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-125708</guid>
		<description>Re: exercise 1.6. For a while I was mislead by the cond expression in new-if, thinking that somehow it was different from an 'if' expression, and that that was the essential issue. But it turns out that the actual body of new-if is  irrelevant. In fact, the infinite recursion will happen even if the definition of new-if is something like:

(define (new-if predicate then-clause else-clause) 17)

That is, even if new-if doesn't really do anything interesting (in this case, returns a constant), the problem will still occur, because its arguments will be evaluated in applicative order before the body of new-if is even reached.</description>
		<content:encoded><![CDATA[<p>Re: exercise 1.6. For a while I was mislead by the cond expression in new-if, thinking that somehow it was different from an &#8216;if&#8217; expression, and that that was the essential issue. But it turns out that the actual body of new-if is  irrelevant. In fact, the infinite recursion will happen even if the definition of new-if is something like:</p>
<p>(define (new-if predicate then-clause else-clause) 17)</p>
<p>That is, even if new-if doesn&#8217;t really do anything interesting (in this case, returns a constant), the problem will still occur, because its arguments will be evaluated in applicative order before the body of new-if is even reached.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aleix</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123364</link>
		<dc:creator>aleix</dc:creator>
		<pubDate>Thu, 03 Jul 2008 06:07:40 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123364</guid>
		<description>Hi again,

about the division by zero I commented above, forget it, it was an error of mine.

And about my "good-enough?" implementation, I think is much better as it doesn't suffer from my precision problem (at least not so much).</description>
		<content:encoded><![CDATA[<p>Hi again,</p>
<p>about the division by zero I commented above, forget it, it was an error of mine.</p>
<p>And about my &#8220;good-enough?&#8221; implementation, I think is much better as it doesn&#8217;t suffer from my precision problem (at least not so much).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aleix</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123349</link>
		<dc:creator>aleix</dc:creator>
		<pubDate>Wed, 02 Jul 2008 18:43:29 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123349</guid>
		<description>Uppps... sorry.

(define (square-root x)
  (sqrt-iter 1.0 0.0 x))

(define (sqrt-iter guess old-guess x)
  (if (good-enough? guess old-guess)
      guess
      (sqrt-iter (improve guess x) guess x)))

(define (improve guess x)
  (average guess (/ x guess)))

(define (average x y)
  (/ (+ x y) 2))

(define (good-enough? guess old-guess)
  (&#60; (abs (- guess old-guess)) 0.001))

This solves the problem for small numbers (except I still have a tolerance for the precision we want). Your "closed-enough?" suffers from divsion by zero for very small numbers (at least in DrScheme).

For large numbers, as you said, the problem is with floating point arithmetic, and this is because of the "improve" procedure. So, in my opinion, the problem is not solved even if we use this new method.

Is this correct?</description>
		<content:encoded><![CDATA[<p>Uppps&#8230; sorry.</p>
<p>(define (square-root x)<br />
  (sqrt-iter 1.0 0.0 x))</p>
<p>(define (sqrt-iter guess old-guess x)<br />
  (if (good-enough? guess old-guess)<br />
      guess<br />
      (sqrt-iter (improve guess x) guess x)))</p>
<p>(define (improve guess x)<br />
  (average guess (/ x guess)))</p>
<p>(define (average x y)<br />
  (/ (+ x y) 2))</p>
<p>(define (good-enough? guess old-guess)<br />
  (&lt; (abs (- guess old-guess)) 0.001))</p>
<p>This solves the problem for small numbers (except I still have a tolerance for the precision we want). Your &#8220;closed-enough?&#8221; suffers from divsion by zero for very small numbers (at least in DrScheme).</p>
<p>For large numbers, as you said, the problem is with floating point arithmetic, and this is because of the &#8220;improve&#8221; procedure. So, in my opinion, the problem is not solved even if we use this new method.</p>
<p>Is this correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aleix</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123348</link>
		<dc:creator>aleix</dc:creator>
		<pubDate>Wed, 02 Jul 2008 18:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-123348</guid>
		<description>Thank you very for all this stuff. A great work, really. I've also taken (or trying to) the challenge to read SICP and do the exercises (don't know if I'll get that far).

Just a note on Ex. 1.7. I have implemented it just by passing a new parameter "old-guess" to the sqrt-iter function:

(define (square-root x)
  (sqrt-iter 1.0 0.0 x))

(define (sqrt-iter guess old-guess x)
  (if (good-enough? guess old-guess)
      guess
      (sqrt-iter (improve guess x) guess x)))

(define (improve guess x)
  (average guess (/ x guess)))

(define (average x y)
  (/ (+ x y) 2))

(define (good-enough? guess old-guess)
  (</description>
		<content:encoded><![CDATA[<p>Thank you very for all this stuff. A great work, really. I&#8217;ve also taken (or trying to) the challenge to read SICP and do the exercises (don&#8217;t know if I&#8217;ll get that far).</p>
<p>Just a note on Ex. 1.7. I have implemented it just by passing a new parameter &#8220;old-guess&#8221; to the sqrt-iter function:</p>
<p>(define (square-root x)<br />
  (sqrt-iter 1.0 0.0 x))</p>
<p>(define (sqrt-iter guess old-guess x)<br />
  (if (good-enough? guess old-guess)<br />
      guess<br />
      (sqrt-iter (improve guess x) guess x)))</p>
<p>(define (improve guess x)<br />
  (average guess (/ x guess)))</p>
<p>(define (average x y)<br />
  (/ (+ x y) 2))</p>
<p>(define (good-enough? guess old-guess)<br />
  (</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-89415</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Mon, 26 Nov 2007 03:42:33 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-89415</guid>
		<description>I skipped the first 3 exercises because they seemed too trivial. Ex. 1.3 would't be different from the solution in C or C#, simply a "case" that finds out the two largest numbers and returns the required computation.</description>
		<content:encoded><![CDATA[<p>I skipped the first 3 exercises because they seemed too trivial. Ex. 1.3 would&#8217;t be different from the solution in C or C#, simply a &#8220;case&#8221; that finds out the two largest numbers and returns the required computation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alpinweis</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-89339</link>
		<dc:creator>Alpinweis</dc:creator>
		<pubDate>Sun, 25 Nov 2007 17:46:41 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-89339</guid>
		<description>Hi and greetings from Moldova! Glad I bumped into your lisp pages. I am a C&#38;C# programmer on my way through SICP myself (using CL) and just out of interest wanted to have a look  at your solution to ex 1.3, but haven't seen one. 
It's really useful what you do so keep up the good job!</description>
		<content:encoded><![CDATA[<p>Hi and greetings from Moldova! Glad I bumped into your lisp pages. I am a C&amp;C# programmer on my way through SICP myself (using CL) and just out of interest wanted to have a look  at your solution to ex 1.3, but haven&#8217;t seen one.<br />
It&#8217;s really useful what you do so keep up the good job!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lieven</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-58154</link>
		<dc:creator>Lieven</dc:creator>
		<pubDate>Wed, 27 Jun 2007 08:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-58154</guid>
		<description>As a style note, </description>
		<content:encoded><![CDATA[<p>As a style note,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-56761</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Thu, 21 Jun 2007 17:18:33 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-56761</guid>
		<description>How cool that you've found it only a few hours after the post ! 

I hope you enjoy the posts, and I hope I will write them consistently.</description>
		<content:encoded><![CDATA[<p>How cool that you&#8217;ve found it only a few hours after the post ! </p>
<p>I hope you enjoy the posts, and I hope I will write them consistently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Kappler</title>
		<link>http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-56652</link>
		<dc:creator>Thomas Kappler</dc:creator>
		<pubDate>Thu, 21 Jun 2007 09:00:38 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/06/21/sicp-section-11/#comment-56652</guid>
		<description>Hey, how cool to find this by accident (via technorati.com).  Over the last few years, I've been dabbling on and off in Scheme, and just recently I decided to work through SICP.  While I can only start in two months or so, I'll be following your endeavour and I'll get back to the posts when I'm at the corresponding position in the book (hopefully after doing the assignments!).

It's especially cool that you're doing it in CL, since I've been reading a lot about the differences between CL and Scheme and wondered which one to tackle.  That will give me some opportunity to compare.

Best,
Thomas</description>
		<content:encoded><![CDATA[<p>Hey, how cool to find this by accident (via technorati.com).  Over the last few years, I&#8217;ve been dabbling on and off in Scheme, and just recently I decided to work through SICP.  While I can only start in two months or so, I&#8217;ll be following your endeavour and I&#8217;ll get back to the posts when I&#8217;m at the corresponding position in the book (hopefully after doing the assignments!).</p>
<p>It&#8217;s especially cool that you&#8217;re doing it in CL, since I&#8217;ve been reading a lot about the differences between CL and Scheme and wondered which one to tackle.  That will give me some opportunity to compare.</p>
<p>Best,<br />
Thomas</p>
]]></content:encoded>
	</item>
</channel>
</rss>
