
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - 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 - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - 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 - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- y z) (- t x) x))
double code(double x, double y, double z, double t) {
return fma((y - z), (t - x), x);
}
function code(x, y, z, t) return fma(Float64(y - z), Float64(t - x), x) end
code[x_, y_, z_, t_] := N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - z, t - x, x\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -4.6e+30)
t_1
(if (<= y 4e-84)
(fma z (- x t) x)
(if (<= y 3500000.0)
(+ x (* (- y z) t))
(if (<= y 2.45e+129) (fma x (- z y) x) t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.6e+30) {
tmp = t_1;
} else if (y <= 4e-84) {
tmp = fma(z, (x - t), x);
} else if (y <= 3500000.0) {
tmp = x + ((y - z) * t);
} else if (y <= 2.45e+129) {
tmp = fma(x, (z - y), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.6e+30) tmp = t_1; elseif (y <= 4e-84) tmp = fma(z, Float64(x - t), x); elseif (y <= 3500000.0) tmp = Float64(x + Float64(Float64(y - z) * t)); elseif (y <= 2.45e+129) tmp = fma(x, Float64(z - y), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+30], t$95$1, If[LessEqual[y, 4e-84], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3500000.0], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e+129], N[(x * N[(z - y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-84}:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{elif}\;y \leq 3500000:\\
\;\;\;\;x + \left(y - z\right) \cdot t\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(x, z - y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.6e30 or 2.45e129 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6486.2
Applied rewrites86.2%
if -4.6e30 < y < 4.0000000000000001e-84Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6494.1
Applied rewrites94.1%
if 4.0000000000000001e-84 < y < 3.5e6Initial program 99.9%
Taylor expanded in t around inf
lower-*.f64N/A
lower--.f6484.8
Applied rewrites84.8%
if 3.5e6 < y < 2.45e129Initial program 100.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6484.5
Applied rewrites84.5%
Final simplification89.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -4.6e+30)
t_1
(if (<= y 1.2e-136)
(* z (- x t))
(if (<= y 2.3e-81)
(fma x z x)
(if (<= y 2100000.0) (* (- y z) t) t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.6e+30) {
tmp = t_1;
} else if (y <= 1.2e-136) {
tmp = z * (x - t);
} else if (y <= 2.3e-81) {
tmp = fma(x, z, x);
} else if (y <= 2100000.0) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.6e+30) tmp = t_1; elseif (y <= 1.2e-136) tmp = Float64(z * Float64(x - t)); elseif (y <= 2.3e-81) tmp = fma(x, z, x); elseif (y <= 2100000.0) tmp = Float64(Float64(y - z) * t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+30], t$95$1, If[LessEqual[y, 1.2e-136], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e-81], N[(x * z + x), $MachinePrecision], If[LessEqual[y, 2100000.0], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-136}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-81}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;y \leq 2100000:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.6e30 or 2.1e6 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6481.4
Applied rewrites81.4%
if -4.6e30 < y < 1.1999999999999999e-136Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6469.0
Applied rewrites69.0%
if 1.1999999999999999e-136 < y < 2.29999999999999991e-81Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6482.3
Applied rewrites82.3%
Taylor expanded in x around inf
Applied rewrites67.7%
if 2.29999999999999991e-81 < y < 2.1e6Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6467.1
Applied rewrites67.1%
Final simplification74.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -4.6e+30)
t_1
(if (<= y 40000000.0)
(fma z (- x t) x)
(if (<= y 2.45e+129) (fma x (- z y) x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.6e+30) {
tmp = t_1;
} else if (y <= 40000000.0) {
tmp = fma(z, (x - t), x);
} else if (y <= 2.45e+129) {
tmp = fma(x, (z - y), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.6e+30) tmp = t_1; elseif (y <= 40000000.0) tmp = fma(z, Float64(x - t), x); elseif (y <= 2.45e+129) tmp = fma(x, Float64(z - y), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+30], t$95$1, If[LessEqual[y, 40000000.0], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.45e+129], N[(x * N[(z - y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 40000000:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(x, z - y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.6e30 or 2.45e129 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6486.2
Applied rewrites86.2%
if -4.6e30 < y < 4e7Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6489.7
Applied rewrites89.7%
if 4e7 < y < 2.45e129Initial program 100.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6484.5
Applied rewrites84.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -4.6e+30)
t_1
(if (<= y -3.6e-161)
(* z (- x t))
(if (<= y 380000.0) (fma z (- t) x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.6e+30) {
tmp = t_1;
} else if (y <= -3.6e-161) {
tmp = z * (x - t);
} else if (y <= 380000.0) {
tmp = fma(z, -t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.6e+30) tmp = t_1; elseif (y <= -3.6e-161) tmp = Float64(z * Float64(x - t)); elseif (y <= 380000.0) tmp = fma(z, Float64(-t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+30], t$95$1, If[LessEqual[y, -3.6e-161], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 380000.0], N[(z * (-t) + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-161}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;y \leq 380000:\\
\;\;\;\;\mathsf{fma}\left(z, -t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.6e30 or 3.8e5 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6481.4
Applied rewrites81.4%
if -4.6e30 < y < -3.60000000000000018e-161Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6469.8
Applied rewrites69.8%
if -3.60000000000000018e-161 < y < 3.8e5Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6491.2
Applied rewrites91.2%
Taylor expanded in x around 0
Applied rewrites71.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma x (- z y) x))) (if (<= x -7.8e+18) t_1 (if (<= x 1.1e+50) (* (- y z) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(x, (z - y), x);
double tmp;
if (x <= -7.8e+18) {
tmp = t_1;
} else if (x <= 1.1e+50) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(x, Float64(z - y), x) tmp = 0.0 if (x <= -7.8e+18) tmp = t_1; elseif (x <= 1.1e+50) tmp = Float64(Float64(y - z) * t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(z - y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -7.8e+18], t$95$1, If[LessEqual[x, 1.1e+50], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, z - y, x\right)\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+50}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.8e18 or 1.10000000000000008e50 < x Initial program 100.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6482.7
Applied rewrites82.7%
if -7.8e18 < x < 1.10000000000000008e50Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6477.2
Applied rewrites77.2%
Final simplification79.7%
(FPCore (x y z t) :precision binary64 (if (<= x -4.5e+19) (fma x z x) (if (<= x 4.6e+52) (* (- y z) t) (fma x z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.5e+19) {
tmp = fma(x, z, x);
} else if (x <= 4.6e+52) {
tmp = (y - z) * t;
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -4.5e+19) tmp = fma(x, z, x); elseif (x <= 4.6e+52) tmp = Float64(Float64(y - z) * t); else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.5e+19], N[(x * z + x), $MachinePrecision], If[LessEqual[x, 4.6e+52], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(x * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+52}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if x < -4.5e19 or 4.6e52 < x Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6470.2
Applied rewrites70.2%
Taylor expanded in x around inf
Applied rewrites60.4%
if -4.5e19 < x < 4.6e52Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6477.2
Applied rewrites77.2%
Final simplification69.7%
(FPCore (x y z t) :precision binary64 (if (<= y -2.4e+24) (* y t) (if (<= y 1.7e+26) (fma x z x) (- (* y x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.4e+24) {
tmp = y * t;
} else if (y <= 1.7e+26) {
tmp = fma(x, z, x);
} else {
tmp = -(y * x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.4e+24) tmp = Float64(y * t); elseif (y <= 1.7e+26) tmp = fma(x, z, x); else tmp = Float64(-Float64(y * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.4e+24], N[(y * t), $MachinePrecision], If[LessEqual[y, 1.7e+26], N[(x * z + x), $MachinePrecision], (-N[(y * x), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+24}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;-y \cdot x\\
\end{array}
\end{array}
if y < -2.4000000000000001e24Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6472.2
Applied rewrites72.2%
Taylor expanded in y around inf
Applied rewrites62.5%
if -2.4000000000000001e24 < y < 1.7000000000000001e26Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6488.7
Applied rewrites88.7%
Taylor expanded in x around inf
Applied rewrites52.5%
if 1.7000000000000001e26 < y Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in t around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f6456.7
Applied rewrites56.7%
Taylor expanded in y around inf
Applied rewrites45.7%
Final simplification53.7%
(FPCore (x y z t) :precision binary64 (if (<= y -2.4e+24) (* y t) (if (<= y 2.45e+129) (fma x z x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.4e+24) {
tmp = y * t;
} else if (y <= 2.45e+129) {
tmp = fma(x, z, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.4e+24) tmp = Float64(y * t); elseif (y <= 2.45e+129) tmp = fma(x, z, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.4e+24], N[(y * t), $MachinePrecision], If[LessEqual[y, 2.45e+129], N[(x * z + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+24}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -2.4000000000000001e24 or 2.45e129 < y Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6467.0
Applied rewrites67.0%
Taylor expanded in y around inf
Applied rewrites58.3%
if -2.4000000000000001e24 < y < 2.45e129Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6484.6
Applied rewrites84.6%
Taylor expanded in x around inf
Applied rewrites50.9%
Final simplification53.5%
(FPCore (x y z t) :precision binary64 (if (<= t -3.2e-59) (* y t) (if (<= t 7.3e-63) (* z x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.2e-59) {
tmp = y * t;
} else if (t <= 7.3e-63) {
tmp = z * x;
} else {
tmp = y * 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 <= (-3.2d-59)) then
tmp = y * t
else if (t <= 7.3d-63) then
tmp = z * x
else
tmp = y * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.2e-59) {
tmp = y * t;
} else if (t <= 7.3e-63) {
tmp = z * x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -3.2e-59: tmp = y * t elif t <= 7.3e-63: tmp = z * x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -3.2e-59) tmp = Float64(y * t); elseif (t <= 7.3e-63) tmp = Float64(z * x); else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -3.2e-59) tmp = y * t; elseif (t <= 7.3e-63) tmp = z * x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.2e-59], N[(y * t), $MachinePrecision], If[LessEqual[t, 7.3e-63], N[(z * x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{-59}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;t \leq 7.3 \cdot 10^{-63}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if t < -3.1999999999999999e-59 or 7.3000000000000002e-63 < t Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6472.7
Applied rewrites72.7%
Taylor expanded in y around inf
Applied rewrites40.1%
if -3.1999999999999999e-59 < t < 7.3000000000000002e-63Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6449.1
Applied rewrites49.1%
Taylor expanded in x around inf
Applied rewrites36.9%
Final simplification38.9%
(FPCore (x y z t) :precision binary64 (* y t))
double code(double x, double y, double z, double t) {
return 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 = y * t
end function
public static double code(double x, double y, double z, double t) {
return y * t;
}
def code(x, y, z, t): return y * t
function code(x, y, z, t) return Float64(y * t) end
function tmp = code(x, y, z, t) tmp = y * t; end
code[x_, y_, z_, t_] := N[(y * t), $MachinePrecision]
\begin{array}{l}
\\
y \cdot t
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6452.9
Applied rewrites52.9%
Taylor expanded in y around inf
Applied rewrites27.8%
Final simplification27.8%
(FPCore (x y z t) :precision binary64 (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (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 = x + ((t * (y - z)) + (-x * (y - z)))
end function
public static double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (y - z)));
}
def code(x, y, z, t): return x + ((t * (y - z)) + (-x * (y - z)))
function code(x, y, z, t) return Float64(x + Float64(Float64(t * Float64(y - z)) + Float64(Float64(-x) * Float64(y - z)))) end
function tmp = code(x, y, z, t) tmp = x + ((t * (y - z)) + (-x * (y - z))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] + N[((-x) * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right)
\end{array}
herbie shell --seed 2024220
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
(+ x (* (- y z) (- t x))))