# Why trigonometric functions throw an error for Inf?

**URL:** <https://discourse.julialang.org/t/why-trigonometric-functions-throw-an-error-for-inf/113899>\
**Category:** General Usage\
**Tags:** trigonometry\
**Created:** [May 6, 2024, 12:00pm UTC](https://discourse.julialang.org/t/why-trigonometric-functions-throw-an-error-for-inf/113899 "2024-05-06T12:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [May 6, 2024, 12:00pm UTC](https://discourse.julialang.org/t/why-trigonometric-functions-throw-an-error-for-inf/113899/1 "2024-05-06T12:00:26Z")

</div>

I belive many other floating point functions just return `NaN` for fast results or IEEE floating point compliance for incompatible input values but `sin`, `cos` like trigonometric functions throw for `Inf` but also not throw for `NaN`. What is the reasoning for that?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 6, 2024, 12:13pm UTC](https://discourse.julialang.org/t/why-trigonometric-functions-throw-an-error-for-inf/113899/2 "2024-05-06T12:13:47Z")

</div>

See: [NaN vs wild (or, what's a DomainError, really?) · Issue #5234 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/5234)

Key quotes:

> Operations whose results would produce NaNs should throw `Exception`s if the cost of testing a NaN would not dominate the cost of the operation.

> NaN input can just propagate. We mostly don’t want to _produce_ NaNs from non-NaNs.

---

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [May 6, 2024, 12:18pm UTC](https://discourse.julialang.org/t/why-trigonometric-functions-throw-an-error-for-inf/113899/3 "2024-05-06T12:18:37Z")

</div>

Thanks for the quick answer.
