Skip to content

Commit 99ddef0

Browse files
author
Michael Abbott
committed
001
0 parents  commit 99ddef0

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Bhāskara
2+
3+
Provides Bhaskara I's sine approximation formula
4+
5+
```julia
6+
sinπ(θ) = 16-θ)θ / (5π^2 - 4-θ)θ) # < 0.1% error, θ ∈ [0,π]
7+
```
8+
9+
There is also `sin2π(θ)` for `θ ∈ [-π,π]`, and `Bhaskara.sin(θ)` for `θ ∈ 𝐑`,
10+
by inserting appropriate `mod(,2π)` and `sign()*abs()` bits.
11+
12+
Similarly `cosπ(θ)` is for `θ ∈ [-π/2,π/2]`, and `Bhaskara.cos(θ)` for `θ ∈ 𝐑`.

src/Bhaskara.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module Bhaskara
2+
3+
export sinπ, sin2π, cosπ, sind180
4+
5+
6+
sinπ(θ) = 16-θ)θ / (5π^2 - 4-θ)θ)
7+
8+
sin2π(θ) = sign(θ) * sinπ(abs(θ))
9+
10+
sin::T) where T<:Number = sin2π(mod+π, T(2)*π) - π)
11+
12+
13+
sind180(x) = 4(180-x)x / (40500 - (180-x)x)
14+
15+
sind360(x) = sign(x) * sin180(abs(x))
16+
17+
sind(x::Number) = sind360(mod(x+180,360)-180)
18+
19+
20+
cosπ(θ) =^2 - 4θ^2) /^2+θ^2)
21+
22+
cos::T) where T<:Number = sin2π(mod+π/T(2), T(2)*π) - π)
23+
24+
25+
tan::Number) = sin(θ) / cos(θ)
26+
27+
end # module

0 commit comments

Comments
 (0)