
(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 (* y (- t x))) (t_2 (* z (- x t))))
(if (<= y -1100.0)
t_1
(if (<= y -2.4e-166)
t_2
(if (<= y 1.4e-11) (fma z x x) (if (<= y 6.4e+36) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = z * (x - t);
double tmp;
if (y <= -1100.0) {
tmp = t_1;
} else if (y <= -2.4e-166) {
tmp = t_2;
} else if (y <= 1.4e-11) {
tmp = fma(z, x, x);
} else if (y <= 6.4e+36) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) t_2 = Float64(z * Float64(x - t)) tmp = 0.0 if (y <= -1100.0) tmp = t_1; elseif (y <= -2.4e-166) tmp = t_2; elseif (y <= 1.4e-11) tmp = fma(z, x, x); elseif (y <= 6.4e+36) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1100.0], t$95$1, If[LessEqual[y, -2.4e-166], t$95$2, If[LessEqual[y, 1.4e-11], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 6.4e+36], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := z \cdot \left(x - t\right)\\
\mathbf{if}\;y \leq -1100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-166}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{+36}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1100 or 6.3999999999999998e36 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6484.6
Applied rewrites84.6%
if -1100 < y < -2.3999999999999999e-166 or 1.4e-11 < y < 6.3999999999999998e36Initial 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--.f6474.1
Applied rewrites74.1%
if -2.3999999999999999e-166 < y < 1.4e-11Initial 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--.f6489.4
Applied rewrites89.4%
Taylor expanded in x around inf
Applied rewrites66.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -1100.0)
t_1
(if (<= y -1.35e-165)
(* z (- x t))
(if (<= y 8.6e+18) (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 <= -1100.0) {
tmp = t_1;
} else if (y <= -1.35e-165) {
tmp = z * (x - t);
} else if (y <= 8.6e+18) {
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 <= -1100.0) tmp = t_1; elseif (y <= -1.35e-165) tmp = Float64(z * Float64(x - t)); elseif (y <= 8.6e+18) 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, -1100.0], t$95$1, If[LessEqual[y, -1.35e-165], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+18], 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 -1100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-165}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(z, -t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1100 or 8.6e18 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6482.5
Applied rewrites82.5%
if -1100 < y < -1.3499999999999999e-165Initial 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--.f6471.5
Applied rewrites71.5%
if -1.3499999999999999e-165 < y < 8.6e18Initial 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--.f6490.1
Applied rewrites90.1%
Taylor expanded in x around 0
Applied rewrites69.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -3e+79)
t_1
(if (<= y -2.3e-15) (* (- y z) t) (if (<= y 4.6e+36) (fma z x x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -3e+79) {
tmp = t_1;
} else if (y <= -2.3e-15) {
tmp = (y - z) * t;
} else if (y <= 4.6e+36) {
tmp = fma(z, x, 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 <= -3e+79) tmp = t_1; elseif (y <= -2.3e-15) tmp = Float64(Float64(y - z) * t); elseif (y <= 4.6e+36) tmp = fma(z, x, 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, -3e+79], t$95$1, If[LessEqual[y, -2.3e-15], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[y, 4.6e+36], N[(z * x + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -3 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{-15}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.99999999999999974e79 or 4.59999999999999993e36 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6486.8
Applied rewrites86.8%
if -2.99999999999999974e79 < y < -2.2999999999999999e-15Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6481.2
Applied rewrites81.2%
if -2.2999999999999999e-15 < y < 4.59999999999999993e36Initial 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--.f6489.6
Applied rewrites89.6%
Taylor expanded in x around inf
Applied rewrites61.4%
Final simplification74.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -1100.0) t_1 (if (<= y 6.4e+36) (fma z (- x t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -1100.0) {
tmp = t_1;
} else if (y <= 6.4e+36) {
tmp = fma(z, (x - 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 <= -1100.0) tmp = t_1; elseif (y <= 6.4e+36) 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]), $MachinePrecision]}, If[LessEqual[y, -1100.0], t$95$1, If[LessEqual[y, 6.4e+36], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -1100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1100 or 6.3999999999999998e36 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6484.6
Applied rewrites84.6%
if -1100 < y < 6.3999999999999998e36Initial 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--.f6488.6
Applied rewrites88.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma x (- z y) x))) (if (<= x -3.3e+80) t_1 (if (<= x 1.2e+64) (* (- 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 <= -3.3e+80) {
tmp = t_1;
} else if (x <= 1.2e+64) {
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 <= -3.3e+80) tmp = t_1; elseif (x <= 1.2e+64) 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, -3.3e+80], t$95$1, If[LessEqual[x, 1.2e+64], 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 -3.3 \cdot 10^{+80}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+64}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.29999999999999991e80 or 1.2e64 < 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--.f6490.7
Applied rewrites90.7%
if -3.29999999999999991e80 < x < 1.2e64Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6473.6
Applied rewrites73.6%
Final simplification80.8%
(FPCore (x y z t) :precision binary64 (if (<= x -3.2e+107) (fma z x x) (if (<= x 1.45e+65) (* (- y z) t) (fma z x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.2e+107) {
tmp = fma(z, x, x);
} else if (x <= 1.45e+65) {
tmp = (y - z) * t;
} else {
tmp = fma(z, x, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -3.2e+107) tmp = fma(z, x, x); elseif (x <= 1.45e+65) tmp = Float64(Float64(y - z) * t); else tmp = fma(z, x, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -3.2e+107], N[(z * x + x), $MachinePrecision], If[LessEqual[x, 1.45e+65], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(z * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+65}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\end{array}
\end{array}
if x < -3.20000000000000029e107 or 1.45e65 < 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--.f6459.4
Applied rewrites59.4%
Taylor expanded in x around inf
Applied rewrites59.4%
if -3.20000000000000029e107 < x < 1.45e65Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6471.5
Applied rewrites71.5%
Final simplification66.9%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e-15) (* y t) (if (<= y 1.95e+52) (fma z x x) (- (* x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-15) {
tmp = y * t;
} else if (y <= 1.95e+52) {
tmp = fma(z, x, x);
} else {
tmp = -(x * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e-15) tmp = Float64(y * t); elseif (y <= 1.95e+52) tmp = fma(z, x, x); else tmp = Float64(-Float64(x * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e-15], N[(y * t), $MachinePrecision], If[LessEqual[y, 1.95e+52], N[(z * x + x), $MachinePrecision], (-N[(x * y), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-15}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;-x \cdot y\\
\end{array}
\end{array}
if y < -4.19999999999999962e-15Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6463.3
Applied rewrites63.3%
Taylor expanded in y around inf
Applied rewrites50.4%
if -4.19999999999999962e-15 < y < 1.95e52Initial 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--.f6488.1
Applied rewrites88.1%
Taylor expanded in x around inf
Applied rewrites60.4%
if 1.95e52 < y 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.f6492.0
Applied rewrites92.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
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
mul-1-negN/A
remove-double-negN/A
lower--.f6457.4
Applied rewrites57.4%
Taylor expanded in y around inf
Applied rewrites49.9%
Final simplification54.9%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e-15) (* y t) (if (<= y 5.2e+36) (fma z x x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-15) {
tmp = y * t;
} else if (y <= 5.2e+36) {
tmp = fma(z, x, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e-15) tmp = Float64(y * t); elseif (y <= 5.2e+36) tmp = fma(z, x, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e-15], N[(y * t), $MachinePrecision], If[LessEqual[y, 5.2e+36], N[(z * x + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-15}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -4.19999999999999962e-15 or 5.2000000000000003e36 < y Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6458.0
Applied rewrites58.0%
Taylor expanded in y around inf
Applied rewrites46.4%
if -4.19999999999999962e-15 < y < 5.2000000000000003e36Initial 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--.f6489.6
Applied rewrites89.6%
Taylor expanded in x around inf
Applied rewrites61.4%
Final simplification53.2%
(FPCore (x y z t) :precision binary64 (if (<= x -7.2e+59) (* x z) (if (<= x 9.8e+64) (* y t) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.2e+59) {
tmp = x * z;
} else if (x <= 9.8e+64) {
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 (x <= (-7.2d+59)) then
tmp = x * z
else if (x <= 9.8d+64) 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 (x <= -7.2e+59) {
tmp = x * z;
} else if (x <= 9.8e+64) {
tmp = y * t;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.2e+59: tmp = x * z elif x <= 9.8e+64: tmp = y * t else: tmp = x * z return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.2e+59) tmp = Float64(x * z); elseif (x <= 9.8e+64) 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 (x <= -7.2e+59) tmp = x * z; elseif (x <= 9.8e+64) tmp = y * t; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.2e+59], N[(x * z), $MachinePrecision], If[LessEqual[x, 9.8e+64], N[(y * t), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+59}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{+64}:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if x < -7.1999999999999997e59 or 9.8000000000000005e64 < x 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--.f6439.2
Applied rewrites39.2%
Taylor expanded in x around inf
Applied rewrites35.3%
if -7.1999999999999997e59 < x < 9.8000000000000005e64Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6473.0
Applied rewrites73.0%
Taylor expanded in y around inf
Applied rewrites43.9%
Final simplification40.2%
(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--.f6450.0
Applied rewrites50.0%
Taylor expanded in y around inf
Applied rewrites30.5%
Final simplification30.5%
(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 2024238
(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))))