| Alternative 1 | |
|---|---|
| Accuracy | 32.5% |
| Cost | 6788 |
\[\begin{array}{l}
\mathbf{if}\;x \leq 5.9 \cdot 10^{+26}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot {y}^{3}\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
(FPCore (x y) :precision binary64 (* (/ (sin x) x) y))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
double code(double x, double y) {
return (sin(x) / x) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * y
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
public static double code(double x, double y) {
return (Math.sin(x) / x) * y;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
def code(x, y): return (math.sin(x) / x) * y
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function code(x, y) return Float64(Float64(sin(x) / x) * y) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
function tmp = code(x, y) tmp = (sin(x) / x) * y; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]
\frac{\sin x \cdot \sinh y}{x}
\frac{\sin x}{x} \cdot y
Results
| Original | 38.6% |
|---|---|
| Target | 49.4% |
| Herbie | 50.9% |
Initial program 37.6%
Simplified53.5%
[Start]37.6 | \[ \frac{\sin x \cdot \sinh y}{x}
\] |
|---|---|
associate-*l/ [<=]53.5 | \[ \color{blue}{\frac{\sin x}{x} \cdot \sinh y}
\] |
Taylor expanded in y around 0 54.8%
Final simplification54.8%
| Alternative 1 | |
|---|---|
| Accuracy | 32.5% |
| Cost | 6788 |
| Alternative 2 | |
|---|---|
| Accuracy | 50.0% |
| Cost | 6720 |
| Alternative 3 | |
|---|---|
| Accuracy | 27.8% |
| Cost | 64 |
herbie shell --seed 2023157
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))