Name: Anonymous 2012-01-01 10:53
Can anone here explain to me how to find the computational complexity of Newtons Method for roots?
y = cube_root(x)
|
|
| ######
| #########
| ######
| ###
| ##
| ##
| #
|#
#
---------------------------------#------------------------------
#
#|
# |
## |
## |
### |
###### |
######## |
########## |
|
|
|
start point:
|
|
| ######
| #########
| X#####
| ###
| ##
| ##
| #
|#
#
---------------------------------#------------------------------
#
#|
# |
## |
## |
### |
###### |
######## |
########## |
|
|
|
make tanget line:
| XXX
| XXX
| XXX ######
| XXX #########
| XXX#####
| XX###
| XXX##
XXX ##
XXX | #
XXX |#
XXX #
----------------------X----------#------------------------------
#
#|
# |
## |
## |
### |
###### |
######## |
########## |
|
|
|
new point at intersection with x axis:
| XXX
| XXX
| XXX ######
| XXX #########
| XXX#####
| XX###
| XXX##
XXX ##
XXX | #
XXX |#
XXX #
----------------------X----------#------------------------------
: #
: #|
: # |
: ## |
: ## |
: ### |
####O# |
######## |
########## |
|
|
|
next tangent line at new point:
| XXX
| XXX
| XXX ######
| XXX #########
| XXX#####
| XX###
| XXX##
XXX ##
XXX | #
XXX |#
XXX #
----------------------X----------#------------------------------O
: # OOOOOO
: #| OOOOOO
: # | OOOOOO
: ## | OOOOOO
: ## |OOOOOO
: ### OOOOOO
####OOOOOO |
######## |
########## |
|
|
|
start new point at intersection with x axis:
|
|
| ######Z
| ######### :
| XXX##### :
| XX### :
| XXX## :
XXX ## :
XXX | # :
XXX |# :
XXX # :
----------------------X----------#------------------------------O
: # OOOOOO
: #| OOOOOO
: # | OOOOOO
: ## | OOOOOO
: ## |OOOOOO
: ### OOOOOO
####OOOOOO |
######## |
########## |
|
|
|
make new tangent line
|
|
| ZZZZZZZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZ ######### :
ZZZZZZZZZZZZZZZ | XXX##### :
ZZZZZZZZZZZZZZZ | XX### :
ZZ | XXX## :
XXX ## :
(aw shucks) XXX | # :
XXX |# :
XXX # :
----------------------X----------#------------------------------O
: # OOOOOO
: #| OOOOOO
: # | OOOOOO
: ## | OOOOOO
: ## |OOOOOO
: ### OOOOOO
####OOOOOO |
######## |
########## |
|
|
|
Exercise 1.6. Alyssa P. Hacker doesn't see why if needs to be provided as a special form. ``Why can't I just define it as an ordinary procedure in terms of cond?'' she asks. Alyssa's friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if:
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
(else else-clause)))
Eva demonstrates the program for Alyssa:
(new-if (= 2 3) 0 5)
5
(new-if (= 1 1) 0 5)
0
Delighted, Alyssa uses new-if to rewrite the square-root program:
(define (sqrt-iter guess x)
(new-if (good-enough? guess x)
guess
(sqrt-iter (improve guess x)
x)))
What happens when Alyssa attempts to use this to compute square roots? Explain.
For example, we can compute the square root of 2 as follows. Suppose our initial guess is 1:
Guess Quotient Average
1 (2/1) = 2 ((2 + 1)/2) = 1.5
1.5 (2/1.5) = 1.3333 ((1.3333 + 1.5)/2) = 1.4167
1.4167 (2/1.4167) = 1.4118 ((1.4167 + 1.4118)/2) = 1.4142
1.4142 ... ...
Continuing this process, we obtain better and better approximations to the square root.