Jabz

433 Reputation

5 Badges

12 years, 296 days

MaplePrimes Activity


These are replies submitted by Jabz

Thank u.

I tried the help("printf"); first but i didn't really understand from the default examples but i understand from ur example thank  u again.

Thanx m8 i just typed it roughly to see if it worked but i will remember it

thanx

Thank u very much 4 the help much appriciated

Thank u very much 4 the help much appriciated

sorry put the wrong function in the last reply. This is the error that it showed when i put ur code in Maple12:

 

Bisection:=proc(a,b,f,epsilon)
     local A,B,c,err:
     A:=a:
     B:=b:
     err:=epsilon+1:
     while err>epsilon do:
           c:=(A+B)/2:
           if evalf(eval(f,x=A)*eval(f,x=c))<o then
                 B:=c:
                 err:evalf(abs(eval(f,x=c))):
            else
                 if evalf(eval(f,x=B)*eval(f,x=c))<0 then
                   A:=c:
                   err:evalf(abs(eval(f,x=c))):
                  else
                  if eval(f,x=c)=0 then
                         err:=0:
                       end if:
                 end if:
            end if:
        end do:
        print(evalf(c)):
end proc:
Bisection(Pi/3,3*Pi/2,sin(x),0.0001);
Error, (in Bisection) cannot determine if this expression is true or false: .2241438681 < o

 

sorry put the wrong function in the last reply. This is the error that it showed when i put ur code in Maple12:

 

Bisection:=proc(a,b,f,epsilon)
     local A,B,c,err:
     A:=a:
     B:=b:
     err:=epsilon+1:
     while err>epsilon do:
           c:=(A+B)/2:
           if evalf(eval(f,x=A)*eval(f,x=c))<o then
                 B:=c:
                 err:evalf(abs(eval(f,x=c))):
            else
                 if evalf(eval(f,x=B)*eval(f,x=c))<0 then
                   A:=c:
                   err:evalf(abs(eval(f,x=c))):
                  else
                  if eval(f,x=c)=0 then
                         err:=0:
                       end if:
                 end if:
            end if:
        end do:
        print(evalf(c)):
end proc:
Bisection(Pi/3,3*Pi/2,sin(x),0.0001);
Error, (in Bisection) cannot determine if this expression is true or false: .2241438681 < o

 

"while sign(f(b)) <> sign(f(c)) do"

This line was suppose to mean that `do the iterations until both signs are equal`
I am having trouble with the continuity of the program. It only works out (a+b)/2 once and then stops or goes to infinite loops.

"while sign(f(b)) <> sign(f(c)) do"

This line was suppose to mean that `do the iterations until both signs are equal`
I am having trouble with the continuity of the program. It only works out (a+b)/2 once and then stops or goes to infinite loops.

Thank so very much 4 ur help but am afraid ur code didnt work on the version of maple that am using. When i inputed ur code an error came up. This error is very similar to the error that i get. Here take a look:

 

Bisection:=proc(a,b,f,epsilon)
     local A,B,c,err:
     A:=a:
     B:=b:
     err:=epsilon+1:
     while err>epsilon do:
           c:=(A+B)/2:
           if evalf(eval(f,x=A)*eval(f,x=c))<o then
                 B:=c:
                 err:evalf(abs(eval(f,x=c))):
            else
                 if evalf(eval(f,x=B)*eval(f,x=c))<0 then
                   A:=c:
                   err:evalf(abs(eval(f,x=c))):
                  else
                  if eval(f,x=c)=0 then
                         err:=0:
                       end if:
                 end if:
            end if:
        end do:
        return evalf(c):
end proc:
Bisection(2,3,x^3-x-8,0.0001);
Error, (in Bisection) cannot determine if this expression is true or false: -10.25000000 < o


Thank so very much 4 ur help but am afraid ur code didnt work on the version of maple that am using. When i inputed ur code an error came up. This error is very similar to the error that i get. Here take a look:

 

Bisection:=proc(a,b,f,epsilon)
     local A,B,c,err:
     A:=a:
     B:=b:
     err:=epsilon+1:
     while err>epsilon do:
           c:=(A+B)/2:
           if evalf(eval(f,x=A)*eval(f,x=c))<o then
                 B:=c:
                 err:evalf(abs(eval(f,x=c))):
            else
                 if evalf(eval(f,x=B)*eval(f,x=c))<0 then
                   A:=c:
                   err:evalf(abs(eval(f,x=c))):
                  else
                  if eval(f,x=c)=0 then
                         err:=0:
                       end if:
                 end if:
            end if:
        end do:
        return evalf(c):
end proc:
Bisection(2,3,x^3-x-8,0.0001);
Error, (in Bisection) cannot determine if this expression is true or false: -10.25000000 < o


First 7 8 9 Page 9 of 9