Newton's Method

Newton invented another method for finding the root of a function. Newton's method exploits the idea of an approximation. To search a root of some function <#66698#><#36162#>f<#36162#><#66698#>, we start with a guess, say <#66699#><#36163#>r1<#36163#><#66699#>. Then we study the tangent of <#66700#><#36164#>f<#36164#><#66700#> at <#66701#><#36165#>r1<#36165#><#66701#>, that is, the line that goes through the Cartesian point (<#66702#><#36166#>r1<#36166#><#66702#>, <#66703#><#36167#>f(r1)<#36167#><#66703#>) and has the same slope as <#66704#><#36168#>f<#36168#><#66704#>. This tangent is a linear approximation of <#66705#><#36169#>f<#36169#><#66705#> and it has a root that is in many cases closer to the root of <#66706#><#36170#>f<#36170#><#66706#> than our original guess. Hence, by repeating this process sufficiently often, we can find an <#66707#><#36171#>r<#36171#><#66707#> for which <#66708#><#36172#>(f<#36172#>\ <#36173#>r)<#36173#><#66708#> is close to <#66709#><#36174#>0<#36174#><#66709#>. To translate this process description into Scheme, we follow the familiar process. The function---let's call it <#66710#><#36175#>newton<#36175#><#66710#> in honor of its inventor---consumes a function <#66711#><#36176#>f<#36176#><#66711#> and a number <#66712#><#36177#>r0<#36177#><#66712#>, the current guess. If <#66713#><#36178#>(f<#36178#>\ <#36179#>r0)<#36179#><#66713#> is close to <#66714#><#36180#>0<#36180#><#66714#>, the problem is solved. Of course, close to <#66715#><#36181#>0<#36181#><#66715#> could be mean <#66716#><#36182#>(f<#36182#>\ <#36183#>r0)<#36183#><#66716#> is a small positive number or a small negative number. Hence, we translate this idea into
<#36188#>(;SPMlt;=<#36188#> <#36189#>(abs<#36189#> <#36190#>(f<#36190#> <#36191#>r0))<#36191#> <#36192#>TOLERANCE)<#36192#>
That is, we determine whether the absolute value is small. The answer in this case is <#66717#><#36196#>r0<#36196#><#66717#>. The generative step of the algorithm consists of finding the root of the tangent of <#66718#><#36197#>f<#36197#><#66718#> at <#66719#><#36198#>r0<#36198#><#66719#>. It generates a new guess. By applying <#66720#><#36199#>newton<#36199#><#66720#> to this new guess, we resume the process with a hopefully better guess:
<#71515#>;; <#66721#><#36204#>newton<#36204#> <#36205#>:<#36205#> <#36206#>(number<#36206#> <#36207#><#36207#><#36208#>-;SPMgt;<#36208#><#36209#><#36209#> <#36210#>number)<#36210#> <#36211#>number<#36211#> <#36212#><#36212#><#36213#>-;SPMgt;<#36213#><#36214#><#36214#> <#36215#>number<#36215#><#66721#><#71515#>
<#71516#>;; to find a number <#66722#><#36216#>r<#36216#><#66722#> such that <#66723#><#36217#>(;SPMlt;<#36217#> <#36218#>(abs<#36218#> <#36219#>(f<#36219#> <#36220#>r))<#36220#> <#36221#>TOLERANCE)<#36221#><#66723#><#71516#> 
<#36222#>(d<#36222#><#36223#>efine<#36223#> <#36224#>(newton<#36224#> <#36225#>f<#36225#> <#36226#>r0)<#36226#> 
  <#36227#>(c<#36227#><#36228#>ond<#36228#> 
    <#36229#>[<#36229#><#36230#>(;SPMlt;=<#36230#> <#36231#>(abs<#36231#> <#36232#>(f<#36232#> <#36233#>r0))<#36233#> <#36234#>TOLERANCE)<#36234#> <#36235#>r0]<#36235#> 
    <#36236#>[<#36236#><#36237#>else<#36237#> <#36238#>(newton<#36238#> <#36239#>f<#36239#> <#36240#>(find-root-tangent<#36240#> <#36241#>f<#36241#> <#36242#>r0))]<#36242#><#36243#>))<#36243#> 
