mike1

0 Reputation

2 Badges

13 years, 205 days

MaplePrimes Activity


These are replies submitted by mike1

I have corrected the "while" operation and changed the "N" to "n", so that its consistent and also made the changed to the error operation. But I don't get what you mean by the traprule. (My procedure for the traprule is working fine)

RombInt:=proc(f,a,b,m,n)
local j,k,R;
if type(m, numeric) then
if not type(m,nonnegint) then error "m must be a non-negative integer"; fi;fi;
if type(n, numeric) then
if not type(n,nonnegint) then error "n must be a non-negative integer";fi;fi;
if (m > n) then
error "parameter m must be less than or equal to n":
fi;
for k from 0 to m do
R[0,k]:=TrapRule(f,2^n,a,b); od;
for j from 1 to m do
for k from j to m do
R[j,k]:=1/(4^j-1)*(4^j*R[j-1,k+1]-R[j-1,k]);
od; od;
end proc:
& the TrapRule procedure is:
TrapRule:=proc(f,n,a,b)
local k,sum1,h,i:
h:=(b-a)/n:
sum1:=0:
for i from 1 by 1 to n-1 do
sum1:=sum1+f(a+i*h):
end do:
k:=(h/2)*(f(a)+2*sum1+f(b)):
return (k):
end proc:
Does the change from TrapRule(f,n,a,b) to TrapRule(f,2^n,a,b) matter?

After doing these little changes and evaluating RombInt(exp,-3,1,0,2);..I get no response and no error, it just goes on the next line?

I have corrected the "while" operation and changed the "N" to "n", so that its consistent and also made the changed to the error operation. But I don't get what you mean by the traprule. (My procedure for the traprule is working fine)

RombInt:=proc(f,a,b,m,n)
local j,k,R;
if type(m, numeric) then
if not type(m,nonnegint) then error "m must be a non-negative integer"; fi;fi;
if type(n, numeric) then
if not type(n,nonnegint) then error "n must be a non-negative integer";fi;fi;
if (m > n) then
error "parameter m must be less than or equal to n":
fi;
for k from 0 to m do
R[0,k]:=TrapRule(f,2^n,a,b); od;
for j from 1 to m do
for k from j to m do
R[j,k]:=1/(4^j-1)*(4^j*R[j-1,k+1]-R[j-1,k]);
od; od;
end proc:
& the TrapRule procedure is:
TrapRule:=proc(f,n,a,b)
local k,sum1,h,i:
h:=(b-a)/n:
sum1:=0:
for i from 1 by 1 to n-1 do
sum1:=sum1+f(a+i*h):
end do:
k:=(h/2)*(f(a)+2*sum1+f(b)):
return (k):
end proc:
Does the change from TrapRule(f,n,a,b) to TrapRule(f,2^n,a,b) matter?

After doing these little changes and evaluating RombInt(exp,-3,1,0,2);..I get no response and no error, it just goes on the next line?

Page 1 of 1