----- Original Message ----- 
From: "Ravi Varadhan" <[EMAIL PROTECTED]>
To: "'James Foadi'" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Thursday, July 05, 2007 9:37 PM
Subject: RE: [R] unexpected result in function valuation


> The problem is that you are dividing two numbers that are both very small.
> Any small imprecision in the denominator creates a big error.
>
> Here you can re-write your function using a trig identity to get accurate
> results:
>
> sinca <- function(N,th) {
> #return(sin((N+0.5)* th)/sin(0.5*th))
> return( (sin(N*th)/tan(th/2)) + cos(N*th))
> }
>
> This function works well, as you had expected.
>
> Ravi.
>

Rounding off errors and error propagation...
I forgot all about it...Sorry for wasting your time, but thanks a lot for 
your help, Brian, Jim and Ravi.

J

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to