mike1

0 Reputation

2 Badges

13 years, 234 days

MaplePrimes Activity


These are questions asked by mike1

This is the procedure for the question I posted on http://www.mapleprimes.com/questions/128600-Romberg-Approximation-Procedure-In-Maple?sq=128600 

Can anyone see where the problem is?

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;

Hey, I need to write a procedure to calculate the romberg approximation by combining the trapezium rule approximations. The command will be RombInt(f(x),a,b,m,n), where a and b are the 2 limits and m is a number more or equal to 0 which indicates the number of iterations and n is a integer more or equal to m. Also given is that when m=0, this approximation can be called TrapRule(f(x),2^n,a,b). (I have got the procedure for this traprule, if that helps)

So basically...

Hey, I have made this procedure for the trapezium rule but I get an error when I perform this calculation.

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*sum+f(b)):
return (k):
end proc:
When I try calculating (TrapRule(exp(x),4,-3,1)); I get 
Error, (in TrapRule...
Page 1 of 1