(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
:precision binary64
(if (<= t -9.793361331116636e+146)
(+ x (* y (/ (- z x) t)))
(if (<= t 1.1791014341897874e-293)
(+ x (/ (- (* y z) (* y x)) t))
(+ x (* (/ y (sqrt t)) (/ (- z x) (sqrt t)))))))double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9.793361331116636e+146) {
tmp = x + (y * ((z - x) / t));
} else if (t <= 1.1791014341897874e-293) {
tmp = x + (((y * z) - (y * x)) / t);
} else {
tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t)));
}
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 - x)) / t)
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 (t <= (-9.793361331116636d+146)) then
tmp = x + (y * ((z - x) / t))
else if (t <= 1.1791014341897874d-293) then
tmp = x + (((y * z) - (y * x)) / t)
else
tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9.793361331116636e+146) {
tmp = x + (y * ((z - x) / t));
} else if (t <= 1.1791014341897874e-293) {
tmp = x + (((y * z) - (y * x)) / t);
} else {
tmp = x + ((y / Math.sqrt(t)) * ((z - x) / Math.sqrt(t)));
}
return tmp;
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
def code(x, y, z, t): tmp = 0 if t <= -9.793361331116636e+146: tmp = x + (y * ((z - x) / t)) elif t <= 1.1791014341897874e-293: tmp = x + (((y * z) - (y * x)) / t) else: tmp = x + ((y / math.sqrt(t)) * ((z - x) / math.sqrt(t))) return tmp
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function code(x, y, z, t) tmp = 0.0 if (t <= -9.793361331116636e+146) tmp = Float64(x + Float64(y * Float64(Float64(z - x) / t))); elseif (t <= 1.1791014341897874e-293) tmp = Float64(x + Float64(Float64(Float64(y * z) - Float64(y * x)) / t)); else tmp = Float64(x + Float64(Float64(y / sqrt(t)) * Float64(Float64(z - x) / sqrt(t)))); end return tmp end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -9.793361331116636e+146) tmp = x + (y * ((z - x) / t)); elseif (t <= 1.1791014341897874e-293) tmp = x + (((y * z) - (y * x)) / t); else tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[t, -9.793361331116636e+146], N[(x + N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.1791014341897874e-293], N[(x + N[(N[(N[(y * z), $MachinePrecision] - N[(y * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / N[Sqrt[t], $MachinePrecision]), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] / N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -9.793361331116636 \cdot 10^{+146}:\\
\;\;\;\;x + y \cdot \frac{z - x}{t}\\
\mathbf{elif}\;t \leq 1.1791014341897874 \cdot 10^{-293}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\sqrt{t}} \cdot \frac{z - x}{\sqrt{t}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.3 |
|---|---|
| Target | 1.9 |
| Herbie | 3.0 |
if t < -9.7933613311166362e146Initial program 11.2
Simplified1.6
Applied fma-udef_binary641.6
if -9.7933613311166362e146 < t < 1.1791014341897874e-293Initial program 3.3
Simplified9.3
Applied fma-udef_binary649.3
Taylor expanded in t around inf 3.3
if 1.1791014341897874e-293 < t Initial program 6.6
Simplified6.1
Applied fma-udef_binary646.1
Applied add-sqr-sqrt_binary646.2
Applied *-un-lft-identity_binary646.2
Applied times-frac_binary646.2
Applied associate-*r*_binary643.4
Simplified3.3
Final simplification3.0
herbie shell --seed 2022131
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))