
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (- z x) (/ t y))))
double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
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 + ((z - x) / (t / y))
end function
public static double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
def code(x, y, z, t): return x + ((z - x) / (t / y))
function code(x, y, z, t) return Float64(x + Float64(Float64(z - x) / Float64(t / y))) end
function tmp = code(x, y, z, t) tmp = x + ((z - x) / (t / y)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z - x}{\frac{t}{y}}
\end{array}
Initial program 93.2%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.8
Applied egg-rr96.8%
lift-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6496.9
Applied egg-rr96.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (/ (* (- z x) y) t))) (t_2 (* y (/ (- z x) t)))) (if (<= t_1 -2e+266) t_2 (if (<= t_1 1e+293) (+ x (/ (* z y) t)) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = x + (((z - x) * y) / t);
double t_2 = y * ((z - x) / t);
double tmp;
if (t_1 <= -2e+266) {
tmp = t_2;
} else if (t_1 <= 1e+293) {
tmp = x + ((z * y) / t);
} else {
tmp = t_2;
}
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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x + (((z - x) * y) / t)
t_2 = y * ((z - x) / t)
if (t_1 <= (-2d+266)) then
tmp = t_2
else if (t_1 <= 1d+293) then
tmp = x + ((z * y) / t)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (((z - x) * y) / t);
double t_2 = y * ((z - x) / t);
double tmp;
if (t_1 <= -2e+266) {
tmp = t_2;
} else if (t_1 <= 1e+293) {
tmp = x + ((z * y) / t);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (((z - x) * y) / t) t_2 = y * ((z - x) / t) tmp = 0 if t_1 <= -2e+266: tmp = t_2 elif t_1 <= 1e+293: tmp = x + ((z * y) / t) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(Float64(z - x) * y) / t)) t_2 = Float64(y * Float64(Float64(z - x) / t)) tmp = 0.0 if (t_1 <= -2e+266) tmp = t_2; elseif (t_1 <= 1e+293) tmp = Float64(x + Float64(Float64(z * y) / t)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (((z - x) * y) / t); t_2 = y * ((z - x) / t); tmp = 0.0; if (t_1 <= -2e+266) tmp = t_2; elseif (t_1 <= 1e+293) tmp = x + ((z * y) / t); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+266], t$95$2, If[LessEqual[t$95$1, 1e+293], N[(x + N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(z - x\right) \cdot y}{t}\\
t_2 := y \cdot \frac{z - x}{t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+266}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+293}:\\
\;\;\;\;x + \frac{z \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -2.0000000000000001e266 or 9.9999999999999992e292 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 80.6%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6487.1
Simplified87.1%
if -2.0000000000000001e266 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 9.9999999999999992e292Initial program 98.7%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6482.6
Simplified82.6%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma z (/ y t) x))) (if (<= z -112000.0) t_1 (if (<= z 2e-37) (fma (/ y t) (- x) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, (y / t), x);
double tmp;
if (z <= -112000.0) {
tmp = t_1;
} else if (z <= 2e-37) {
tmp = fma((y / t), -x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(y / t), x) tmp = 0.0 if (z <= -112000.0) tmp = t_1; elseif (z <= 2e-37) tmp = fma(Float64(y / t), Float64(-x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -112000.0], t$95$1, If[LessEqual[z, 2e-37], N[(N[(y / t), $MachinePrecision] * (-x) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{if}\;z \leq -112000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -112000 or 2.00000000000000013e-37 < z Initial program 89.9%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6484.7
Simplified84.7%
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-fma.f6490.7
Applied egg-rr90.7%
if -112000 < z < 2.00000000000000013e-37Initial program 96.2%
lift--.f64N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.6
Applied egg-rr95.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6483.4
Simplified83.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma z (/ y t) x))) (if (<= z -26500.0) t_1 (if (<= z 1.85e-37) (- x (/ (* x y) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, (y / t), x);
double tmp;
if (z <= -26500.0) {
tmp = t_1;
} else if (z <= 1.85e-37) {
tmp = x - ((x * y) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(y / t), x) tmp = 0.0 if (z <= -26500.0) tmp = t_1; elseif (z <= 1.85e-37) tmp = Float64(x - Float64(Float64(x * y) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -26500.0], t$95$1, If[LessEqual[z, 1.85e-37], N[(x - N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{if}\;z \leq -26500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{-37}:\\
\;\;\;\;x - \frac{x \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -26500 or 1.85e-37 < z Initial program 89.9%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6484.7
Simplified84.7%
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-fma.f6490.7
Applied egg-rr90.7%
if -26500 < z < 1.85e-37Initial program 96.2%
Taylor expanded in x around inf
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
associate-/l*N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.6
Simplified81.6%
Final simplification86.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (/ (- z x) t)))) (if (<= y -3.4e+112) t_1 (if (<= y 3.2e+83) (fma z (/ y t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * ((z - x) / t);
double tmp;
if (y <= -3.4e+112) {
tmp = t_1;
} else if (y <= 3.2e+83) {
tmp = fma(z, (y / t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(Float64(z - x) / t)) tmp = 0.0 if (y <= -3.4e+112) tmp = t_1; elseif (y <= 3.2e+83) tmp = fma(z, Float64(y / t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.4e+112], t$95$1, If[LessEqual[y, 3.2e+83], N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z - x}{t}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+112}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.39999999999999993e112 or 3.1999999999999999e83 < y Initial program 82.7%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6480.8
Simplified80.8%
if -3.39999999999999993e112 < y < 3.1999999999999999e83Initial program 98.6%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6485.1
Simplified85.1%
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-fma.f6484.9
Applied egg-rr84.9%
(FPCore (x y z t) :precision binary64 (+ x (* (- z x) (/ y t))))
double code(double x, double y, double z, double t) {
return x + ((z - x) * (y / t));
}
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 + ((z - x) * (y / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((z - x) * (y / t));
}
def code(x, y, z, t): return x + ((z - x) * (y / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(z - x) * Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = x + ((z - x) * (y / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - x\right) \cdot \frac{y}{t}
\end{array}
Initial program 93.2%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.8
Applied egg-rr96.8%
Final simplification96.8%
(FPCore (x y z t) :precision binary64 (fma (/ y t) (- z x) x))
double code(double x, double y, double z, double t) {
return fma((y / t), (z - x), x);
}
function code(x, y, z, t) return fma(Float64(y / t), Float64(z - x), x) end
code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)
\end{array}
Initial program 93.2%
lift--.f64N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.8
Applied egg-rr96.8%
(FPCore (x y z t) :precision binary64 (fma z (/ y t) x))
double code(double x, double y, double z, double t) {
return fma(z, (y / t), x);
}
function code(x, y, z, t) return fma(z, Float64(y / t), x) end
code[x_, y_, z_, t_] := N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \frac{y}{t}, x\right)
\end{array}
Initial program 93.2%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6471.9
Simplified71.9%
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-fma.f6475.4
Applied egg-rr75.4%
(FPCore (x y z t) :precision binary64 (* z (/ y t)))
double code(double x, double y, double z, double t) {
return z * (y / t);
}
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 = z * (y / t)
end function
public static double code(double x, double y, double z, double t) {
return z * (y / t);
}
def code(x, y, z, t): return z * (y / t)
function code(x, y, z, t) return Float64(z * Float64(y / t)) end
function tmp = code(x, y, z, t) tmp = z * (y / t); end
code[x_, y_, z_, t_] := N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \frac{y}{t}
\end{array}
Initial program 93.2%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6432.9
Simplified32.9%
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-*.f6435.7
Applied egg-rr35.7%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
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 - ((x * (y / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2024208
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:alt
(! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
(+ x (/ (* y (- z x)) t)))