## Numerical

 LA home Computing Algorithms  glossary  Numerical   Num.Errors   Polynomials   Stirling   Mean&S.D.   Integration   Segmentation   Superposition   Matrices   Eigen v.

### Solving Equations

A zero, `x`, of a real-valued continuous function, `f(x)`, i.e., such that `f(x)=0`, can be found by an application of the binary search algorithm. Values ‘`Lo`’ and ‘`Hi`’ are chosen such that (i) `Lo<Hi`, and (ii) `f(Lo)<0` and `f(Hi)>0` or v.v..

`Mid=(Lo+Hi)/2` and `f(Mid)` is computed. If `f(Mid)` has the same sign as `f(Lo)` then `Lo` is moved up to `Mid`. If it has the same sign as `f(Hi)` then `Hi` is moved down to `Mid`. The algorithm terminates when `Hi-Lo` is "small". It is not a good idea to wait until f(Mid)=0.

The HTML FORM below can be used to solve a cubic polynomial (we'll ignore the fact that there are better ways to solve cubics). Change the coefficients of the powers of x and click on the solve button to find a zero:

f(x)=x3+ x2+ x1+ =0
-trace
x  =  [  ]
f(x)=[  ]

### Exercises

1. Find a solution to x3+x2+x+1=0. What are the other two solutions?
2. Multiply out f(x)=(x-1)(x-2)(x-3), by hand, and use the FORM to find one of the solutions to f(x)=0.
3. What happens if the coefficient of x3 is set to zero, and the other coefficients are set to 1? Why does this happen? Could the problem be fixed?
www:
 The C++ Cookbook mastering the language

 © L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated), Created with "vi (Linux or Solaris)",  charset=iso-8859-1,  fetched Wednesday, 22-Nov-2017 19:08:08 EST.

 free: Linux, Ubuntu operating-sys, OpenOffice office-suite, The GIMP ~photoshop, Firefox web-browser, FlashBlock flash on/off.