
(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(y * Float64(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[(y * N[(z / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(0.125 \cdot x - y \cdot \frac{z}{2}\right) + t
\end{array}
Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
(FPCore (x y z t) :precision binary64 (if (or (<= (* y z) -4e+115) (not (<= (* y z) 2e+21))) (- t (* (* y z) 0.5)) (+ (* 0.125 x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (((y * z) <= -4e+115) || !((y * z) <= 2e+21)) {
tmp = t - ((y * z) * 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 * z) <= (-4d+115)) .or. (.not. ((y * z) <= 2d+21))) then
tmp = t - ((y * z) * 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 * z) <= -4e+115) || !((y * z) <= 2e+21)) {
tmp = t - ((y * z) * 0.5);
} else {
tmp = (0.125 * x) + t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((y * z) <= -4e+115) or not ((y * z) <= 2e+21): tmp = t - ((y * z) * 0.5) else: tmp = (0.125 * x) + t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(y * z) <= -4e+115) || !(Float64(y * z) <= 2e+21)) tmp = Float64(t - Float64(Float64(y * z) * 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 * z) <= -4e+115) || ~(((y * z) <= 2e+21))) tmp = t - ((y * z) * 0.5); else tmp = (0.125 * x) + t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -4e+115], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+21]], $MachinePrecision]], N[(t - N[(N[(y * z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(0.125 * x), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -4 \cdot 10^{+115} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+21}\right):\\
\;\;\;\;t - \left(y \cdot z\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot x + t\\
\end{array}
\end{array}
if (*.f64 y z) < -4.0000000000000001e115 or 2e21 < (*.f64 y z) Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 91.3%
if -4.0000000000000001e115 < (*.f64 y z) < 2e21Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 90.4%
Final simplification90.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (* y -0.5))))
(if (<= y -1.8e+33)
t_1
(if (<= y 9.5e-172) t (if (<= y 7e-84) (* 0.125 x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (y * -0.5);
double tmp;
if (y <= -1.8e+33) {
tmp = t_1;
} else if (y <= 9.5e-172) {
tmp = t;
} else if (y <= 7e-84) {
tmp = 0.125 * x;
} else {
tmp = t_1;
}
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) :: tmp
t_1 = z * (y * (-0.5d0))
if (y <= (-1.8d+33)) then
tmp = t_1
else if (y <= 9.5d-172) then
tmp = t
else if (y <= 7d-84) then
tmp = 0.125d0 * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (y * -0.5);
double tmp;
if (y <= -1.8e+33) {
tmp = t_1;
} else if (y <= 9.5e-172) {
tmp = t;
} else if (y <= 7e-84) {
tmp = 0.125 * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (y * -0.5) tmp = 0 if y <= -1.8e+33: tmp = t_1 elif y <= 9.5e-172: tmp = t elif y <= 7e-84: tmp = 0.125 * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(y * -0.5)) tmp = 0.0 if (y <= -1.8e+33) tmp = t_1; elseif (y <= 9.5e-172) tmp = t; elseif (y <= 7e-84) tmp = Float64(0.125 * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (y * -0.5); tmp = 0.0; if (y <= -1.8e+33) tmp = t_1; elseif (y <= 9.5e-172) tmp = t; elseif (y <= 7e-84) tmp = 0.125 * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e+33], t$95$1, If[LessEqual[y, 9.5e-172], t, If[LessEqual[y, 7e-84], N[(0.125 * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(y \cdot -0.5\right)\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{+33}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-172}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-84}:\\
\;\;\;\;0.125 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.8000000000000001e33 or 7.0000000000000002e-84 < y Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 78.8%
Taylor expanded in t around 0 58.1%
associate-*r*58.1%
*-commutative58.1%
Simplified58.1%
if -1.8000000000000001e33 < y < 9.50000000000000053e-172Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in t around inf 55.1%
if 9.50000000000000053e-172 < y < 7.0000000000000002e-84Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 90.5%
Taylor expanded in x around inf 42.5%
Final simplification55.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -7.1e+195) (not (<= y 8.6e-48))) (* z (* y -0.5)) (+ (* 0.125 x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7.1e+195) || !(y <= 8.6e-48)) {
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 <= (-7.1d+195)) .or. (.not. (y <= 8.6d-48))) 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 <= -7.1e+195) || !(y <= 8.6e-48)) {
tmp = z * (y * -0.5);
} else {
tmp = (0.125 * x) + t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -7.1e+195) or not (y <= 8.6e-48): tmp = z * (y * -0.5) else: tmp = (0.125 * x) + t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -7.1e+195) || !(y <= 8.6e-48)) 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 <= -7.1e+195) || ~((y <= 8.6e-48))) 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, -7.1e+195], N[Not[LessEqual[y, 8.6e-48]], $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 -7.1 \cdot 10^{+195} \lor \neg \left(y \leq 8.6 \cdot 10^{-48}\right):\\
\;\;\;\;z \cdot \left(y \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot x + t\\
\end{array}
\end{array}
if y < -7.10000000000000011e195 or 8.6e-48 < y Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 80.7%
Taylor expanded in t around 0 60.7%
associate-*r*60.7%
*-commutative60.7%
Simplified60.7%
if -7.10000000000000011e195 < y < 8.6e-48Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 77.3%
Final simplification70.4%
(FPCore (x y z t) :precision binary64 (if (<= t -1.75e+56) t (if (<= t 6e+23) (* 0.125 x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.75e+56) {
tmp = t;
} else if (t <= 6e+23) {
tmp = 0.125 * x;
} 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 (t <= (-1.75d+56)) then
tmp = t
else if (t <= 6d+23) then
tmp = 0.125d0 * x
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.75e+56) {
tmp = t;
} else if (t <= 6e+23) {
tmp = 0.125 * x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.75e+56: tmp = t elif t <= 6e+23: tmp = 0.125 * x else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.75e+56) tmp = t; elseif (t <= 6e+23) tmp = Float64(0.125 * x); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.75e+56) tmp = t; elseif (t <= 6e+23) tmp = 0.125 * x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.75e+56], t, If[LessEqual[t, 6e+23], N[(0.125 * x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.75 \cdot 10^{+56}:\\
\;\;\;\;t\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+23}:\\
\;\;\;\;0.125 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if t < -1.75e56 or 6.0000000000000002e23 < t Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in t around inf 61.7%
if -1.75e56 < t < 6.0000000000000002e23Initial program 100.0%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around inf 53.5%
Taylor expanded in x around inf 40.7%
(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%
associate-+l-100.0%
*-commutative100.0%
associate-+l-100.0%
*-commutative100.0%
metadata-eval100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in t around inf 35.4%
(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 2024163
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (+ (/ x 8) t) (* (/ z 2) y)))
(+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))