
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (- (+ (* y x) (/ (* t z) 16.0)) (/ (* b a) 4.0)))) (if (<= t_1 INFINITY) (+ c t_1) (* (* -0.25 a) b))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = ((y * x) + ((t * z) / 16.0)) - ((b * a) / 4.0);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = c + t_1;
} else {
tmp = (-0.25 * a) * b;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = ((y * x) + ((t * z) / 16.0)) - ((b * a) / 4.0);
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = c + t_1;
} else {
tmp = (-0.25 * a) * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = ((y * x) + ((t * z) / 16.0)) - ((b * a) / 4.0) tmp = 0 if t_1 <= math.inf: tmp = c + t_1 else: tmp = (-0.25 * a) * b return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(Float64(y * x) + Float64(Float64(t * z) / 16.0)) - Float64(Float64(b * a) / 4.0)) tmp = 0.0 if (t_1 <= Inf) tmp = Float64(c + t_1); else tmp = Float64(Float64(-0.25 * a) * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = ((y * x) + ((t * z) / 16.0)) - ((b * a) / 4.0); tmp = 0.0; if (t_1 <= Inf) tmp = c + t_1; else tmp = (-0.25 * a) * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(N[(y * x), $MachinePrecision] + N[(N[(t * z), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(b * a), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(c + t$95$1), $MachinePrecision], N[(N[(-0.25 * a), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y \cdot x + \frac{t \cdot z}{16}\right) - \frac{b \cdot a}{4}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;c + t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-0.25 \cdot a\right) \cdot b\\
\end{array}
\end{array}
if (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) < +inf.0Initial program 100.0%
if +inf.0 < (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) Initial program 0.0%
Taylor expanded in a around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6471.4
Applied rewrites71.4%
Final simplification99.2%
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (fma (* 0.0625 z) t (* y x))) (t_2 (+ (* y x) (/ (* t z) 16.0)))) (if (<= t_2 -2e+165) t_1 (if (<= t_2 2e+114) (fma (* -0.25 a) b c) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma((0.0625 * z), t, (y * x));
double t_2 = (y * x) + ((t * z) / 16.0);
double tmp;
if (t_2 <= -2e+165) {
tmp = t_1;
} else if (t_2 <= 2e+114) {
tmp = fma((-0.25 * a), b, c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(Float64(0.0625 * z), t, Float64(y * x)) t_2 = Float64(Float64(y * x) + Float64(Float64(t * z) / 16.0)) tmp = 0.0 if (t_2 <= -2e+165) tmp = t_1; elseif (t_2 <= 2e+114) tmp = fma(Float64(-0.25 * a), b, c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(0.0625 * z), $MachinePrecision] * t + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * x), $MachinePrecision] + N[(N[(t * z), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+165], t$95$1, If[LessEqual[t$95$2, 2e+114], N[(N[(-0.25 * a), $MachinePrecision] * b + c), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(0.0625 \cdot z, t, y \cdot x\right)\\
t_2 := y \cdot x + \frac{t \cdot z}{16}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot a, b, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < -1.9999999999999998e165 or 2e114 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) Initial program 95.5%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.9
Applied rewrites86.9%
Taylor expanded in y around inf
Applied rewrites80.4%
if -1.9999999999999998e165 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < 2e114Initial program 99.9%
Taylor expanded in x around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.4
Applied rewrites87.4%
Taylor expanded in z around 0
Applied rewrites75.3%
Final simplification77.9%
herbie shell --seed 2024230
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, C"
:precision binary64
(+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))