
(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 94.0%
associate-*l/98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.85e-89) (+ x (/ z (/ t y))) (if (<= z 1.15e-99) (- x (* y (/ x t))) (+ x (* (/ y t) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.85e-89) {
tmp = x + (z / (t / y));
} else if (z <= 1.15e-99) {
tmp = x - (y * (x / 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 (z <= (-1.85d-89)) then
tmp = x + (z / (t / y))
else if (z <= 1.15d-99) then
tmp = x - (y * (x / 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 (z <= -1.85e-89) {
tmp = x + (z / (t / y));
} else if (z <= 1.15e-99) {
tmp = x - (y * (x / t));
} else {
tmp = x + ((y / t) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.85e-89: tmp = x + (z / (t / y)) elif z <= 1.15e-99: tmp = x - (y * (x / t)) else: tmp = x + ((y / t) * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.85e-89) tmp = Float64(x + Float64(z / Float64(t / y))); elseif (z <= 1.15e-99) tmp = Float64(x - Float64(y * Float64(x / 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 (z <= -1.85e-89) tmp = x + (z / (t / y)); elseif (z <= 1.15e-99) tmp = x - (y * (x / t)); else tmp = x + ((y / t) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.85e-89], N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e-99], N[(x - N[(y * N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{-89}:\\
\;\;\;\;x + \frac{z}{\frac{t}{y}}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-99}:\\
\;\;\;\;x - y \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\end{array}
\end{array}
if z < -1.8499999999999999e-89Initial program 93.6%
associate-*l/98.5%
Simplified98.5%
Taylor expanded in z around inf 83.5%
associate-*l/85.9%
*-commutative85.9%
Simplified85.9%
clear-num85.9%
div-inv86.0%
Applied egg-rr86.0%
if -1.8499999999999999e-89 < z < 1.1499999999999999e-99Initial program 94.8%
associate-*l/96.9%
Simplified96.9%
*-commutative96.9%
clear-num96.9%
un-div-inv96.9%
Applied egg-rr96.9%
Taylor expanded in z around 0 90.0%
mul-1-neg90.0%
associate-*l/90.0%
distribute-rgt-neg-in90.0%
Simplified90.0%
if 1.1499999999999999e-99 < z Initial program 93.6%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in z around inf 85.1%
associate-*l/89.4%
*-commutative89.4%
Simplified89.4%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (if (<= z -2.9e-91) (+ x (/ z (/ t y))) (if (<= z 9.6e-90) (- x (* x (/ y t))) (+ x (* (/ y t) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.9e-91) {
tmp = x + (z / (t / y));
} else if (z <= 9.6e-90) {
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 (z <= (-2.9d-91)) then
tmp = x + (z / (t / y))
else if (z <= 9.6d-90) 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 (z <= -2.9e-91) {
tmp = x + (z / (t / y));
} else if (z <= 9.6e-90) {
tmp = x - (x * (y / t));
} else {
tmp = x + ((y / t) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.9e-91: tmp = x + (z / (t / y)) elif z <= 9.6e-90: tmp = x - (x * (y / t)) else: tmp = x + ((y / t) * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.9e-91) tmp = Float64(x + Float64(z / Float64(t / y))); elseif (z <= 9.6e-90) 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 (z <= -2.9e-91) tmp = x + (z / (t / y)); elseif (z <= 9.6e-90) tmp = x - (x * (y / t)); else tmp = x + ((y / t) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.9e-91], N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.6e-90], 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}\;z \leq -2.9 \cdot 10^{-91}:\\
\;\;\;\;x + \frac{z}{\frac{t}{y}}\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-90}:\\
\;\;\;\;x - x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\end{array}
\end{array}
if z < -2.9000000000000001e-91Initial program 93.6%
associate-*l/98.5%
Simplified98.5%
Taylor expanded in z around inf 83.5%
associate-*l/85.9%
*-commutative85.9%
Simplified85.9%
clear-num85.9%
div-inv86.0%
Applied egg-rr86.0%
if -2.9000000000000001e-91 < z < 9.6000000000000006e-90Initial program 94.8%
associate-*l/96.9%
Simplified96.9%
Taylor expanded in z around 0 90.0%
*-commutative90.0%
associate-*l/92.1%
neg-mul-192.1%
distribute-rgt-neg-out92.1%
Simplified92.1%
if 9.6000000000000006e-90 < z Initial program 93.6%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in z around inf 85.1%
associate-*l/89.4%
*-commutative89.4%
Simplified89.4%
Final simplification89.4%
(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 94.0%
associate-*l/98.4%
Simplified98.4%
Taylor expanded in z around inf 73.6%
associate-*l/76.5%
*-commutative76.5%
Simplified76.5%
Final simplification76.5%
(FPCore (x y z t) :precision binary64 (+ x (/ z (/ t y))))
double code(double x, double y, double z, double t) {
return x + (z / (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 / (t / y))
end function
public static double code(double x, double y, double z, double t) {
return x + (z / (t / y));
}
def code(x, y, z, t): return x + (z / (t / y))
function code(x, y, z, t) return Float64(x + Float64(z / Float64(t / y))) end
function tmp = code(x, y, z, t) tmp = x + (z / (t / y)); end
code[x_, y_, z_, t_] := N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z}{\frac{t}{y}}
\end{array}
Initial program 94.0%
associate-*l/98.4%
Simplified98.4%
Taylor expanded in z around inf 73.6%
associate-*l/76.5%
*-commutative76.5%
Simplified76.5%
clear-num76.5%
div-inv76.5%
Applied egg-rr76.5%
Final simplification76.5%
(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 2024024
(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)))