Question: How do I correctly write a procedure that takes another procedure as an input?

I am new to Maple. I attempted to write a procedure that takes another procedure as input. It is not working correctly. As you can see from the output of a call to procedure A that something went wrong.
How do I do this correctly?
 

H := proc (n::integer)::real; local s, i; s := 0; for i by 2 to n do if i <= n-1 then s := s+1./((i*(i+1))) else s := s+1./i end if end do; return s end proc

A := proc (n::integer, T::procedure)::real; local d1, d2, s; d1 = T(n+1)-T(n); d2 = T(n+2)-T(n); s := T(n+1)-d1*d2/(d2-d1); return s end proc

proc (n::integer, T::procedure)::real; local d1, d2, s; d1 = T(n+1)-T(n); d2 = T(n+2)-T(n); s := T(n+1)-d1*d2/(d2-d1); return s end proc

(1)

H(11)

.7365440115

(2)

A(10, H)

.7365440115-d1*d2/(d2-d1)

(3)

``


 

Download st.mw

Please Wait...