
(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 7 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 (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%
+-commutative93.2%
associate-*l/98.0%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.5e+43) (not (<= z 2.65e-80))) (+ x (* (/ y t) z)) (- x (* (/ y t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.5e+43) || !(z <= 2.65e-80)) {
tmp = x + ((y / t) * z);
} else {
tmp = x - ((y / t) * x);
}
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 ((z <= (-3.5d+43)) .or. (.not. (z <= 2.65d-80))) then
tmp = x + ((y / t) * z)
else
tmp = x - ((y / t) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.5e+43) || !(z <= 2.65e-80)) {
tmp = x + ((y / t) * z);
} else {
tmp = x - ((y / t) * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.5e+43) or not (z <= 2.65e-80): tmp = x + ((y / t) * z) else: tmp = x - ((y / t) * x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.5e+43) || !(z <= 2.65e-80)) tmp = Float64(x + Float64(Float64(y / t) * z)); else tmp = Float64(x - Float64(Float64(y / t) * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.5e+43) || ~((z <= 2.65e-80))) tmp = x + ((y / t) * z); else tmp = x - ((y / t) * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.5e+43], N[Not[LessEqual[z, 2.65e-80]], $MachinePrecision]], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+43} \lor \neg \left(z \leq 2.65 \cdot 10^{-80}\right):\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{t} \cdot x\\
\end{array}
\end{array}
if z < -3.5000000000000001e43 or 2.65000000000000013e-80 < z Initial program 92.9%
associate-*l/97.4%
Simplified97.4%
Taylor expanded in z around inf 89.0%
associate-*l/90.1%
*-commutative90.1%
Simplified90.1%
if -3.5000000000000001e43 < z < 2.65000000000000013e-80Initial program 93.5%
associate-*l/98.5%
Simplified98.5%
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%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.8e+43) (not (<= z 1.6e-79))) (+ x (* (/ y t) z)) (- x (/ x (/ t y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+43) || !(z <= 1.6e-79)) {
tmp = x + ((y / t) * z);
} else {
tmp = x - (x / (t / y));
}
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 ((z <= (-5.8d+43)) .or. (.not. (z <= 1.6d-79))) then
tmp = x + ((y / t) * z)
else
tmp = x - (x / (t / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+43) || !(z <= 1.6e-79)) {
tmp = x + ((y / t) * z);
} else {
tmp = x - (x / (t / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.8e+43) or not (z <= 1.6e-79): tmp = x + ((y / t) * z) else: tmp = x - (x / (t / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.8e+43) || !(z <= 1.6e-79)) tmp = Float64(x + Float64(Float64(y / t) * z)); else tmp = Float64(x - Float64(x / Float64(t / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.8e+43) || ~((z <= 1.6e-79))) tmp = x + ((y / t) * z); else tmp = x - (x / (t / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.8e+43], N[Not[LessEqual[z, 1.6e-79]], $MachinePrecision]], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+43} \lor \neg \left(z \leq 1.6 \cdot 10^{-79}\right):\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{t}{y}}\\
\end{array}
\end{array}
if z < -5.8000000000000004e43 or 1.59999999999999994e-79 < z Initial program 92.9%
associate-*l/97.4%
Simplified97.4%
Taylor expanded in z around inf 89.0%
associate-*l/90.1%
*-commutative90.1%
Simplified90.1%
if -5.8000000000000004e43 < z < 1.59999999999999994e-79Initial program 93.5%
associate-*l/98.5%
Simplified98.5%
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%
div-inv88.3%
Applied egg-rr88.3%
Final simplification89.1%
(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.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (+ x (* y (/ z t))))
double code(double x, double y, double z, double t) {
return x + (y * (z / 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 / t))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z / t));
}
def code(x, y, z, t): return x + (y * (z / t))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z}{t}
\end{array}
Initial program 93.2%
associate-*l/98.0%
Simplified98.0%
associate-/r/91.5%
div-inv91.4%
associate-/r*97.9%
Applied egg-rr97.9%
Taylor expanded in z around inf 73.9%
associate-*r/71.6%
Simplified71.6%
Final simplification71.6%
(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.0%
Simplified98.0%
Taylor expanded in z around inf 73.9%
associate-*l/75.2%
*-commutative75.2%
Simplified75.2%
Final simplification75.2%
(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.0%
Simplified98.0%
Taylor expanded in y around 0 37.4%
Final simplification37.4%
(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 2023268
(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)))