(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
(FPCore (x y z t)
:precision binary64
(if (<= z -2.7e-93)
(* x (/ (- y z) (- t z)))
(if (<= z 2.5e-177)
(/ (- (* x y) (* z x)) (- t z))
(/ x (/ (- t z) (- y z))))))double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e-93) {
tmp = x * ((y - z) / (t - z));
} else if (z <= 2.5e-177) {
tmp = ((x * y) - (z * x)) / (t - z);
} else {
tmp = x / ((t - z) / (y - z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-2.7d-93)) then
tmp = x * ((y - z) / (t - z))
else if (z <= 2.5d-177) then
tmp = ((x * y) - (z * x)) / (t - z)
else
tmp = x / ((t - z) / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e-93) {
tmp = x * ((y - z) / (t - z));
} else if (z <= 2.5e-177) {
tmp = ((x * y) - (z * x)) / (t - z);
} else {
tmp = x / ((t - z) / (y - z));
}
return tmp;
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
def code(x, y, z, t): tmp = 0 if z <= -2.7e-93: tmp = x * ((y - z) / (t - z)) elif z <= 2.5e-177: tmp = ((x * y) - (z * x)) / (t - z) else: tmp = x / ((t - z) / (y - z)) return tmp
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function code(x, y, z, t) tmp = 0.0 if (z <= -2.7e-93) tmp = Float64(x * Float64(Float64(y - z) / Float64(t - z))); elseif (z <= 2.5e-177) tmp = Float64(Float64(Float64(x * y) - Float64(z * x)) / Float64(t - z)); else tmp = Float64(x / Float64(Float64(t - z) / Float64(y - z))); end return tmp end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.7e-93) tmp = x * ((y - z) / (t - z)); elseif (z <= 2.5e-177) tmp = ((x * y) - (z * x)) / (t - z); else tmp = x / ((t - z) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[z, -2.7e-93], N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.5e-177], N[(N[(N[(x * y), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot \left(y - z\right)}{t - z}
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-93}:\\
\;\;\;\;x \cdot \frac{y - z}{t - z}\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-177}:\\
\;\;\;\;\frac{x \cdot y - z \cdot x}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{t - z}{y - z}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 11.7 |
|---|---|
| Target | 2.2 |
| Herbie | 2.3 |
if z < -2.7000000000000001e-93Initial program 14.9
Simplified0.7
if -2.7000000000000001e-93 < z < 2.5e-177Initial program 6.0
Simplified5.7
Taylor expanded in x around 0 6.0
Simplified5.7
Taylor expanded in x around 0 6.0
Taylor expanded in y around 0 6.0
if 2.5e-177 < z Initial program 12.8
Simplified1.4
Taylor expanded in x around 0 12.8
Simplified1.3
Final simplification2.3
herbie shell --seed 2022166
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:herbie-target
(/ x (/ (- t z) (- y z)))
(/ (* x (- y z)) (- t z)))