
(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 5 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 (* (/ y t) (- z x))))
double code(double x, double y, double z, double t) {
return x + ((y / t) * (z - x));
}
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 / t) * (z - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y / t) * (z - x));
}
def code(x, y, z, t): return x + ((y / t) * (z - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y / t) * Float64(z - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y / t) * (z - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{t} \cdot \left(z - x\right)
\end{array}
Initial program 93.2%
associate-*l/98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -3.7e-34) (not (<= x 6e+31))) (- x (* x (/ y t))) (+ x (* (/ y t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.7e-34) || !(x <= 6e+31)) {
tmp = x - (x * (y / t));
} else {
tmp = x + ((y / t) * z);
}
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) :: tmp
if ((x <= (-3.7d-34)) .or. (.not. (x <= 6d+31))) then
tmp = x - (x * (y / t))
else
tmp = x + ((y / t) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.7e-34) || !(x <= 6e+31)) {
tmp = x - (x * (y / t));
} else {
tmp = x + ((y / t) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -3.7e-34) or not (x <= 6e+31): tmp = x - (x * (y / t)) else: tmp = x + ((y / t) * z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.7e-34) || !(x <= 6e+31)) tmp = Float64(x - Float64(x * Float64(y / t))); else tmp = Float64(x + Float64(Float64(y / t) * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -3.7e-34) || ~((x <= 6e+31))) tmp = x - (x * (y / t)); else tmp = x + ((y / t) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.7e-34], N[Not[LessEqual[x, 6e+31]], $MachinePrecision]], N[(x - N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{-34} \lor \neg \left(x \leq 6 \cdot 10^{+31}\right):\\
\;\;\;\;x - x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\end{array}
\end{array}
if x < -3.69999999999999988e-34 or 5.99999999999999978e31 < x Initial program 94.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around inf 88.3%
*-commutative88.3%
distribute-lft-in88.3%
*-rgt-identity88.3%
mul-1-neg88.3%
distribute-rgt-neg-in88.3%
unsub-neg88.3%
Simplified88.3%
if -3.69999999999999988e-34 < x < 5.99999999999999978e31Initial program 91.6%
associate-*l/96.7%
Simplified96.7%
Taylor expanded in z around inf 83.0%
associate-*l/87.8%
*-commutative87.8%
Simplified87.8%
Final simplification88.1%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7.1e-34) (not (<= x 3.8e+31))) (- x (/ x (/ t y))) (+ x (* (/ y t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.1e-34) || !(x <= 3.8e+31)) {
tmp = x - (x / (t / y));
} else {
tmp = x + ((y / t) * z);
}
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) :: tmp
if ((x <= (-7.1d-34)) .or. (.not. (x <= 3.8d+31))) then
tmp = x - (x / (t / y))
else
tmp = x + ((y / t) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.1e-34) || !(x <= 3.8e+31)) {
tmp = x - (x / (t / y));
} else {
tmp = x + ((y / t) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -7.1e-34) or not (x <= 3.8e+31): tmp = x - (x / (t / y)) else: tmp = x + ((y / t) * z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -7.1e-34) || !(x <= 3.8e+31)) tmp = Float64(x - Float64(x / Float64(t / y))); else tmp = Float64(x + Float64(Float64(y / t) * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -7.1e-34) || ~((x <= 3.8e+31))) tmp = x - (x / (t / y)); else tmp = x + ((y / t) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -7.1e-34], N[Not[LessEqual[x, 3.8e+31]], $MachinePrecision]], N[(x - N[(x / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.1 \cdot 10^{-34} \lor \neg \left(x \leq 3.8 \cdot 10^{+31}\right):\\
\;\;\;\;x - \frac{x}{\frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\end{array}
\end{array}
if x < -7.10000000000000036e-34 or 3.8000000000000001e31 < x Initial program 94.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around inf 88.3%
*-commutative88.3%
distribute-lft-in88.3%
*-rgt-identity88.3%
mul-1-neg88.3%
distribute-rgt-neg-in88.3%
unsub-neg88.3%
Simplified88.3%
clear-num88.3%
un-div-inv88.4%
Applied egg-rr88.4%
if -7.10000000000000036e-34 < x < 3.8000000000000001e31Initial program 91.6%
associate-*l/96.7%
Simplified96.7%
Taylor expanded in z around inf 83.0%
associate-*l/87.8%
*-commutative87.8%
Simplified87.8%
Final simplification88.1%
(FPCore (x y z t) :precision binary64 (+ x (* (/ y t) z)))
double code(double x, double y, double z, double t) {
return x + ((y / t) * z);
}
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 / t) * z)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y / t) * z);
}
def code(x, y, z, t): return x + ((y / t) * z)
function code(x, y, z, t) return Float64(x + Float64(Float64(y / t) * z)) end
function tmp = code(x, y, z, t) tmp = x + ((y / t) * z); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{t} \cdot z
\end{array}
Initial program 93.2%
associate-*l/98.3%
Simplified98.3%
Taylor expanded in z around inf 72.6%
associate-*l/76.3%
*-commutative76.3%
Simplified76.3%
Final simplification76.3%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.2%
associate-*l/98.3%
Simplified98.3%
Taylor expanded in y around 0 37.1%
Final simplification37.1%
(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 2023230
(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)))