| Alternative 1 | |
|---|---|
| Accuracy | 87.7% |
| Cost | 7113 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-8} \lor \neg \left(y \leq 1.65 \cdot 10^{-28}\right):\\
\;\;\;\;x \cdot \frac{\sin y}{z \cdot y}\\
\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 (<= z -3e-12) (not (<= z 3.7e-14))) (/ (/ x (/ y (sin y))) z) (/ x (* y (/ z (sin 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 ((z <= -3e-12) || !(z <= 3.7e-14)) {
tmp = (x / (y / sin(y))) / z;
} else {
tmp = x / (y * (z / sin(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 ((z <= (-3d-12)) .or. (.not. (z <= 3.7d-14))) then
tmp = (x / (y / sin(y))) / z
else
tmp = x / (y * (z / sin(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 ((z <= -3e-12) || !(z <= 3.7e-14)) {
tmp = (x / (y / Math.sin(y))) / z;
} else {
tmp = x / (y * (z / Math.sin(y)));
}
return tmp;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
def code(x, y, z): tmp = 0 if (z <= -3e-12) or not (z <= 3.7e-14): tmp = (x / (y / math.sin(y))) / z else: tmp = x / (y * (z / math.sin(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 ((z <= -3e-12) || !(z <= 3.7e-14)) tmp = Float64(Float64(x / Float64(y / sin(y))) / z); else tmp = Float64(x / Float64(y * Float64(z / sin(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 ((z <= -3e-12) || ~((z <= 3.7e-14))) tmp = (x / (y / sin(y))) / z; else tmp = x / (y * (z / sin(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[z, -3e-12], N[Not[LessEqual[z, 3.7e-14]], $MachinePrecision]], N[(N[(x / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(y * N[(z / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-12} \lor \neg \left(z \leq 3.7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \frac{z}{\sin y}}\\
\end{array}
Results
| Original | 88.0% |
|---|---|
| Target | 91.5% |
| Herbie | 91.7% |
if z < -3.0000000000000001e-12 or 3.70000000000000001e-14 < z Initial program 99.8%
Applied egg-rr99.9%
[Start]99.8 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
clear-num [=>]99.8 | \[ \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}
\] |
un-div-inv [=>]99.9 | \[ \frac{\color{blue}{\frac{x}{\frac{y}{\sin y}}}}{z}
\] |
if -3.0000000000000001e-12 < z < 3.70000000000000001e-14Initial program 73.7%
Simplified80.7%
[Start]73.7 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
associate-/l* [=>]80.7 | \[ \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}
\] |
associate-/r/ [=>]80.7 | \[ \frac{x}{\color{blue}{\frac{z}{\sin y} \cdot y}}
\] |
Final simplification90.4%
| Alternative 1 | |
|---|---|
| Accuracy | 87.7% |
| Cost | 7113 |
| Alternative 2 | |
|---|---|
| Accuracy | 87.7% |
| Cost | 7113 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.0% |
| Cost | 7113 |
| Alternative 4 | |
|---|---|
| Accuracy | 91.0% |
| Cost | 7113 |
| Alternative 5 | |
|---|---|
| Accuracy | 87.8% |
| Cost | 7112 |
| Alternative 6 | |
|---|---|
| Accuracy | 59.5% |
| Cost | 968 |
| Alternative 7 | |
|---|---|
| Accuracy | 59.3% |
| Cost | 841 |
| Alternative 8 | |
|---|---|
| Accuracy | 59.3% |
| Cost | 840 |
| Alternative 9 | |
|---|---|
| Accuracy | 58.9% |
| Cost | 713 |
| Alternative 10 | |
|---|---|
| Accuracy | 51.7% |
| Cost | 712 |
| Alternative 11 | |
|---|---|
| Accuracy | 58.9% |
| Cost | 712 |
| Alternative 12 | |
|---|---|
| Accuracy | 59.5% |
| Cost | 704 |
| Alternative 13 | |
|---|---|
| Accuracy | 51.0% |
| Cost | 320 |
| Alternative 14 | |
|---|---|
| Accuracy | 51.1% |
| Cost | 192 |
herbie shell --seed 2023157
(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))