|
From: Philipp K. J. <ja...@ie...> - 2014-10-30 15:00:27
|
On Thu, 30 Oct 2014 09:44:48 +0100
Christoph Bersch <us...@be...> wrote:
> Zitat von "Philipp K. Janert" <ja...@ie...>:
> > f(x) = cos(x)
> > steps=0; x=0.5; eps=1e-6
> >
> > while( abs(f(x)) > 1e-10 ) {
> > x = x - eps*f(x)/( f(x+eps) - f(x) )
> > steps = steps + 1
> > }
> >
> > print steps, x
>
> g(x) = cos(x)
> h(x) = (abs(g(x)) < 1e-10) ? x : h(x - eps*g(x)/(g(x + eps) - g(x)))
> x=0.5; eps=1e-6
> print h(x)
Clever, that! I didn't think of this.
|