(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* z (/ x y)))))
(if (<= z -1.0563614392392175e-19)
t_0
(if (<= z 7.15187536954833e-11) (* x (- 1.0 (/ z y))) t_0))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double t_0 = x - (z * (x / y));
double tmp;
if (z <= -1.0563614392392175e-19) {
tmp = t_0;
} else if (z <= 7.15187536954833e-11) {
tmp = x * (1.0 - (z / y));
} else {
tmp = t_0;
}
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 * (y - z)) / y
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) :: tmp
t_0 = x - (z * (x / y))
if (z <= (-1.0563614392392175d-19)) then
tmp = t_0
else if (z <= 7.15187536954833d-11) then
tmp = x * (1.0d0 - (z / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
double t_0 = x - (z * (x / y));
double tmp;
if (z <= -1.0563614392392175e-19) {
tmp = t_0;
} else if (z <= 7.15187536954833e-11) {
tmp = x * (1.0 - (z / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return (x * (y - z)) / y
def code(x, y, z): t_0 = x - (z * (x / y)) tmp = 0 if z <= -1.0563614392392175e-19: tmp = t_0 elif z <= 7.15187536954833e-11: tmp = x * (1.0 - (z / y)) else: tmp = t_0 return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function code(x, y, z) t_0 = Float64(x - Float64(z * Float64(x / y))) tmp = 0.0 if (z <= -1.0563614392392175e-19) tmp = t_0; elseif (z <= 7.15187536954833e-11) tmp = Float64(x * Float64(1.0 - Float64(z / y))); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
function tmp_2 = code(x, y, z) t_0 = x - (z * (x / y)); tmp = 0.0; if (z <= -1.0563614392392175e-19) tmp = t_0; elseif (z <= 7.15187536954833e-11) tmp = x * (1.0 - (z / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0563614392392175e-19], t$95$0, If[LessEqual[z, 7.15187536954833e-11], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := x - z \cdot \frac{x}{y}\\
\mathbf{if}\;z \leq -1.0563614392392175 \cdot 10^{-19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 7.15187536954833 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 11.8 |
|---|---|
| Target | 3.2 |
| Herbie | 1.5 |
if z < -1.05636143923921748e-19 or 7.15187536954833e-11 < z Initial program 11.0
Simplified3.4
Taylor expanded in z around 0 6.8
Simplified3.2
if -1.05636143923921748e-19 < z < 7.15187536954833e-11Initial program 12.5
Simplified5.1
Taylor expanded in x around 0 0.1
Final simplification1.5
herbie shell --seed 2022146
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))