Revision of 1.3.4 Procedures as Returned Values from 11 July 2009 - 9:46pm

The revisions let you track differences between multiple versions of a post.

Printer-friendly versionPrinter-friendly version


Exercise 1.40

Define a procedure cubic that can be used together with the newtons-method procedure in expressions of the form

(newtons-method (cubic a b c) 1)

to approximate zeros of the cubic x3 + ax2 + bx + c.

Exercise 1.41

Define a procedure double that takes a procedure of one argument as argument and returns a procedure that applies the original procedure twice. For example, if inc is a procedure that adds 1 to its argument, then (double inc) should be a procedure that adds 2. What value is returned by

(((double (double double)) inc) 5)

Exercise 1.42

Let f and g be two one-argument functions. The composition f after g is defined to be the function xf(g(x)). Define a procedure compose that implements composition. For example, if inc is a procedure that adds 1 to its argument,

((compose square inc) 6)

Exercise 1.43

If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f((f(x)))). For example, if f is the function xx + 1, then the nth repeated application of f is the function xx + n. If f is the operation of squaring a number, then the nth repeated application of f is the function that raises its argument to the 2nth power. Write a procedure that takes as inputs a procedure that computes f and a positive integer n and returns the procedure that computes the nth repeated application of f. Your procedure should be able to be used as follows:

((repeated square 2) 5)

Hint: You may find it convenient to use compose from exercise 1.42.

Exercise 1.44

The idea of smoothing a function is an important concept in signal processing. If f is a function and dx is some small number, then the smoothed version of f is the function whose value at a point x is the average of f(x - dx), f(x), and f(x + dx). Write a procedure smooth that takes as input a procedure that computes f and returns a procedure that computes the smoothed f. It is sometimes valuable to repeatedly smooth a function (that is, smooth the smoothed function, and so on) to obtained the n-fold smoothed function. Show how to generate the n-fold smoothed function of any given function using smooth and repeated from exercise 1.43.

Exercise 1.45

We saw in section 1.3.3 that attempting to compute square roots by naively finding a fixed point of yx/y does not converge, and that this can be fixed by average damping. The same method works for finding cube roots as fixed points of the average-damped yx/y2. Unfortunately, the process does not work for fourth roots — a single average damp is not enough to make a fixed-point search for yx/y3 converge. On the other hand, if we average damp twice (i.e., use the average damp of the average damp of x/y3) the fixed-point search does converge. Do some experiments to determine how many average damps are required to compute nth roots as a fixed-point search based upon repeated average damping of yx/yn-1. Use this to implement a simple procedure for computing nth roots using fixed-point, average-damp, and the repeated procedure of exercise 1.43. Assume that any arithmetic operations you need are available as primitives.

Exercise 1.46

Several of the numerical methods described in this chapter are instances of an extremely general computational strategy known as iterative improvement. Iterative improvement says that, to compute something, we start with an initial guess for the answer, test if the guess is good enough, and otherwise improve the guess and continue the process using the improved guess as the new guess. Write a procedure iterative-improve that takes two procedures as arguments: a method for telling whether a guess is good enough and a method for improving a guess. Iterative-improve should return as its value a procedure that takes a guess as argument and keeps improving the guess until it is good enough. Rewrite the sqrt procedure of section 1.1.7 and the fixed-point procedure of section 1.3.3 in terms of iterative-improve.


Louis Vuitton Outlet
Louis Vuitton Outlet

UGG Outlet…………
UGG Outlet

UGG Outlet
UGG Outlet

Louis Vuitton Outlet….…………………
Louis Vuitton Outlet

pandora charms
pandora charms

UGG Outlet……
UGG Outlet

UGGS On Sale
UGGS On Sale

UGG Outlet…………………………….………………]…………
UGG Outlet

1.3.4 Procedures as Returned Values | SICP in Clojure

While you buy the car parts store, if its a car shop dublin relatively common part.
There are lots of options out there and this is the least expensive way possible.

My homepage; serwisy samochodowe (

1.3.4 Procedures as Returned Values | SICP in Clojure

Hi, i think that i saw you visited my site thus i came to

1.3.4 Procedures as Returned Values | SICP in Clojure

There is definately a lot to know about this issue. I really like all the points you have made.

Here is my web site; Best gps 2014

1.3.4 Procedures as Returned Values | SICP in Clojure


1.3.4 Procedures as Returned Values | SICP in Clojure

Howdy terrific website! Does running a blog
such as this take a lot of work? I’ve absolutely no expertise
in coding however I was hoping to start my own blog in the near future.
Anyway, should you have any recommendations or tips for new
blog owners please share. I understand this is off subject
but I simply needed to ask. Thanks!

Also visit my homepage … 東京 テキサスホールデ

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <hr> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Adds typographic refinements.

More information about formatting options