
(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 (- (+ (* (/ 1.0 8.0) x) t) (/ (* y z) 2.0)))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) + t) - ((y * z) / 2.0);
}
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) + t) - ((y * z) / 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) + t) - ((y * z) / 2.0);
}
def code(x, y, z, t): return (((1.0 / 8.0) * x) + t) - ((y * z) / 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) + t) - Float64(Float64(y * z) / 2.0)) end
function tmp = code(x, y, z, t) tmp = (((1.0 / 8.0) * x) + t) - ((y * z) / 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] + t), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{8} \cdot x + t\right) - \frac{y \cdot z}{2}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites68.7%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ 1.0 8.0) x)) (t_2 (- t_1 (/ (* y z) 2.0)))) (if (<= (* y z) -2.7e+98) t_2 (if (<= (* y z) 8.5e+110) (+ t_1 t) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 / 8.0) * x;
double t_2 = t_1 - ((y * z) / 2.0);
double tmp;
if ((y * z) <= -2.7e+98) {
tmp = t_2;
} else if ((y * z) <= 8.5e+110) {
tmp = t_1 + t;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (1.0d0 / 8.0d0) * x
t_2 = t_1 - ((y * z) / 2.0d0)
if ((y * z) <= (-2.7d+98)) then
tmp = t_2
else if ((y * z) <= 8.5d+110) then
tmp = t_1 + t
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (1.0 / 8.0) * x;
double t_2 = t_1 - ((y * z) / 2.0);
double tmp;
if ((y * z) <= -2.7e+98) {
tmp = t_2;
} else if ((y * z) <= 8.5e+110) {
tmp = t_1 + t;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (1.0 / 8.0) * x t_2 = t_1 - ((y * z) / 2.0) tmp = 0 if (y * z) <= -2.7e+98: tmp = t_2 elif (y * z) <= 8.5e+110: tmp = t_1 + t else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(1.0 / 8.0) * x) t_2 = Float64(t_1 - Float64(Float64(y * z) / 2.0)) tmp = 0.0 if (Float64(y * z) <= -2.7e+98) tmp = t_2; elseif (Float64(y * z) <= 8.5e+110) tmp = Float64(t_1 + t); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (1.0 / 8.0) * x; t_2 = t_1 - ((y * z) / 2.0); tmp = 0.0; if ((y * z) <= -2.7e+98) tmp = t_2; elseif ((y * z) <= 8.5e+110) tmp = t_1 + t; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -2.7e+98], t$95$2, If[LessEqual[N[(y * z), $MachinePrecision], 8.5e+110], N[(t$95$1 + t), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{8} \cdot x\\
t_2 := t\_1 - \frac{y \cdot z}{2}\\
\mathbf{if}\;y \cdot z \leq -2.7 \cdot 10^{+98}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \cdot z \leq 8.5 \cdot 10^{+110}:\\
\;\;\;\;t\_1 + t\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y z) < -2.7e98 or 8.5000000000000004e110 < (*.f64 y z) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites89.6%
if -2.7e98 < (*.f64 y z) < 8.5000000000000004e110Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites89.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (/ 1.0 8.0) t))) (if (<= t -5.5e+117) t_1 (if (<= t 9e+79) (* (/ 1.0 8.0) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 / 8.0) + t;
double tmp;
if (t <= -5.5e+117) {
tmp = t_1;
} else if (t <= 9e+79) {
tmp = (1.0 / 8.0) * 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 = (1.0d0 / 8.0d0) + t
if (t <= (-5.5d+117)) then
tmp = t_1
else if (t <= 9d+79) then
tmp = (1.0d0 / 8.0d0) * 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 = (1.0 / 8.0) + t;
double tmp;
if (t <= -5.5e+117) {
tmp = t_1;
} else if (t <= 9e+79) {
tmp = (1.0 / 8.0) * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (1.0 / 8.0) + t tmp = 0 if t <= -5.5e+117: tmp = t_1 elif t <= 9e+79: tmp = (1.0 / 8.0) * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(1.0 / 8.0) + t) tmp = 0.0 if (t <= -5.5e+117) tmp = t_1; elseif (t <= 9e+79) tmp = Float64(Float64(1.0 / 8.0) * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (1.0 / 8.0) + t; tmp = 0.0; if (t <= -5.5e+117) tmp = t_1; elseif (t <= 9e+79) tmp = (1.0 / 8.0) * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 / 8.0), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[t, -5.5e+117], t$95$1, If[LessEqual[t, 9e+79], N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{8} + t\\
\mathbf{if}\;t \leq -5.5 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9 \cdot 10^{+79}:\\
\;\;\;\;\frac{1}{8} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -5.49999999999999965e117 or 8.99999999999999987e79 < t Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites69.9%
if -5.49999999999999965e117 < t < 8.99999999999999987e79Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites87.1%
Taylor expanded in x around 0
Applied rewrites44.5%
(FPCore (x y z t) :precision binary64 (+ (* (/ 1.0 8.0) x) t))
double code(double x, double y, double z, double t) {
return ((1.0 / 8.0) * 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 = ((1.0d0 / 8.0d0) * x) + t
end function
public static double code(double x, double y, double z, double t) {
return ((1.0 / 8.0) * x) + t;
}
def code(x, y, z, t): return ((1.0 / 8.0) * x) + t
function code(x, y, z, t) return Float64(Float64(Float64(1.0 / 8.0) * x) + t) end
function tmp = code(x, y, z, t) tmp = ((1.0 / 8.0) * x) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{8} \cdot x + t
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.5%
(FPCore (x y z t) :precision binary64 (+ (* y z) t))
double code(double x, double y, double z, double t) {
return (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 = (y * z) + t
end function
public static double code(double x, double y, double z, double t) {
return (y * z) + t;
}
def code(x, y, z, t): return (y * z) + t
function code(x, y, z, t) return Float64(Float64(y * z) + t) end
function tmp = code(x, y, z, t) tmp = (y * z) + t; end
code[x_, y_, z_, t_] := N[(N[(y * z), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
y \cdot z + t
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.5%
Taylor expanded in x around 0
Applied rewrites39.9%
Taylor expanded in x around 0
Applied rewrites32.2%
(FPCore (x y z t) :precision binary64 (* y z))
double code(double x, double y, double z, double t) {
return y * 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 = y * z
end function
public static double code(double x, double y, double z, double t) {
return y * z;
}
def code(x, y, z, t): return y * z
function code(x, y, z, t) return Float64(y * z) end
function tmp = code(x, y, z, t) tmp = y * z; end
code[x_, y_, z_, t_] := N[(y * z), $MachinePrecision]
\begin{array}{l}
\\
y \cdot z
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites68.7%
Taylor expanded in x around -inf
Applied rewrites2.1%
(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 2024321
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, B"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (- (+ (/ x 8) t) (* (/ z 2) y)))
(+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))