
(FPCore (x y z t) :precision binary64 (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + 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 = (((1.0d0 / 8.0d0) * x) - ((y * z) / 2.0d0)) + t
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
def code(x, y, z, t): return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t) end
function tmp = code(x, y, z, t) tmp = (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + 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 = (((1.0d0 / 8.0d0) * x) - ((y * z) / 2.0d0)) + t
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
def code(x, y, z, t): return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t) end
function tmp = code(x, y, z, t) tmp = (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\end{array}
(FPCore (x y z t) :precision binary64 (+ (- (* 0.125 x) (/ (* y z) 2.0)) t))
double code(double x, double y, double z, double t) {
return ((0.125 * x) - ((y * z) / 2.0)) + 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 = ((0.125d0 * x) - ((y * z) / 2.0d0)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((0.125 * x) - ((y * z) / 2.0)) + t;
}
def code(x, y, z, t): return ((0.125 * x) - ((y * z) / 2.0)) + t
function code(x, y, z, t) return Float64(Float64(Float64(0.125 * x) - Float64(Float64(y * z) / 2.0)) + t) end
function tmp = code(x, y, z, t) tmp = ((0.125 * x) - ((y * z) / 2.0)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(0.125 * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(0.125 \cdot x - \frac{y \cdot z}{2}\right) + t
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -6.7e+25) (not (<= x 8e+75))) (+ (* 0.125 x) t) (+ t (* y (* z -0.5)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6.7e+25) || !(x <= 8e+75)) {
tmp = (0.125 * x) + t;
} else {
tmp = t + (y * (z * -0.5));
}
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 <= (-6.7d+25)) .or. (.not. (x <= 8d+75))) then
tmp = (0.125d0 * x) + t
else
tmp = t + (y * (z * (-0.5d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6.7e+25) || !(x <= 8e+75)) {
tmp = (0.125 * x) + t;
} else {
tmp = t + (y * (z * -0.5));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -6.7e+25) or not (x <= 8e+75): tmp = (0.125 * x) + t else: tmp = t + (y * (z * -0.5)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -6.7e+25) || !(x <= 8e+75)) tmp = Float64(Float64(0.125 * x) + t); else tmp = Float64(t + Float64(y * Float64(z * -0.5))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -6.7e+25) || ~((x <= 8e+75))) tmp = (0.125 * x) + t; else tmp = t + (y * (z * -0.5)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -6.7e+25], N[Not[LessEqual[x, 8e+75]], $MachinePrecision]], N[(N[(0.125 * x), $MachinePrecision] + t), $MachinePrecision], N[(t + N[(y * N[(z * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.7 \cdot 10^{+25} \lor \neg \left(x \leq 8 \cdot 10^{+75}\right):\\
\;\;\;\;0.125 \cdot x + t\\
\mathbf{else}:\\
\;\;\;\;t + y \cdot \left(z \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -6.70000000000000037e25 or 7.99999999999999941e75 < x Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
if -6.70000000000000037e25 < x < 7.99999999999999941e75Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 89.1%
*-commutative89.1%
associate-*l*89.1%
Simplified89.1%
Final simplification86.0%
(FPCore (x y z t) :precision binary64 (+ t (- (* 0.125 x) (/ y (/ 2.0 z)))))
double code(double x, double y, double z, double t) {
return t + ((0.125 * x) - (y / (2.0 / 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 = t + ((0.125d0 * x) - (y / (2.0d0 / z)))
end function
public static double code(double x, double y, double z, double t) {
return t + ((0.125 * x) - (y / (2.0 / z)));
}
def code(x, y, z, t): return t + ((0.125 * x) - (y / (2.0 / z)))
function code(x, y, z, t) return Float64(t + Float64(Float64(0.125 * x) - Float64(y / Float64(2.0 / z)))) end
function tmp = code(x, y, z, t) tmp = t + ((0.125 * x) - (y / (2.0 / z))); end
code[x_, y_, z_, t_] := N[(t + N[(N[(0.125 * x), $MachinePrecision] - N[(y / N[(2.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \left(0.125 \cdot x - \frac{y}{\frac{2}{z}}\right)
\end{array}
Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2e-84) (not (<= z 0.0005))) (* z (* y -0.5)) t))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e-84) || !(z <= 0.0005)) {
tmp = z * (y * -0.5);
} else {
tmp = t;
}
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 <= (-2d-84)) .or. (.not. (z <= 0.0005d0))) then
tmp = z * (y * (-0.5d0))
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e-84) || !(z <= 0.0005)) {
tmp = z * (y * -0.5);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2e-84) or not (z <= 0.0005): tmp = z * (y * -0.5) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2e-84) || !(z <= 0.0005)) tmp = Float64(z * Float64(y * -0.5)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2e-84) || ~((z <= 0.0005))) tmp = z * (y * -0.5); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2e-84], N[Not[LessEqual[z, 0.0005]], $MachinePrecision]], N[(z * N[(y * -0.5), $MachinePrecision]), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-84} \lor \neg \left(z \leq 0.0005\right):\\
\;\;\;\;z \cdot \left(y \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -2.0000000000000001e-84 or 5.0000000000000001e-4 < z Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 79.8%
*-commutative79.8%
associate-*l*79.8%
Simplified79.8%
Taylor expanded in y around inf 60.6%
associate-*r*60.6%
Simplified60.6%
if -2.0000000000000001e-84 < z < 5.0000000000000001e-4Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 60.2%
*-commutative60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in y around 0 40.3%
Final simplification51.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.25e+129) (not (<= y 7.8e-67))) (* z (* y -0.5)) (+ (* 0.125 x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.25e+129) || !(y <= 7.8e-67)) {
tmp = z * (y * -0.5);
} else {
tmp = (0.125 * x) + t;
}
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 ((y <= (-1.25d+129)) .or. (.not. (y <= 7.8d-67))) then
tmp = z * (y * (-0.5d0))
else
tmp = (0.125d0 * x) + t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.25e+129) || !(y <= 7.8e-67)) {
tmp = z * (y * -0.5);
} else {
tmp = (0.125 * x) + t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.25e+129) or not (y <= 7.8e-67): tmp = z * (y * -0.5) else: tmp = (0.125 * x) + t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.25e+129) || !(y <= 7.8e-67)) tmp = Float64(z * Float64(y * -0.5)); else tmp = Float64(Float64(0.125 * x) + t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.25e+129) || ~((y <= 7.8e-67))) tmp = z * (y * -0.5); else tmp = (0.125 * x) + t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.25e+129], N[Not[LessEqual[y, 7.8e-67]], $MachinePrecision]], N[(z * N[(y * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(0.125 * x), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+129} \lor \neg \left(y \leq 7.8 \cdot 10^{-67}\right):\\
\;\;\;\;z \cdot \left(y \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot x + t\\
\end{array}
\end{array}
if y < -1.2500000000000001e129 or 7.7999999999999997e-67 < y Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 82.8%
*-commutative82.8%
associate-*l*82.8%
Simplified82.8%
Taylor expanded in y around inf 68.9%
associate-*r*68.9%
Simplified68.9%
if -1.2500000000000001e129 < y < 7.7999999999999997e-67Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 82.0%
Final simplification75.8%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
return 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 = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 100.0%
sub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 70.7%
*-commutative70.7%
associate-*l*70.7%
Simplified70.7%
Taylor expanded in y around 0 29.9%
Final simplification29.9%
(FPCore (x y z t) :precision binary64 (- (+ (/ x 8.0) t) (* (/ z 2.0) y)))
double code(double x, double y, double z, double t) {
return ((x / 8.0) + t) - ((z / 2.0) * 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 / 8.0d0) + t) - ((z / 2.0d0) * y)
end function
public static double code(double x, double y, double z, double t) {
return ((x / 8.0) + t) - ((z / 2.0) * y);
}
def code(x, y, z, t): return ((x / 8.0) + t) - ((z / 2.0) * y)
function code(x, y, z, t) return Float64(Float64(Float64(x / 8.0) + t) - Float64(Float64(z / 2.0) * y)) end
function tmp = code(x, y, z, t) tmp = ((x / 8.0) + t) - ((z / 2.0) * y); end
code[x_, y_, z_, t_] := N[(N[(N[(x / 8.0), $MachinePrecision] + t), $MachinePrecision] - N[(N[(z / 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{8} + t\right) - \frac{z}{2} \cdot y
\end{array}
herbie shell --seed 2023298
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(- (+ (/ x 8.0) t) (* (/ z 2.0) y))
(+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))