- #1

m4r35n357

- 658

- 148

This is a brief interactive session using my ODE Playground, which is my repository of Automatic Differentiation code. It illustrates two solutions of ##\sqrt {2}##

Enjoy!

*with the user-specified function provided via a lambda*, using Newton's method and then bisection. Note that the user needs to provide no step sizes or other requirements or artifacts of numerical differencing, just the function itself!
Python:

```
$ ipython3
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from ad import *
ad module loaded
In [2]: from playground import *
playground module loaded
In [3]: Newton(lambda x: (x**2), x0=1.0, target=2.0)
Out[3]: ResultType(count=7, sense='', mode='ROOT', x=1.414213562373095, f=2.0000000000000004, dx=-1.5700924586837747e-16)
In [4]: bisect(lambda x: (x**2), xa=1.4, xb=1.5, target=2.0)
Out[4]: ResultType(count=38, sense='', mode='ROOT', x=1.4142135623733338, f=2.0000000000006755, dx=7.276401703393276e-13)
```

Last edited: