| Alternative 1 | |
|---|---|
| Error | 4.6% |
| Cost | 7113 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-8} \lor \neg \left(y \leq 5.1 \cdot 10^{-23}\right):\\
\;\;\;\;x \cdot \frac{\sin y}{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
(let* ((t_0 (/ (sin y) y)) (t_1 (/ (* x t_0) z)))
(if (<= t_1 -5e-55)
(/ x (/ z t_0))
(if (<= t_1 2e-67) (* (sin y) (/ (/ x z) y)) t_1))))double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double t_1 = (x * t_0) / z;
double tmp;
if (t_1 <= -5e-55) {
tmp = x / (z / t_0);
} else if (t_1 <= 2e-67) {
tmp = sin(y) * ((x / z) / y);
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(y) / y
t_1 = (x * t_0) / z
if (t_1 <= (-5d-55)) then
tmp = x / (z / t_0)
else if (t_1 <= 2d-67) then
tmp = sin(y) * ((x / z) / y)
else
tmp = t_1
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 t_0 = Math.sin(y) / y;
double t_1 = (x * t_0) / z;
double tmp;
if (t_1 <= -5e-55) {
tmp = x / (z / t_0);
} else if (t_1 <= 2e-67) {
tmp = Math.sin(y) * ((x / z) / y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
def code(x, y, z): t_0 = math.sin(y) / y t_1 = (x * t_0) / z tmp = 0 if t_1 <= -5e-55: tmp = x / (z / t_0) elif t_1 <= 2e-67: tmp = math.sin(y) * ((x / z) / y) else: tmp = t_1 return tmp
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function code(x, y, z) t_0 = Float64(sin(y) / y) t_1 = Float64(Float64(x * t_0) / z) tmp = 0.0 if (t_1 <= -5e-55) tmp = Float64(x / Float64(z / t_0)); elseif (t_1 <= 2e-67) tmp = Float64(sin(y) * Float64(Float64(x / z) / y)); else tmp = t_1; end return tmp end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; t_1 = (x * t_0) / z; tmp = 0.0; if (t_1 <= -5e-55) tmp = x / (z / t_0); elseif (t_1 <= 2e-67) tmp = sin(y) * ((x / z) / y); else tmp = t_1; 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_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-55], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-67], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := \frac{x \cdot t_0}{z}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-55}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-67}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{z}}{y}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 4.15% |
|---|---|
| Target | 0.42% |
| Herbie | 0.38% |
if (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < -5.0000000000000002e-55Initial program 0.32
Simplified0.71
[Start]0.32 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
associate-/l* [=>]0.71 | \[ \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}
\] |
if -5.0000000000000002e-55 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < 1.99999999999999989e-67Initial program 7.09
Simplified7.6
[Start]7.09 | \[ \frac{x \cdot \frac{\sin y}{y}}{z}
\] |
|---|---|
associate-/l* [=>]7.6 | \[ \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}
\] |
Applied egg-rr0.27
if 1.99999999999999989e-67 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) Initial program 0.34
Final simplification0.38
| Alternative 1 | |
|---|---|
| Error | 4.6% |
| Cost | 7113 |
| Alternative 2 | |
|---|---|
| Error | 2.14% |
| Cost | 7113 |
| Alternative 3 | |
|---|---|
| Error | 4.35% |
| Cost | 7112 |
| Alternative 4 | |
|---|---|
| Error | 4.98% |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Error | 4.85% |
| Cost | 6980 |
| Alternative 6 | |
|---|---|
| Error | 34.65% |
| Cost | 1097 |
| Alternative 7 | |
|---|---|
| Error | 39.37% |
| Cost | 713 |
| Alternative 8 | |
|---|---|
| Error | 35.66% |
| Cost | 713 |
| Alternative 9 | |
|---|---|
| Error | 35.32% |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 43.97% |
| Cost | 192 |
herbie shell --seed 2023089
(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))