Skip to content
Back to formatted view

Raw Message

Message-ID: <5890A1CE-D8FF-4984-ABBD-50BE31DB0D71@xs4all.nl>
Date: 2012-11-29T20:12:38Z
From: Berend Hasselman
Subject: Help in Bissection algorithm
In-Reply-To: <1354202323742-4651295.post@n4.nabble.com>

On 29-11-2012, at 16:18, finehko wrote:

> I'm trying to make a function witch recieves a function "f", "a" and "b", and
> the error "e". When I run the algorithm without labeling it a function and
> typing the values it works, but when I just try to save it in a function It
> doesn't ' bug but don't do anything.

I don't understand what you mean with this: "doesn't ' bug but don't do anything" 

> Here's the code, anyone know whats
> happening?
> raiz=function(f,a,b,e){
>  repeat{
>    if(i>50){break}
>    if(abs(a-b)<e){m=(a+b)/2
>                  raiz1=m}
>    if(abs(a-b)>e){
>          m=(a+b)/2
>          af=f(a)
>           if((af*f(m))>0){a=m}
>           if((af*f(m))<0){b=m}}
>        i=i+1}}
> 

Initialize i before starting the repeat loop.
i <- 1

Berend