Skip to content

Commit

Permalink
math: test large negative values as args for trig functions
Browse files Browse the repository at this point in the history
Sin/Tan are odd, Cos is even, so it is easy to compute the correct
result from the positive argument case.

Change-Id: If851d00fc7f515ece8199cf56d21186ced51e94f
Reviewed-on: https://go-review.googlesource.com/c/go/+/509815
Run-TryBot: Keith Randall <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Srinivas Pokala <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
randall77 authored and bradfitz committed Aug 2, 2023
1 parent b82e7d4 commit 1d7212a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/math/huge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) {
if !close(f1, f2) {
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
}
f3 := Cos(-trigHuge[i])
if !close(f1, f3) {
t.Errorf("Cos(%g) = %g, want %g", -trigHuge[i], f3, f1)
}
}
}

Expand All @@ -91,6 +95,10 @@ func TestHugeSin(t *testing.T) {
if !close(f1, f2) {
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
}
f3 := Sin(-trigHuge[i])
if !close(-f1, f3) {
t.Errorf("Sin(%g) = %g, want %g", -trigHuge[i], f3, -f1)
}
}
}

Expand All @@ -101,6 +109,10 @@ func TestHugeSinCos(t *testing.T) {
if !close(f1, f2) || !close(g1, g2) {
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
}
f3, g3 := Sincos(-trigHuge[i])
if !close(-f1, f3) || !close(g1, g3) {
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", -trigHuge[i], f3, g3, -f1, g1)
}
}
}

Expand All @@ -111,5 +123,9 @@ func TestHugeTan(t *testing.T) {
if !close(f1, f2) {
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
}
f3 := Tan(-trigHuge[i])
if !close(-f1, f3) {
t.Errorf("Tan(%g) = %g, want %g", -trigHuge[i], f3, -f1)
}
}
}

0 comments on commit 1d7212a

Please sign in to comment.