(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (+ x y) (/ (* y (- z t)) (- a t)))) (t_2 (/ y (- t a))))
(if (<= t_1 -1.483738741544636e-277)
(+ x (* y (+ (/ z (- t a)) (- 1.0 (/ t (- t a))))))
(if (<= t_1 0.0)
(- (+ x (/ (* y z) t)) (/ (* y a) t))
(+ x (+ (* z t_2) (- y (* t t_2))))))))double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) - ((y * (z - t)) / (a - t));
double t_2 = y / (t - a);
double tmp;
if (t_1 <= -1.483738741544636e-277) {
tmp = x + (y * ((z / (t - a)) + (1.0 - (t / (t - a)))));
} else if (t_1 <= 0.0) {
tmp = (x + ((y * z) / t)) - ((y * a) / t);
} else {
tmp = x + ((z * t_2) + (y - (t * t_2)));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x + y) - (((z - t) * y) / (a - t))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x + y) - ((y * (z - t)) / (a - t))
t_2 = y / (t - a)
if (t_1 <= (-1.483738741544636d-277)) then
tmp = x + (y * ((z / (t - a)) + (1.0d0 - (t / (t - a)))))
else if (t_1 <= 0.0d0) then
tmp = (x + ((y * z) / t)) - ((y * a) / t)
else
tmp = x + ((z * t_2) + (y - (t * t_2)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) - ((y * (z - t)) / (a - t));
double t_2 = y / (t - a);
double tmp;
if (t_1 <= -1.483738741544636e-277) {
tmp = x + (y * ((z / (t - a)) + (1.0 - (t / (t - a)))));
} else if (t_1 <= 0.0) {
tmp = (x + ((y * z) / t)) - ((y * a) / t);
} else {
tmp = x + ((z * t_2) + (y - (t * t_2)));
}
return tmp;
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a): t_1 = (x + y) - ((y * (z - t)) / (a - t)) t_2 = y / (t - a) tmp = 0 if t_1 <= -1.483738741544636e-277: tmp = x + (y * ((z / (t - a)) + (1.0 - (t / (t - a))))) elif t_1 <= 0.0: tmp = (x + ((y * z) / t)) - ((y * a) / t) else: tmp = x + ((z * t_2) + (y - (t * t_2))) return tmp
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function code(x, y, z, t, a) t_1 = Float64(Float64(x + y) - Float64(Float64(y * Float64(z - t)) / Float64(a - t))) t_2 = Float64(y / Float64(t - a)) tmp = 0.0 if (t_1 <= -1.483738741544636e-277) tmp = Float64(x + Float64(y * Float64(Float64(z / Float64(t - a)) + Float64(1.0 - Float64(t / Float64(t - a)))))); elseif (t_1 <= 0.0) tmp = Float64(Float64(x + Float64(Float64(y * z) / t)) - Float64(Float64(y * a) / t)); else tmp = Float64(x + Float64(Float64(z * t_2) + Float64(y - Float64(t * t_2)))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
function tmp_2 = code(x, y, z, t, a) t_1 = (x + y) - ((y * (z - t)) / (a - t)); t_2 = y / (t - a); tmp = 0.0; if (t_1 <= -1.483738741544636e-277) tmp = x + (y * ((z / (t - a)) + (1.0 - (t / (t - a))))); elseif (t_1 <= 0.0) tmp = (x + ((y * z) / t)) - ((y * a) / t); else tmp = x + ((z * t_2) + (y - (t * t_2))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1.483738741544636e-277], N[(x + N[(y * N[(N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] - N[(N[(y * a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z * t$95$2), $MachinePrecision] + N[(y - N[(t * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t}\\
t_2 := \frac{y}{t - a}\\
\mathbf{if}\;t_1 \leq -1.483738741544636 \cdot 10^{-277}:\\
\;\;\;\;x + y \cdot \left(\frac{z}{t - a} + \left(1 - \frac{t}{t - a}\right)\right)\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\left(x + \frac{y \cdot z}{t}\right) - \frac{y \cdot a}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot t_2 + \left(y - t \cdot t_2\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 16.3 |
|---|---|
| Target | 7.9 |
| Herbie | 3.2 |
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -1.483738741544636e-277Initial program 12.5
Simplified4.8
Applied egg-rr4.7
Taylor expanded in y around 0 4.8
Simplified4.8
Applied egg-rr3.0
if -1.483738741544636e-277 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0Initial program 60.0
Simplified34.1
Applied egg-rr34.1
Taylor expanded in t around inf 0.9
if 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 12.4
Simplified4.8
Taylor expanded in z around 0 12.2
Simplified3.9
Final simplification3.2
herbie shell --seed 2022150
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))
(- (+ x y) (/ (* (- z t) y) (- a t))))