Re: [R] Integrating functions / vector arithmetic

2010-11-19 Thread Erich Neuwirth
Some remarks: Why are you using assignments to indicate the return values of functions? This is R idiom: f-function(u){ f-0 for (j in 1:4){ f-f+coeff[j]*(zeta(j)(u)) } f } If you only want the inner product of 2 vector, outer probably is an overkill. g - function(u){ sum(coeff *

Re: [R] Integrating functions / vector arithmetic

2010-11-16 Thread Eduardo de Oliveira Horta
Thanks, I'll try that. Regarding your question Why are you using assignments to indicate the return values of functions?, I'd probably answer that it is a matlab vice... But I'll change my habits soon enough! Best regards, Eduardo Horta On Tue, Nov 16, 2010 at 12:27 PM, Erich Neuwirth

[R] Integrating functions / vector arithmetic

2010-11-15 Thread Eduardo de Oliveira Horta
Hello, I was trying to build some functions which I would like to integrate over an interval using the function 'integrate' from the 'stats' package. As an example, please consider the function h(u)=sin(pi*u) + sqrt(2)*sin(pi*2*u) + sqrt(3)*sin(pi*3*u) + 2*sin(pi*4*u) Two alternative ways to

Re: [R] Integrating functions / vector arithmetic

2010-11-15 Thread David Winsemius
On Nov 15, 2010, at 7:18 PM, Eduardo de Oliveira Horta wrote: Hello, I was trying to build some functions which I would like to integrate over an interval using the function 'integrate' from the 'stats' package. As an example, please consider the function h(u)=sin(pi*u) +

Re: [R] Integrating functions / vector arithmetic

2010-11-15 Thread Eduardo de Oliveira Horta
Thanks! Seems to work just fine! Best regards, Eduardo Horta On Mon, Nov 15, 2010 at 10:37 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 15, 2010, at 7:18 PM, Eduardo de Oliveira Horta wrote: Hello, I was trying to build some functions which I would like to integrate over an