(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
(FPCore (x) :precision binary64 (tan (* x 0.5)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
double code(double x) {
return tan((x * 0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / sin(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x * 0.5d0))
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / Math.sin(x);
}
public static double code(double x) {
return Math.tan((x * 0.5));
}
def code(x): return (1.0 - math.cos(x)) / math.sin(x)
def code(x): return math.tan((x * 0.5))
function code(x) return Float64(Float64(1.0 - cos(x)) / sin(x)) end
function code(x) return tan(Float64(x * 0.5)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / sin(x); end
function tmp = code(x) tmp = tan((x * 0.5)); end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]
\frac{1 - \cos x}{\sin x}
\tan \left(x \cdot 0.5\right)
Results
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 30.0
Simplified0.0
herbie shell --seed 2023010
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))