
(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 (+ 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}
Initial program 100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- t))))
(if (<= x -2.9e-46)
(fma x z x)
(if (<= x -6.6e-307)
t_1
(if (<= x 6.8e-180) (* y t) (if (<= x 17000000.0) t_1 (fma x z x)))))))
double code(double x, double y, double z, double t) {
double t_1 = z * -t;
double tmp;
if (x <= -2.9e-46) {
tmp = fma(x, z, x);
} else if (x <= -6.6e-307) {
tmp = t_1;
} else if (x <= 6.8e-180) {
tmp = y * t;
} else if (x <= 17000000.0) {
tmp = t_1;
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(-t)) tmp = 0.0 if (x <= -2.9e-46) tmp = fma(x, z, x); elseif (x <= -6.6e-307) tmp = t_1; elseif (x <= 6.8e-180) tmp = Float64(y * t); elseif (x <= 17000000.0) tmp = t_1; else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * (-t)), $MachinePrecision]}, If[LessEqual[x, -2.9e-46], N[(x * z + x), $MachinePrecision], If[LessEqual[x, -6.6e-307], t$95$1, If[LessEqual[x, 6.8e-180], N[(y * t), $MachinePrecision], If[LessEqual[x, 17000000.0], t$95$1, N[(x * z + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(-t\right)\\
\mathbf{if}\;x \leq -2.9 \cdot 10^{-46}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{-307}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-180}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;x \leq 17000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if x < -2.90000000000000005e-46 or 1.7e7 < x Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6496.6
Applied rewrites96.6%
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
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6484.0
Applied rewrites84.0%
Taylor expanded in y around 0
Applied rewrites53.9%
if -2.90000000000000005e-46 < x < -6.59999999999999999e-307 or 6.79999999999999963e-180 < x < 1.7e7Initial 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--.f6462.8
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites52.8%
if -6.59999999999999999e-307 < x < 6.79999999999999963e-180Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6464.2
Applied rewrites64.2%
Taylor expanded in t around inf
Applied rewrites58.1%
Final simplification53.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -1.3e+16)
t_1
(if (<= z 1.6e-11)
(fma y (- t x) x)
(if (<= z 2.75e+66) (* (- y z) t) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -1.3e+16) {
tmp = t_1;
} else if (z <= 1.6e-11) {
tmp = fma(y, (t - x), x);
} else if (z <= 2.75e+66) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -1.3e+16) tmp = t_1; elseif (z <= 1.6e-11) tmp = fma(y, Float64(t - x), x); elseif (z <= 2.75e+66) tmp = Float64(Float64(y - z) * t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+16], t$95$1, If[LessEqual[z, 1.6e-11], N[(y * N[(t - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.75e+66], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(y, t - x, x\right)\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+66}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.3e16 or 2.75e66 < z Initial 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--.f6483.6
Applied rewrites83.6%
if -1.3e16 < z < 1.59999999999999997e-11Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6489.8
Applied rewrites89.8%
if 1.59999999999999997e-11 < z < 2.75e66Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6479.5
Applied rewrites79.5%
Final simplification86.2%
(FPCore (x y z t)
:precision binary64
(if (<= x -1.55e-44)
(fma x z x)
(if (<= x 22000000.0)
(* (- y z) t)
(if (<= x 2.6e+171) (* y (- t x)) (fma x z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.55e-44) {
tmp = fma(x, z, x);
} else if (x <= 22000000.0) {
tmp = (y - z) * t;
} else if (x <= 2.6e+171) {
tmp = y * (t - x);
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -1.55e-44) tmp = fma(x, z, x); elseif (x <= 22000000.0) tmp = Float64(Float64(y - z) * t); elseif (x <= 2.6e+171) tmp = Float64(y * Float64(t - x)); else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.55e-44], N[(x * z + x), $MachinePrecision], If[LessEqual[x, 22000000.0], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[x, 2.6e+171], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(x * z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;x \leq 22000000:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+171}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if x < -1.54999999999999992e-44 or 2.6e171 < x Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6497.6
Applied rewrites97.6%
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
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6489.7
Applied rewrites89.7%
Taylor expanded in y around 0
Applied rewrites61.0%
if -1.54999999999999992e-44 < x < 2.2e7Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6478.9
Applied rewrites78.9%
if 2.2e7 < x < 2.6e171Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6456.5
Applied rewrites56.5%
Final simplification70.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (- t x) x)))
(if (<= y -6800000000000.0)
t_1
(if (<= y 1.95e-44) (fma z (- x t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (t - x), x);
double tmp;
if (y <= -6800000000000.0) {
tmp = t_1;
} else if (y <= 1.95e-44) {
tmp = fma(z, (x - t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(t - x), x) tmp = 0.0 if (y <= -6800000000000.0) tmp = t_1; elseif (y <= 1.95e-44) tmp = fma(z, Float64(x - 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] + x), $MachinePrecision]}, If[LessEqual[y, -6800000000000.0], t$95$1, If[LessEqual[y, 1.95e-44], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, t - x, x\right)\\
\mathbf{if}\;y \leq -6800000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.8e12 or 1.9500000000000001e-44 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6480.1
Applied rewrites80.1%
if -6.8e12 < y < 1.9500000000000001e-44Initial 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--.f6493.0
Applied rewrites93.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma x (- z y) x))) (if (<= x -4.38e-59) t_1 (if (<= x 35000000.0) (* (- 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 <= -4.38e-59) {
tmp = t_1;
} else if (x <= 35000000.0) {
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 <= -4.38e-59) tmp = t_1; elseif (x <= 35000000.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[(x * N[(z - y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -4.38e-59], t$95$1, If[LessEqual[x, 35000000.0], 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 -4.38 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 35000000:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.38000000000000004e-59 or 3.5e7 < 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--.f6483.6
Applied rewrites83.6%
if -4.38000000000000004e-59 < x < 3.5e7Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6480.5
Applied rewrites80.5%
Final simplification82.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -6800000000000.0) t_1 (if (<= y 1.95e-44) (* z (- x t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -6800000000000.0) {
tmp = t_1;
} else if (y <= 1.95e-44) {
tmp = z * (x - t);
} 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 = y * (t - x)
if (y <= (-6800000000000.0d0)) then
tmp = t_1
else if (y <= 1.95d-44) then
tmp = z * (x - t)
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 = y * (t - x);
double tmp;
if (y <= -6800000000000.0) {
tmp = t_1;
} else if (y <= 1.95e-44) {
tmp = z * (x - t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (t - x) tmp = 0 if y <= -6800000000000.0: tmp = t_1 elif y <= 1.95e-44: tmp = z * (x - 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 <= -6800000000000.0) tmp = t_1; elseif (y <= 1.95e-44) tmp = Float64(z * Float64(x - t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (t - x); tmp = 0.0; if (y <= -6800000000000.0) tmp = t_1; elseif (y <= 1.95e-44) tmp = z * (x - t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6800000000000.0], t$95$1, If[LessEqual[y, 1.95e-44], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -6800000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-44}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.8e12 or 1.9500000000000001e-44 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6478.1
Applied rewrites78.1%
if -6.8e12 < y < 1.9500000000000001e-44Initial 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--.f6470.0
Applied rewrites70.0%
(FPCore (x y z t) :precision binary64 (if (<= x -1.55e-44) (fma x z x) (if (<= x 45000000.0) (* (- y z) t) (fma x z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.55e-44) {
tmp = fma(x, z, x);
} else if (x <= 45000000.0) {
tmp = (y - z) * t;
} else {
tmp = fma(x, z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -1.55e-44) tmp = fma(x, z, x); elseif (x <= 45000000.0) tmp = Float64(Float64(y - z) * t); else tmp = fma(x, z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.55e-44], N[(x * z + x), $MachinePrecision], If[LessEqual[x, 45000000.0], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(x * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;x \leq 45000000:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\end{array}
\end{array}
if x < -1.54999999999999992e-44 or 4.5e7 < x Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6496.6
Applied rewrites96.6%
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
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 y around 0
Applied rewrites54.4%
if -1.54999999999999992e-44 < x < 4.5e7Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6479.1
Applied rewrites79.1%
Final simplification67.7%
(FPCore (x y z t) :precision binary64 (if (<= y -1.05e+71) (* y t) (if (<= y 9.2e-28) (fma x z x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e+71) {
tmp = y * t;
} else if (y <= 9.2e-28) {
tmp = fma(x, z, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.05e+71) tmp = Float64(y * t); elseif (y <= 9.2e-28) tmp = fma(x, z, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.05e+71], N[(y * t), $MachinePrecision], If[LessEqual[y, 9.2e-28], N[(x * z + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+71}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -1.04999999999999995e71 or 9.19999999999999942e-28 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6480.8
Applied rewrites80.8%
Taylor expanded in t around inf
Applied rewrites44.7%
if -1.04999999999999995e71 < y < 9.19999999999999942e-28Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.3
Applied rewrites99.3%
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
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6453.2
Applied rewrites53.2%
Taylor expanded in y around 0
Applied rewrites48.8%
Final simplification47.0%
(FPCore (x y z t) :precision binary64 (if (<= z -3e+103) (* x z) (if (<= z 2.75e+66) (* y t) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3e+103) {
tmp = x * z;
} else if (z <= 2.75e+66) {
tmp = y * t;
} else {
tmp = x * z;
}
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 <= (-3d+103)) then
tmp = x * z
else if (z <= 2.75d+66) then
tmp = y * t
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3e+103) {
tmp = x * z;
} else if (z <= 2.75e+66) {
tmp = y * t;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3e+103: tmp = x * z elif z <= 2.75e+66: tmp = y * t else: tmp = x * z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3e+103) tmp = Float64(x * z); elseif (z <= 2.75e+66) tmp = Float64(y * t); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3e+103) tmp = x * z; elseif (z <= 2.75e+66) tmp = y * t; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3e+103], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.75e+66], N[(y * t), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+103}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+66}:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -3e103 or 2.75e66 < z Initial 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--.f6487.6
Applied rewrites87.6%
Taylor expanded in x around inf
Applied rewrites45.0%
if -3e103 < z < 2.75e66Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6479.6
Applied rewrites79.6%
Taylor expanded in t around inf
Applied rewrites35.5%
Final simplification39.2%
(FPCore (x y z t) :precision binary64 (* x z))
double code(double x, double y, double z, double t) {
return x * 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 * z
end function
public static double code(double x, double y, double z, double t) {
return x * z;
}
def code(x, y, z, t): return x * z
function code(x, y, z, t) return Float64(x * z) end
function tmp = code(x, y, z, t) tmp = x * z; end
code[x_, y_, z_, t_] := N[(x * z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot z
\end{array}
Initial 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--.f6447.6
Applied rewrites47.6%
Taylor expanded in x around inf
Applied rewrites21.0%
(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 2024226
(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))))