Skip to content

Instantly share code, notes, and snippets.

@FunctionalFirst
Created January 18, 2012 21:54
Show Gist options
  • Save FunctionalFirst/1636040 to your computer and use it in GitHub Desktop.
Save FunctionalFirst/1636040 to your computer and use it in GitHub Desktop.
let inline cosine n (x:^a) : ^a =
let one = LanguagePrimitives.GenericOne
let two = one + one
Seq.unfold (fun (twoIp1, t) -> Some(t, (twoIp1+two, -t*x*x/(twoIp1*(twoIp1+one))))) (one,one)
|> Seq.take n
|> Seq.sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment