| Alternative 1 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 7113 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-8} \lor \neg \left(y \leq 1.4 \cdot 10^{-14}\right):\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
(FPCore (x y z) :precision binary64 (if (or (<= x -5e+73) (not (<= x 5e-121))) (/ (/ x (/ y (sin y))) z) (/ x (/ z (/ (sin y) y)))))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+73) || !(x <= 5e-121)) {
tmp = (x / (y / sin(y))) / z;
} else {
tmp = x / (z / (sin(y) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (sin(y) / y)) / z
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-5d+73)) .or. (.not. (x <= 5d-121))) then
tmp = (x / (y / sin(y))) / z
else
tmp = x / (z / (sin(y) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+73) || !(x <= 5e-121)) {
tmp = (x / (y / Math.sin(y))) / z;
} else {
tmp = x / (z / (Math.sin(y) / y));
}
return tmp;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
def code(x, y, z): tmp = 0 if (x <= -5e+73) or not (x <= 5e-121): tmp = (x / (y / math.sin(y))) / z else: tmp = x / (z / (math.sin(y) / y)) return tmp
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function code(x, y, z) tmp = 0.0 if ((x <= -5e+73) || !(x <= 5e-121)) tmp = Float64(Float64(x / Float64(y / sin(y))) / z); else tmp = Float64(x / Float64(z / Float64(sin(y) / y))); end return tmp end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5e+73) || ~((x <= 5e-121))) tmp = (x / (y / sin(y))) / z; else tmp = x / (z / (sin(y) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+73], N[Not[LessEqual[x, 5e-121]], $MachinePrecision]], N[(N[(x / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+73} \lor \neg \left(x \leq 5 \cdot 10^{-121}\right):\\
\;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\
\end{array}
Results
| Original | 96.5% |
|---|---|
| Target | 99.5% |
| Herbie | 99.2% |
if x < -4.99999999999999976e73 or 4.99999999999999989e-121 < x Initial program 99.0%
Applied egg-rr98.9%
[Start]99.0 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
clear-num [=>]98.8 | \[ \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}
\] |
un-div-inv [=>]98.9 | \[ \frac{\color{blue}{\frac{x}{\frac{y}{\sin y}}}}{z}
\] |
if -4.99999999999999976e73 < x < 4.99999999999999989e-121Initial program 94.1%
Simplified99.5%
[Start]94.1 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
associate-/l* [=>]99.5 | \[ \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}
\] |
Final simplification99.2%
| Alternative 1 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 7113 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 7113 |
| Alternative 3 | |
|---|---|
| Accuracy | 95.9% |
| Cost | 7112 |
| Alternative 4 | |
|---|---|
| Accuracy | 96.0% |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 6848 |
| Alternative 6 | |
|---|---|
| Accuracy | 64.4% |
| Cost | 968 |
| Alternative 7 | |
|---|---|
| Accuracy | 64.3% |
| Cost | 841 |
| Alternative 8 | |
|---|---|
| Accuracy | 64.3% |
| Cost | 840 |
| Alternative 9 | |
|---|---|
| Accuracy | 64.1% |
| Cost | 713 |
| Alternative 10 | |
|---|---|
| Accuracy | 57.1% |
| Cost | 712 |
| Alternative 11 | |
|---|---|
| Accuracy | 65.1% |
| Cost | 704 |
| Alternative 12 | |
|---|---|
| Accuracy | 55.8% |
| Cost | 192 |
herbie shell --seed 2023146
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))
(/ (* x (/ (sin y) y)) z))