|
From: Pat on 7 Jul 2008 13:19 Are cot, sec, and csc not a standard part of the math.h? It appears that way, but just wanted to double check before defining them in my code. Thanks. Pat
From: Jerry Coffin on 7 Jul 2008 13:22 In article <tdWdnW1LKtJm0u_VnZ2dnUVZ_rrinZ2d(a)insightbb.com>, pkelecy@_REMOVETHIS_gmail.com says... > Are cot, sec, and csc not a standard part of the math.h? No, they are not. -- Later, Jerry. The universe is a figment of its own imagination.
From: Richard Heathfield on 7 Jul 2008 13:46 Jerry Coffin said: > In article <tdWdnW1LKtJm0u_VnZ2dnUVZ_rrinZ2d(a)insightbb.com>, > pkelecy@_REMOVETHIS_gmail.com says... >> Are cot, sec, and csc not a standard part of the math.h? > > No, they are not. They are, however, easy to implement naively: #include <math.h> double cot(double z) { return 1.0 / tan(z); } double sec(double z) { return 1.0 / cos(z); } double csc(double z) { return 1.0 / sin(z); } Naturally, a more robust implementation would deal with range and domain errors. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet is a strange place" - dmr 29 July 1999
From: Pat on 7 Jul 2008 14:03 Jerry Coffin wrote: > In article <tdWdnW1LKtJm0u_VnZ2dnUVZ_rrinZ2d(a)insightbb.com>, > pkelecy@_REMOVETHIS_gmail.com says... >> Are cot, sec, and csc not a standard part of the math.h? > > No, they are not. > Thanks. That's what I thought.
From: Pat on 7 Jul 2008 14:09
Richard Heathfield wrote: > Jerry Coffin said: > >> In article <tdWdnW1LKtJm0u_VnZ2dnUVZ_rrinZ2d(a)insightbb.com>, >> pkelecy@_REMOVETHIS_gmail.com says... >>> Are cot, sec, and csc not a standard part of the math.h? >> No, they are not. > > They are, however, easy to implement naively: > > #include <math.h> > > double cot(double z) > { > return 1.0 / tan(z); > } > > double sec(double z) > { > return 1.0 / cos(z); > } > > double csc(double z) > { > return 1.0 / sin(z); > } > > Naturally, a more robust implementation would deal with range and domain > errors. > This is what I was planning to do. In some cases though I've decided it's better to just rewrite the expression in terms of sin, cos, and tan, and avoid the overhead of the function call. |