
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (- z t) (/ a y))))
double code(double x, double y, double z, double t, double a) {
return x + ((z - t) / (a / y));
}
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 + ((z - t) / (a / y))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((z - t) / (a / y));
}
def code(x, y, z, t, a): return x + ((z - t) / (a / y))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(z - t) / Float64(a / y))) end
function tmp = code(x, y, z, t, a) tmp = x + ((z - t) / (a / y)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z - t}{\frac{a}{y}}
\end{array}
Initial program 93.6%
associate-/l*92.2%
Simplified92.2%
add-cube-cbrt91.7%
pow391.8%
associate-*r/93.1%
*-commutative93.1%
associate-/l*96.7%
Applied egg-rr96.7%
rem-cube-cbrt97.3%
clear-num97.2%
un-div-inv97.6%
Applied egg-rr97.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.4e+60) (+ x (/ (* z y) a)) (if (<= z 4.6e+101) (- x (/ t (/ a y))) (+ x (* z (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e+60) {
tmp = x + ((z * y) / a);
} else if (z <= 4.6e+101) {
tmp = x - (t / (a / y));
} else {
tmp = x + (z * (y / a));
}
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
real(8) :: tmp
if (z <= (-2.4d+60)) then
tmp = x + ((z * y) / a)
else if (z <= 4.6d+101) then
tmp = x - (t / (a / y))
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e+60) {
tmp = x + ((z * y) / a);
} else if (z <= 4.6e+101) {
tmp = x - (t / (a / y));
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -2.4e+60: tmp = x + ((z * y) / a) elif z <= 4.6e+101: tmp = x - (t / (a / y)) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.4e+60) tmp = Float64(x + Float64(Float64(z * y) / a)); elseif (z <= 4.6e+101) tmp = Float64(x - Float64(t / Float64(a / y))); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -2.4e+60) tmp = x + ((z * y) / a); elseif (z <= 4.6e+101) tmp = x - (t / (a / y)); else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.4e+60], N[(x + N[(N[(z * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.6e+101], N[(x - N[(t / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+60}:\\
\;\;\;\;x + \frac{z \cdot y}{a}\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+101}:\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -2.4e60Initial program 97.1%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in z around inf 91.3%
if -2.4e60 < z < 4.6000000000000003e101Initial program 93.2%
*-commutative93.2%
associate-/l*97.4%
Applied egg-rr97.4%
Taylor expanded in z around 0 84.4%
associate-*l/84.5%
*-commutative84.5%
neg-mul-184.5%
sub-neg84.5%
*-commutative84.5%
associate-*l/84.4%
associate-*r/89.1%
Simplified89.1%
clear-num89.1%
div-inv89.1%
Applied egg-rr89.1%
if 4.6000000000000003e101 < z Initial program 87.7%
*-commutative87.7%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 83.6%
associate-*l/92.8%
*-commutative92.8%
Simplified92.8%
Final simplification90.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.55e+60) (+ x (/ (* z y) a)) (if (<= z 1.26e+99) (- x (* t (/ y a))) (+ x (* z (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.55e+60) {
tmp = x + ((z * y) / a);
} else if (z <= 1.26e+99) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z * (y / a));
}
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
real(8) :: tmp
if (z <= (-1.55d+60)) then
tmp = x + ((z * y) / a)
else if (z <= 1.26d+99) then
tmp = x - (t * (y / a))
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.55e+60) {
tmp = x + ((z * y) / a);
} else if (z <= 1.26e+99) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.55e+60: tmp = x + ((z * y) / a) elif z <= 1.26e+99: tmp = x - (t * (y / a)) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.55e+60) tmp = Float64(x + Float64(Float64(z * y) / a)); elseif (z <= 1.26e+99) tmp = Float64(x - Float64(t * Float64(y / a))); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.55e+60) tmp = x + ((z * y) / a); elseif (z <= 1.26e+99) tmp = x - (t * (y / a)); else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.55e+60], N[(x + N[(N[(z * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.26e+99], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+60}:\\
\;\;\;\;x + \frac{z \cdot y}{a}\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{+99}:\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -1.55e60Initial program 97.1%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in z around inf 91.3%
if -1.55e60 < z < 1.25999999999999996e99Initial program 93.2%
*-commutative93.2%
associate-/l*97.4%
Applied egg-rr97.4%
Taylor expanded in z around 0 84.4%
associate-*l/84.5%
*-commutative84.5%
neg-mul-184.5%
sub-neg84.5%
*-commutative84.5%
associate-*l/84.4%
associate-*r/89.1%
Simplified89.1%
if 1.25999999999999996e99 < z Initial program 87.7%
*-commutative87.7%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 83.6%
associate-*l/92.8%
*-commutative92.8%
Simplified92.8%
Final simplification90.1%
(FPCore (x y z t a) :precision binary64 (if (<= z 2.75e+141) (+ x (* y (/ (- z t) a))) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= 2.75e+141) {
tmp = x + (y * ((z - t) / a));
} else {
tmp = x + (z * (y / a));
}
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
real(8) :: tmp
if (z <= 2.75d+141) then
tmp = x + (y * ((z - t) / a))
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= 2.75e+141) {
tmp = x + (y * ((z - t) / a));
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= 2.75e+141: tmp = x + (y * ((z - t) / a)) else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= 2.75e+141) tmp = Float64(x + Float64(y * Float64(Float64(z - t) / a))); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= 2.75e+141) tmp = x + (y * ((z - t) / a)); else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, 2.75e+141], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.75 \cdot 10^{+141}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < 2.74999999999999984e141Initial program 94.5%
associate-/l*94.1%
Simplified94.1%
if 2.74999999999999984e141 < z Initial program 86.8%
*-commutative86.8%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 85.5%
associate-*l/95.3%
*-commutative95.3%
Simplified95.3%
(FPCore (x y z t a) :precision binary64 (+ x (* (- z t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / a));
}
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 + ((z - t) * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / a));
}
def code(x, y, z, t, a): return x + ((z - t) * (y / a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(z - t) * Float64(y / a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((z - t) * (y / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - t\right) \cdot \frac{y}{a}
\end{array}
Initial program 93.6%
*-commutative93.6%
associate-/l*97.3%
Applied egg-rr97.3%
(FPCore (x y z t a) :precision binary64 (+ x (/ z (/ a y))))
double code(double x, double y, double z, double t, double a) {
return x + (z / (a / y));
}
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 + (z / (a / y))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (z / (a / y));
}
def code(x, y, z, t, a): return x + (z / (a / y))
function code(x, y, z, t, a) return Float64(x + Float64(z / Float64(a / y))) end
function tmp = code(x, y, z, t, a) tmp = x + (z / (a / y)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z}{\frac{a}{y}}
\end{array}
Initial program 93.6%
*-commutative93.6%
associate-/l*97.3%
Applied egg-rr97.3%
clear-num97.2%
un-div-inv97.6%
sub-neg97.6%
add-sqr-sqrt41.3%
sqrt-unprod70.7%
sqr-neg70.7%
sqrt-unprod40.8%
add-sqr-sqrt68.5%
Applied egg-rr68.5%
Taylor expanded in z around inf 71.3%
(FPCore (x y z t a) :precision binary64 (+ x (* z (/ y a))))
double code(double x, double y, double z, double t, double a) {
return x + (z * (y / a));
}
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 + (z * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (z * (y / a));
}
def code(x, y, z, t, a): return x + (z * (y / a))
function code(x, y, z, t, a) return Float64(x + Float64(z * Float64(y / a))) end
function tmp = code(x, y, z, t, a) tmp = x + (z * (y / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \frac{y}{a}
\end{array}
Initial program 93.6%
*-commutative93.6%
associate-/l*97.3%
Applied egg-rr97.3%
Taylor expanded in z around inf 69.9%
associate-*l/71.0%
*-commutative71.0%
Simplified71.0%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.6%
associate-/l*92.2%
Simplified92.2%
Taylor expanded in x around inf 38.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ a (- z t))))
(if (< y -1.0761266216389975e-10)
(+ x (/ 1.0 (/ t_1 y)))
(if (< y 2.894426862792089e-49)
(+ x (/ (* y (- z t)) a))
(+ x (/ y t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / t_1);
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = a / (z - t)
if (y < (-1.0761266216389975d-10)) then
tmp = x + (1.0d0 / (t_1 / y))
else if (y < 2.894426862792089d-49) then
tmp = x + ((y * (z - t)) / a)
else
tmp = x + (y / t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / t_1);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = a / (z - t) tmp = 0 if y < -1.0761266216389975e-10: tmp = x + (1.0 / (t_1 / y)) elif y < 2.894426862792089e-49: tmp = x + ((y * (z - t)) / a) else: tmp = x + (y / t_1) return tmp
function code(x, y, z, t, a) t_1 = Float64(a / Float64(z - t)) tmp = 0.0 if (y < -1.0761266216389975e-10) tmp = Float64(x + Float64(1.0 / Float64(t_1 / y))); elseif (y < 2.894426862792089e-49) tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / a)); else tmp = Float64(x + Float64(y / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = a / (z - t); tmp = 0.0; if (y < -1.0761266216389975e-10) tmp = x + (1.0 / (t_1 / y)); elseif (y < 2.894426862792089e-49) tmp = x + ((y * (z - t)) / a); else tmp = x + (y / t_1); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -1.0761266216389975e-10], N[(x + N[(1.0 / N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[y, 2.894426862792089e-49], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{z - t}\\
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{t\_1}{y}}\\
\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t\_1}\\
\end{array}
\end{array}
herbie shell --seed 2024139
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:alt
(! :herbie-platform default (if (< y -430450648655599/4000000000000000000000000) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2894426862792089/10000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t)))))))
(+ x (/ (* y (- z t)) a)))