
(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%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z x))))
(if (<= z -3.4e-11)
t_1
(if (<= z 1.55e-87)
(+ x (* y t))
(if (or (<= z 1.6e+22) (and (not (<= z 6.5e+43)) (<= z 6.6e+150)))
(- x (* z t))
t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * x);
double tmp;
if (z <= -3.4e-11) {
tmp = t_1;
} else if (z <= 1.55e-87) {
tmp = x + (y * t);
} else if ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150))) {
tmp = x - (z * 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 = x + (z * x)
if (z <= (-3.4d-11)) then
tmp = t_1
else if (z <= 1.55d-87) then
tmp = x + (y * t)
else if ((z <= 1.6d+22) .or. (.not. (z <= 6.5d+43)) .and. (z <= 6.6d+150)) then
tmp = x - (z * 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 = x + (z * x);
double tmp;
if (z <= -3.4e-11) {
tmp = t_1;
} else if (z <= 1.55e-87) {
tmp = x + (y * t);
} else if ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150))) {
tmp = x - (z * t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * x) tmp = 0 if z <= -3.4e-11: tmp = t_1 elif z <= 1.55e-87: tmp = x + (y * t) elif (z <= 1.6e+22) or (not (z <= 6.5e+43) and (z <= 6.6e+150)): tmp = x - (z * t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * x)) tmp = 0.0 if (z <= -3.4e-11) tmp = t_1; elseif (z <= 1.55e-87) tmp = Float64(x + Float64(y * t)); elseif ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150))) tmp = Float64(x - Float64(z * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * x); tmp = 0.0; if (z <= -3.4e-11) tmp = t_1; elseif (z <= 1.55e-87) tmp = x + (y * t); elseif ((z <= 1.6e+22) || (~((z <= 6.5e+43)) && (z <= 6.6e+150))) tmp = x - (z * t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.4e-11], t$95$1, If[LessEqual[z, 1.55e-87], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.6e+22], And[N[Not[LessEqual[z, 6.5e+43]], $MachinePrecision], LessEqual[z, 6.6e+150]]], N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot x\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{-11}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-87}:\\
\;\;\;\;x + y \cdot t\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+22} \lor \neg \left(z \leq 6.5 \cdot 10^{+43}\right) \land z \leq 6.6 \cdot 10^{+150}:\\
\;\;\;\;x - z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -3.3999999999999999e-11 or 1.6e22 < z < 6.4999999999999998e43 or 6.59999999999999962e150 < z Initial program 100.0%
sub-neg100.0%
distribute-lft-in92.2%
Applied egg-rr92.2%
Taylor expanded in y around 0 80.2%
Taylor expanded in t around 0 52.9%
if -3.3999999999999999e-11 < z < 1.54999999999999999e-87Initial program 99.9%
Taylor expanded in t around inf 80.6%
Taylor expanded in z around 0 76.3%
if 1.54999999999999999e-87 < z < 1.6e22 or 6.4999999999999998e43 < z < 6.59999999999999962e150Initial program 99.9%
Taylor expanded in t around inf 61.2%
Taylor expanded in y around 0 52.4%
+-commutative52.4%
mul-1-neg52.4%
unsub-neg52.4%
Simplified52.4%
Final simplification61.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z x))) (t_2 (- x (* z t))))
(if (<= y -2.8e-28)
(+ x (* y t))
(if (<= y -1.55e-257)
t_2
(if (<= y -3e-287)
t_1
(if (<= y 1.4e-62) t_2 (if (<= y 32.0) t_1 (- x (* y x)))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * x);
double t_2 = x - (z * t);
double tmp;
if (y <= -2.8e-28) {
tmp = x + (y * t);
} else if (y <= -1.55e-257) {
tmp = t_2;
} else if (y <= -3e-287) {
tmp = t_1;
} else if (y <= 1.4e-62) {
tmp = t_2;
} else if (y <= 32.0) {
tmp = t_1;
} else {
tmp = x - (y * x);
}
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 = x + (z * x)
t_2 = x - (z * t)
if (y <= (-2.8d-28)) then
tmp = x + (y * t)
else if (y <= (-1.55d-257)) then
tmp = t_2
else if (y <= (-3d-287)) then
tmp = t_1
else if (y <= 1.4d-62) then
tmp = t_2
else if (y <= 32.0d0) then
tmp = t_1
else
tmp = x - (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * x);
double t_2 = x - (z * t);
double tmp;
if (y <= -2.8e-28) {
tmp = x + (y * t);
} else if (y <= -1.55e-257) {
tmp = t_2;
} else if (y <= -3e-287) {
tmp = t_1;
} else if (y <= 1.4e-62) {
tmp = t_2;
} else if (y <= 32.0) {
tmp = t_1;
} else {
tmp = x - (y * x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * x) t_2 = x - (z * t) tmp = 0 if y <= -2.8e-28: tmp = x + (y * t) elif y <= -1.55e-257: tmp = t_2 elif y <= -3e-287: tmp = t_1 elif y <= 1.4e-62: tmp = t_2 elif y <= 32.0: tmp = t_1 else: tmp = x - (y * x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * x)) t_2 = Float64(x - Float64(z * t)) tmp = 0.0 if (y <= -2.8e-28) tmp = Float64(x + Float64(y * t)); elseif (y <= -1.55e-257) tmp = t_2; elseif (y <= -3e-287) tmp = t_1; elseif (y <= 1.4e-62) tmp = t_2; elseif (y <= 32.0) tmp = t_1; else tmp = Float64(x - Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * x); t_2 = x - (z * t); tmp = 0.0; if (y <= -2.8e-28) tmp = x + (y * t); elseif (y <= -1.55e-257) tmp = t_2; elseif (y <= -3e-287) tmp = t_1; elseif (y <= 1.4e-62) tmp = t_2; elseif (y <= 32.0) tmp = t_1; else tmp = x - (y * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.8e-28], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.55e-257], t$95$2, If[LessEqual[y, -3e-287], t$95$1, If[LessEqual[y, 1.4e-62], t$95$2, If[LessEqual[y, 32.0], t$95$1, N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot x\\
t_2 := x - z \cdot t\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{-28}:\\
\;\;\;\;x + y \cdot t\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-257}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-287}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-62}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 32:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot x\\
\end{array}
\end{array}
if y < -2.7999999999999998e-28Initial program 100.0%
Taylor expanded in t around inf 52.6%
Taylor expanded in z around 0 48.2%
if -2.7999999999999998e-28 < y < -1.55000000000000004e-257 or -2.99999999999999992e-287 < y < 1.40000000000000001e-62Initial program 100.0%
Taylor expanded in t around inf 82.7%
Taylor expanded in y around 0 74.4%
+-commutative74.4%
mul-1-neg74.4%
unsub-neg74.4%
Simplified74.4%
if -1.55000000000000004e-257 < y < -2.99999999999999992e-287 or 1.40000000000000001e-62 < y < 32Initial program 99.9%
sub-neg99.9%
distribute-lft-in100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 94.6%
Taylor expanded in t around 0 76.6%
if 32 < y Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in t around 0 64.0%
+-commutative64.0%
mul-1-neg64.0%
unsub-neg64.0%
*-commutative64.0%
Simplified64.0%
Taylor expanded in y around inf 53.4%
Final simplification63.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z x))))
(if (<= x -1.1e+145)
t_1
(if (<= x 6.4e+118)
(- x (* t (- z y)))
(if (<= x 4.5e+257) t_1 (- x (* y x)))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * x);
double tmp;
if (x <= -1.1e+145) {
tmp = t_1;
} else if (x <= 6.4e+118) {
tmp = x - (t * (z - y));
} else if (x <= 4.5e+257) {
tmp = t_1;
} else {
tmp = x - (y * x);
}
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 = x + (z * x)
if (x <= (-1.1d+145)) then
tmp = t_1
else if (x <= 6.4d+118) then
tmp = x - (t * (z - y))
else if (x <= 4.5d+257) then
tmp = t_1
else
tmp = x - (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * x);
double tmp;
if (x <= -1.1e+145) {
tmp = t_1;
} else if (x <= 6.4e+118) {
tmp = x - (t * (z - y));
} else if (x <= 4.5e+257) {
tmp = t_1;
} else {
tmp = x - (y * x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * x) tmp = 0 if x <= -1.1e+145: tmp = t_1 elif x <= 6.4e+118: tmp = x - (t * (z - y)) elif x <= 4.5e+257: tmp = t_1 else: tmp = x - (y * x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * x)) tmp = 0.0 if (x <= -1.1e+145) tmp = t_1; elseif (x <= 6.4e+118) tmp = Float64(x - Float64(t * Float64(z - y))); elseif (x <= 4.5e+257) tmp = t_1; else tmp = Float64(x - Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * x); tmp = 0.0; if (x <= -1.1e+145) tmp = t_1; elseif (x <= 6.4e+118) tmp = x - (t * (z - y)); elseif (x <= 4.5e+257) tmp = t_1; else tmp = x - (y * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.1e+145], t$95$1, If[LessEqual[x, 6.4e+118], N[(x - N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e+257], t$95$1, N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot x\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{+118}:\\
\;\;\;\;x - t \cdot \left(z - y\right)\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+257}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot x\\
\end{array}
\end{array}
if x < -1.10000000000000004e145 or 6.40000000000000032e118 < x < 4.4999999999999999e257Initial program 100.0%
sub-neg100.0%
distribute-lft-in92.4%
Applied egg-rr92.4%
Taylor expanded in y around 0 73.0%
Taylor expanded in t around 0 69.5%
if -1.10000000000000004e145 < x < 6.40000000000000032e118Initial program 99.9%
Taylor expanded in t around inf 77.1%
if 4.4999999999999999e257 < x Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in t around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 91.7%
Final simplification75.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -0.028) (not (<= z 190.0))) (+ x (* z (- x t))) (- x (* t (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.028) || !(z <= 190.0)) {
tmp = x + (z * (x - t));
} else {
tmp = x - (t * (z - y));
}
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 <= (-0.028d0)) .or. (.not. (z <= 190.0d0))) then
tmp = x + (z * (x - t))
else
tmp = x - (t * (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.028) || !(z <= 190.0)) {
tmp = x + (z * (x - t));
} else {
tmp = x - (t * (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -0.028) or not (z <= 190.0): tmp = x + (z * (x - t)) else: tmp = x - (t * (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -0.028) || !(z <= 190.0)) tmp = Float64(x + Float64(z * Float64(x - t))); else tmp = Float64(x - Float64(t * Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -0.028) || ~((z <= 190.0))) tmp = x + (z * (x - t)); else tmp = x - (t * (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.028], N[Not[LessEqual[z, 190.0]], $MachinePrecision]], N[(x + N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.028 \lor \neg \left(z \leq 190\right):\\
\;\;\;\;x + z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x - t \cdot \left(z - y\right)\\
\end{array}
\end{array}
if z < -0.0280000000000000006 or 190 < z Initial program 100.0%
sub-neg100.0%
distribute-lft-in94.1%
Applied egg-rr94.1%
Taylor expanded in y around 0 73.9%
associate-*r*73.9%
*-commutative73.9%
distribute-rgt-in79.9%
+-commutative79.9%
mul-1-neg79.9%
sub-neg79.9%
Simplified79.9%
if -0.0280000000000000006 < z < 190Initial program 99.9%
Taylor expanded in t around inf 77.6%
Final simplification78.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.2e+39) (not (<= y 2.6e+15))) (- x (* y (- x t))) (+ x (* z (- x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+39) || !(y <= 2.6e+15)) {
tmp = x - (y * (x - t));
} else {
tmp = x + (z * (x - 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 ((y <= (-6.2d+39)) .or. (.not. (y <= 2.6d+15))) then
tmp = x - (y * (x - t))
else
tmp = x + (z * (x - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+39) || !(y <= 2.6e+15)) {
tmp = x - (y * (x - t));
} else {
tmp = x + (z * (x - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -6.2e+39) or not (y <= 2.6e+15): tmp = x - (y * (x - t)) else: tmp = x + (z * (x - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.2e+39) || !(y <= 2.6e+15)) tmp = Float64(x - Float64(y * Float64(x - t))); else tmp = Float64(x + Float64(z * Float64(x - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -6.2e+39) || ~((y <= 2.6e+15))) tmp = x - (y * (x - t)); else tmp = x + (z * (x - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.2e+39], N[Not[LessEqual[y, 2.6e+15]], $MachinePrecision]], N[(x - N[(y * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+39} \lor \neg \left(y \leq 2.6 \cdot 10^{+15}\right):\\
\;\;\;\;x - y \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(x - t\right)\\
\end{array}
\end{array}
if y < -6.2000000000000005e39 or 2.6e15 < y Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 81.6%
if -6.2000000000000005e39 < y < 2.6e15Initial program 100.0%
sub-neg100.0%
distribute-lft-in100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 88.2%
associate-*r*88.2%
*-commutative88.2%
distribute-rgt-in88.2%
+-commutative88.2%
mul-1-neg88.2%
sub-neg88.2%
Simplified88.2%
Final simplification85.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.4e-65) (not (<= t 2.95e+16))) (- x (* t (- z y))) (+ x (* x (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.4e-65) || !(t <= 2.95e+16)) {
tmp = x - (t * (z - y));
} else {
tmp = x + (x * (z - y));
}
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.4d-65)) .or. (.not. (t <= 2.95d+16))) then
tmp = x - (t * (z - y))
else
tmp = x + (x * (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.4e-65) || !(t <= 2.95e+16)) {
tmp = x - (t * (z - y));
} else {
tmp = x + (x * (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.4e-65) or not (t <= 2.95e+16): tmp = x - (t * (z - y)) else: tmp = x + (x * (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.4e-65) || !(t <= 2.95e+16)) tmp = Float64(x - Float64(t * Float64(z - y))); else tmp = Float64(x + Float64(x * Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -3.4e-65) || ~((t <= 2.95e+16))) tmp = x - (t * (z - y)); else tmp = x + (x * (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.4e-65], N[Not[LessEqual[t, 2.95e+16]], $MachinePrecision]], N[(x - N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.4 \cdot 10^{-65} \lor \neg \left(t \leq 2.95 \cdot 10^{+16}\right):\\
\;\;\;\;x - t \cdot \left(z - y\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z - y\right)\\
\end{array}
\end{array}
if t < -3.39999999999999987e-65 or 2.95e16 < t Initial program 100.0%
Taylor expanded in t around inf 83.9%
if -3.39999999999999987e-65 < t < 2.95e16Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in t around 0 88.2%
+-commutative88.2%
mul-1-neg88.2%
unsub-neg88.2%
*-commutative88.2%
Simplified88.2%
Final simplification85.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -8.6e-11) (not (<= z 5300000.0))) (+ x (* z x)) (+ x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.6e-11) || !(z <= 5300000.0)) {
tmp = x + (z * x);
} else {
tmp = x + (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 ((z <= (-8.6d-11)) .or. (.not. (z <= 5300000.0d0))) then
tmp = x + (z * x)
else
tmp = x + (y * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.6e-11) || !(z <= 5300000.0)) {
tmp = x + (z * x);
} else {
tmp = x + (y * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8.6e-11) or not (z <= 5300000.0): tmp = x + (z * x) else: tmp = x + (y * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -8.6e-11) || !(z <= 5300000.0)) tmp = Float64(x + Float64(z * x)); else tmp = Float64(x + Float64(y * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -8.6e-11) || ~((z <= 5300000.0))) tmp = x + (z * x); else tmp = x + (y * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8.6e-11], N[Not[LessEqual[z, 5300000.0]], $MachinePrecision]], N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.6 \cdot 10^{-11} \lor \neg \left(z \leq 5300000\right):\\
\;\;\;\;x + z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot t\\
\end{array}
\end{array}
if z < -8.60000000000000003e-11 or 5.3e6 < z Initial program 100.0%
sub-neg100.0%
distribute-lft-in94.1%
Applied egg-rr94.1%
Taylor expanded in y around 0 80.0%
Taylor expanded in t around 0 46.0%
if -8.60000000000000003e-11 < z < 5.3e6Initial program 99.9%
Taylor expanded in t around inf 78.8%
Taylor expanded in z around 0 66.9%
Final simplification55.7%
(FPCore (x y z t) :precision binary64 (- x (* (- y z) (- x t))))
double code(double x, double y, double z, double t) {
return x - ((y - z) * (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 = x - ((y - z) * (x - t))
end function
public static double code(double x, double y, double z, double t) {
return x - ((y - z) * (x - t));
}
def code(x, y, z, t): return x - ((y - z) * (x - t))
function code(x, y, z, t) return Float64(x - Float64(Float64(y - z) * Float64(x - t))) end
function tmp = code(x, y, z, t) tmp = x - ((y - z) * (x - t)); end
code[x_, y_, z_, t_] := N[(x - N[(N[(y - z), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(y - z\right) \cdot \left(x - t\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (+ x (* y t)))
double code(double x, double y, double z, double t) {
return x + (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 = x + (y * t)
end function
public static double code(double x, double y, double z, double t) {
return x + (y * t);
}
def code(x, y, z, t): return x + (y * t)
function code(x, y, z, t) return Float64(x + Float64(y * t)) end
function tmp = code(x, y, z, t) tmp = x + (y * t); end
code[x_, y_, z_, t_] := N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot t
\end{array}
Initial program 100.0%
Taylor expanded in t around inf 60.4%
Taylor expanded in z around 0 38.8%
Final simplification38.8%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return 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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in t around inf 60.4%
Taylor expanded in x around inf 16.5%
Final simplification16.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 2023182
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:herbie-target
(+ x (+ (* t (- y z)) (* (- x) (- y z))))
(+ x (* (- y z) (- t x))))