From: Pat on
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
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
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
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
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.