|
From: Philipp K. J. <ja...@ie...> - 2014-10-30 15:34:24
|
Apologies for the spam - this was supposed to go
to Christoph only.
It IS clever, though! ;-)
>
> > 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.
>
|