Since finding the root of a tangent is domain knowledge, we define a separate function for this purpose:
<#71517#>;; <#66724#><#36251#>find-root-tangent<#36251#> <#36252#>:<#36252#> <#36253#>(number<#36253#> <#36254#><#36254#><#36255#>-;SPMgt;<#36255#><#36256#><#36256#> <#36257#>number)<#36257#> <#36258#>number<#36258#> <#36259#><#36259#><#36260#>-;SPMgt;<#36260#><#36261#><#36261#> <#36262#>number<#36262#><#66724#><#71517#>
<#71518#>;; to find the root of the tagent of <#66725#><#36263#>f<#36263#><#66725#> at <#66726#><#36264#>r0<#36264#><#66726#><#71518#> 
<#36265#>(d<#36265#><#36266#>efine<#36266#> <#36267#>(find-root-tangent<#36267#> <#36268#>f<#36268#> <#36269#>r0)<#36269#> 
  <#36270#>(l<#36270#><#36271#>ocal<#36271#> <#36272#>((define<#36272#> <#36273#>(fprime<#36273#> <#36274#>(d/dx<#36274#> <#36275#>f))))<#36275#> 
    <#36276#>(-<#36276#> <#36277#>r0<#36277#> 
       <#36278#>(/<#36278#> <#36279#>(f<#36279#> <#36280#>r0)<#36280#> 
          <#36281#>(fprime<#36281#> <#36282#>r0)))))<#36282#> 
The function first computes <#66727#><#36286#>(d/dx<#36286#>\ <#36287#>f)<#36287#><#66727#>, that is, the derivative of <#66728#><#36288#>f<#36288#><#66728#> at <#66729#><#36289#>r0<#36289#><#66729#> (see~section~#secdiff1#36290>) at <#66730#><#36291#>r0<#36291#><#66730#>. The body of the <#66731#><#36292#>local<#36292#>-expression<#66731#> computes the root from the current guess, <#66732#><#36293#>(f<#36293#>\ <#36294#>r0)<#36294#><#66732#>, and the slope of <#66733#><#36295#>f<#36295#><#66733#> at <#66734#><#36296#>r0<#36296#><#66734#>. The most interesting aspect of <#66736#><#36303#>newton<#36303#><#66736#> is that, unlike all other functions we have discussed, it does <#36304#>not<#36304#> always terminate. Consider the following function:
<#71519#>;; <#66737#><#36309#>f<#36309#> <#36310#>:<#36310#> <#36311#>number<#36311#> <#36312#><#36312#><#36313#>-;SPMgt;<#36313#><#36314#><#36314#> <#36315#>number<#36315#><#66737#><#71519#>
<#36316#>(d<#36316#><#36317#>efine<#36317#> <#36318#>(f<#36318#> <#36319#>x)<#36319#> 
  <#36320#>(-<#36320#> <#36321#>(*<#36321#> <#36322#>x<#36322#> <#36323#>x)<#36323#> <#36324#>x<#36324#> <#36325#>1.8))<#36325#> 
A simple hand-calculation shows that its derivative is
<#71520#>;; <#66738#><#36333#>fprime<#36333#> <#36334#>:<#36334#> <#36335#>number<#36335#> <#36336#><#36336#><#36337#>-;SPMgt;<#36337#><#36338#><#36338#> <#36339#>number<#36339#><#66738#><#71520#>
<#36340#>(d<#36340#><#36341#>efine<#36341#> <#36342#>(fprime<#36342#> <#36343#>x)<#36343#> 
  <#36344#>(-<#36344#> <#36345#>(*<#36345#> <#36346#>2<#36346#> <#36347#>x)<#36347#> <#36348#>1))<#36348#> 
If we were to use <#66739#><#36352#>1/2<#36352#><#66739#> as the initial guess, we would have to find the root of a tangent with slope <#66740#><#36353#>0<#36353#><#66740#>, that is, a tangent that is parallel to the <#36354#>x<#36354#>-axis. Of course, such a tangent doesn't have a root. As a result, <#66741#><#36355#>find-root-of-tangent<#36355#><#66741#> cannot find a tangent and <#66742#><#36356#>newton<#36356#><#66742#> won't find a root.
<#36359#>Exercise 27.4.1<#36359#> Test <#66743#><#36361#>newton<#36361#><#66743#> with <#66744#><#36362#>f<#36362#><#66744#>. Use the initial guesses <#66745#><#36363#>1<#36363#><#66745#>, <#66746#><#36364#>2<#36364#><#66746#>, and <#66747#><#36365#>3<#36365#><#66747#>. Also use <#66748#><#36366#>find-root<#36366#><#66748#> from the preceding section to find a root. Use a hand-evaluation to determine how quickly <#66749#><#36367#>newton<#36367#><#66749#> finds a value close to the root (if it finds one). Compare <#66750#><#36368#>newton<#36368#><#66750#>'s behavior with <#66751#><#36369#>find-root<#36369#><#66751#>'s behavior. Employ the strategy of section~#secequaltest#36370> to formulate the tests as boolean-valued expressions.~ external Solution<#66752#><#66752#>