Question: Summation procedure

January 01 2013 Skyblue 10
Maple 15

0

Hello,

 

I would like to do the following procedure from a basic concept, but I can't figure out what I'm doing wrong (sorry for that, I'm a beginner). I have tried to look up some more information about procedures on the Help menu with no success. Here you have what I'm planning to do:

Considering the following function (which approximates the cosine function):

aprcos:=(x,n)->add((-1)^i*(x^(2*i)/(2*i)!),i=0..n)


I would like to create a procedure which gives the same results the function gives. Here you have one of my several attempts:

aprcos:=proc(x,n::nonnegint)
local resp,i;
resp:=0;
if n>=0 then
for i from 0 to n do
resp:=resp+((-1)^i*(x^(2*i)/(2*i)!);
end do;
end if;
resp;
end proc;

 However, Maple doesn't accept it, so I guess something must be wrong, even though I don't know what it is. I would be grateful if you could help me with this.

 

Thank  you very much for your attention.

 

Happy New Year 2013!

Please Wait...