
(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 10 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 92.4%
associate-*l/97.3%
Simplified97.3%
*-commutative97.3%
clear-num97.2%
un-div-inv97.3%
Applied egg-rr97.3%
Final simplification97.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -6.1e-34) (not (<= z 2e+116))) (+ x (/ z (/ a y))) (- x (* t (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -6.1e-34) || !(z <= 2e+116)) {
tmp = x + (z / (a / y));
} else {
tmp = x - (t * (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 <= (-6.1d-34)) .or. (.not. (z <= 2d+116))) then
tmp = x + (z / (a / y))
else
tmp = x - (t * (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 <= -6.1e-34) || !(z <= 2e+116)) {
tmp = x + (z / (a / y));
} else {
tmp = x - (t * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -6.1e-34) or not (z <= 2e+116): tmp = x + (z / (a / y)) else: tmp = x - (t * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -6.1e-34) || !(z <= 2e+116)) tmp = Float64(x + Float64(z / Float64(a / y))); else tmp = Float64(x - Float64(t * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -6.1e-34) || ~((z <= 2e+116))) tmp = x + (z / (a / y)); else tmp = x - (t * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -6.1e-34], N[Not[LessEqual[z, 2e+116]], $MachinePrecision]], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{-34} \lor \neg \left(z \leq 2 \cdot 10^{+116}\right):\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -6.0999999999999998e-34 or 2.00000000000000003e116 < z Initial program 89.9%
associate-*l/99.0%
Simplified99.0%
Taylor expanded in t around 0 81.8%
associate-*l/86.1%
*-commutative86.1%
Simplified86.1%
clear-num86.0%
un-div-inv86.1%
Applied egg-rr86.1%
if -6.0999999999999998e-34 < z < 2.00000000000000003e116Initial program 94.4%
associate-*l/96.0%
Simplified96.0%
Taylor expanded in z around 0 81.5%
mul-1-neg81.5%
associate-*l/85.6%
distribute-rgt-neg-out85.6%
+-commutative85.6%
*-commutative85.6%
distribute-lft-neg-out85.6%
unsub-neg85.6%
Simplified85.6%
Final simplification85.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.28e-33) (not (<= z 1.8e+118))) (+ x (/ z (/ a y))) (- x (/ t (/ a y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.28e-33) || !(z <= 1.8e+118)) {
tmp = x + (z / (a / y));
} else {
tmp = x - (t / (a / y));
}
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.28d-33)) .or. (.not. (z <= 1.8d+118))) then
tmp = x + (z / (a / y))
else
tmp = x - (t / (a / y))
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.28e-33) || !(z <= 1.8e+118)) {
tmp = x + (z / (a / y));
} else {
tmp = x - (t / (a / y));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.28e-33) or not (z <= 1.8e+118): tmp = x + (z / (a / y)) else: tmp = x - (t / (a / y)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.28e-33) || !(z <= 1.8e+118)) tmp = Float64(x + Float64(z / Float64(a / y))); else tmp = Float64(x - Float64(t / Float64(a / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.28e-33) || ~((z <= 1.8e+118))) tmp = x + (z / (a / y)); else tmp = x - (t / (a / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.28e-33], N[Not[LessEqual[z, 1.8e+118]], $MachinePrecision]], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(t / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.28 \cdot 10^{-33} \lor \neg \left(z \leq 1.8 \cdot 10^{+118}\right):\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\end{array}
\end{array}
if z < -1.28000000000000001e-33 or 1.8e118 < z Initial program 89.9%
associate-*l/99.0%
Simplified99.0%
Taylor expanded in t around 0 81.8%
associate-*l/86.1%
*-commutative86.1%
Simplified86.1%
clear-num86.0%
un-div-inv86.1%
Applied egg-rr86.1%
if -1.28000000000000001e-33 < z < 1.8e118Initial program 94.4%
associate-*l/96.0%
Simplified96.0%
*-commutative96.0%
clear-num95.9%
un-div-inv96.0%
Applied egg-rr96.0%
Taylor expanded in z around 0 81.5%
+-commutative81.5%
associate-*l/85.6%
neg-mul-185.6%
unsub-neg85.6%
associate-*l/81.5%
associate-*r/82.9%
Simplified82.9%
associate-*r/81.5%
*-commutative81.5%
associate-/l*85.6%
Applied egg-rr85.6%
Final simplification85.8%
(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 92.4%
associate-*l/97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ t a))))
double code(double x, double y, double z, double t, double a) {
return x + (y * (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 * (t / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * (t / a));
}
def code(x, y, z, t, a): return x + (y * (t / a))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(t / a))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * (t / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{t}{a}
\end{array}
Initial program 92.4%
associate-/l*93.1%
Simplified93.1%
Taylor expanded in z around 0 70.1%
associate-*r/70.1%
neg-mul-170.1%
Simplified70.1%
expm1-log1p-u50.2%
expm1-udef47.9%
associate-/r/48.5%
add-sqr-sqrt25.2%
sqrt-unprod43.5%
sqr-neg43.5%
sqrt-unprod19.9%
add-sqr-sqrt40.7%
Applied egg-rr40.7%
expm1-def40.7%
expm1-log1p42.8%
associate-*l/42.9%
associate-*r/42.9%
Simplified42.9%
Final simplification42.9%
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ z a))))
double code(double x, double y, double z, double t, double a) {
return x + (y * (z / 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 / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * (z / a));
}
def code(x, y, z, t, a): return x + (y * (z / a))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(z / a))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * (z / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z}{a}
\end{array}
Initial program 92.4%
associate-*l/97.3%
Simplified97.3%
*-commutative97.3%
clear-num97.2%
un-div-inv97.3%
Applied egg-rr97.3%
Taylor expanded in z around inf 71.8%
associate-*r/69.6%
Simplified69.6%
Final simplification69.6%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ a z))))
double code(double x, double y, double z, double t, double a) {
return x + (y / (a / z));
}
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 / (a / z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / (a / z));
}
def code(x, y, z, t, a): return x + (y / (a / z))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(a / z))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / (a / z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{a}{z}}
\end{array}
Initial program 92.4%
associate-/l*93.1%
Simplified93.1%
Taylor expanded in z around inf 69.9%
Final simplification69.9%
(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 92.4%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in t around 0 71.8%
associate-*l/72.9%
*-commutative72.9%
Simplified72.9%
Final simplification72.9%
(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 92.4%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in t around 0 71.8%
associate-*l/72.9%
*-commutative72.9%
Simplified72.9%
clear-num72.9%
un-div-inv72.9%
Applied egg-rr72.9%
Final simplification72.9%
(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 92.4%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in x around inf 42.0%
Final simplification42.0%
(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 2023228
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:herbie-target
(if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
(+ x (/ (* y (- z t)) a)))