
(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 12 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 (* y (- t x))) (t_2 (* (- y z) t)))
(if (<= z -3.6e+115)
t_2
(if (<= z -4.3e+18)
(* z x)
(if (<= z -9.5e-56)
t_1
(if (<= z -2.1e-94) x (if (<= z 4.5e-44) t_1 t_2)))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = (y - z) * t;
double tmp;
if (z <= -3.6e+115) {
tmp = t_2;
} else if (z <= -4.3e+18) {
tmp = z * x;
} else if (z <= -9.5e-56) {
tmp = t_1;
} else if (z <= -2.1e-94) {
tmp = x;
} else if (z <= 4.5e-44) {
tmp = t_1;
} else {
tmp = t_2;
}
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 = y * (t - x)
t_2 = (y - z) * t
if (z <= (-3.6d+115)) then
tmp = t_2
else if (z <= (-4.3d+18)) then
tmp = z * x
else if (z <= (-9.5d-56)) then
tmp = t_1
else if (z <= (-2.1d-94)) then
tmp = x
else if (z <= 4.5d-44) then
tmp = t_1
else
tmp = t_2
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 t_2 = (y - z) * t;
double tmp;
if (z <= -3.6e+115) {
tmp = t_2;
} else if (z <= -4.3e+18) {
tmp = z * x;
} else if (z <= -9.5e-56) {
tmp = t_1;
} else if (z <= -2.1e-94) {
tmp = x;
} else if (z <= 4.5e-44) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (t - x) t_2 = (y - z) * t tmp = 0 if z <= -3.6e+115: tmp = t_2 elif z <= -4.3e+18: tmp = z * x elif z <= -9.5e-56: tmp = t_1 elif z <= -2.1e-94: tmp = x elif z <= 4.5e-44: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) t_2 = Float64(Float64(y - z) * t) tmp = 0.0 if (z <= -3.6e+115) tmp = t_2; elseif (z <= -4.3e+18) tmp = Float64(z * x); elseif (z <= -9.5e-56) tmp = t_1; elseif (z <= -2.1e-94) tmp = x; elseif (z <= 4.5e-44) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (t - x); t_2 = (y - z) * t; tmp = 0.0; if (z <= -3.6e+115) tmp = t_2; elseif (z <= -4.3e+18) tmp = z * x; elseif (z <= -9.5e-56) tmp = t_1; elseif (z <= -2.1e-94) tmp = x; elseif (z <= 4.5e-44) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z, -3.6e+115], t$95$2, If[LessEqual[z, -4.3e+18], N[(z * x), $MachinePrecision], If[LessEqual[z, -9.5e-56], t$95$1, If[LessEqual[z, -2.1e-94], x, If[LessEqual[z, 4.5e-44], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := \left(y - z\right) \cdot t\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+115}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -4.3 \cdot 10^{+18}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-56}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.1 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-44}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -3.6000000000000001e115 or 4.4999999999999999e-44 < z Initial program 99.9%
Taylor expanded in x around -inf 94.4%
+-commutative94.4%
fma-def98.1%
mul-1-neg98.1%
distribute-rgt-neg-in98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in t around inf 63.3%
if -3.6000000000000001e115 < z < -4.3e18Initial program 100.0%
Taylor expanded in x around -inf 95.7%
+-commutative95.7%
fma-def100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 81.9%
+-commutative81.9%
mul-1-neg81.9%
sub-neg81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in x around inf 78.8%
if -4.3e18 < z < -9.4999999999999991e-56 or -2.1000000000000001e-94 < z < 4.4999999999999999e-44Initial program 100.0%
Taylor expanded in x around -inf 97.4%
+-commutative97.4%
fma-def99.1%
mul-1-neg99.1%
distribute-rgt-neg-in99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in y around inf 65.0%
mul-1-neg65.0%
sub-neg65.0%
*-commutative65.0%
Simplified65.0%
if -9.4999999999999991e-56 < z < -2.1000000000000001e-94Initial program 100.0%
Taylor expanded in t around inf 86.5%
Taylor expanded in x around inf 64.8%
Final simplification65.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))) (t_2 (+ x (* (- y z) t))))
(if (<= z -11200000000.0)
t_1
(if (<= z 4e-125)
t_2
(if (<= z 1.02e-69) (* y (- t x)) (if (<= z 1.6e+27) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double t_2 = x + ((y - z) * t);
double tmp;
if (z <= -11200000000.0) {
tmp = t_1;
} else if (z <= 4e-125) {
tmp = t_2;
} else if (z <= 1.02e-69) {
tmp = y * (t - x);
} else if (z <= 1.6e+27) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_1 = z * (x - t)
t_2 = x + ((y - z) * t)
if (z <= (-11200000000.0d0)) then
tmp = t_1
else if (z <= 4d-125) then
tmp = t_2
else if (z <= 1.02d-69) then
tmp = y * (t - x)
else if (z <= 1.6d+27) then
tmp = t_2
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 = z * (x - t);
double t_2 = x + ((y - z) * t);
double tmp;
if (z <= -11200000000.0) {
tmp = t_1;
} else if (z <= 4e-125) {
tmp = t_2;
} else if (z <= 1.02e-69) {
tmp = y * (t - x);
} else if (z <= 1.6e+27) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) t_2 = x + ((y - z) * t) tmp = 0 if z <= -11200000000.0: tmp = t_1 elif z <= 4e-125: tmp = t_2 elif z <= 1.02e-69: tmp = y * (t - x) elif z <= 1.6e+27: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) t_2 = Float64(x + Float64(Float64(y - z) * t)) tmp = 0.0 if (z <= -11200000000.0) tmp = t_1; elseif (z <= 4e-125) tmp = t_2; elseif (z <= 1.02e-69) tmp = Float64(y * Float64(t - x)); elseif (z <= 1.6e+27) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); t_2 = x + ((y - z) * t); tmp = 0.0; if (z <= -11200000000.0) tmp = t_1; elseif (z <= 4e-125) tmp = t_2; elseif (z <= 1.02e-69) tmp = y * (t - x); elseif (z <= 1.6e+27) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -11200000000.0], t$95$1, If[LessEqual[z, 4e-125], t$95$2, If[LessEqual[z, 1.02e-69], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e+27], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
t_2 := x + \left(y - z\right) \cdot t\\
\mathbf{if}\;z \leq -11200000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-125}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-69}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+27}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.12e10 or 1.60000000000000008e27 < z Initial program 99.9%
Taylor expanded in x around -inf 94.9%
+-commutative94.9%
fma-def98.3%
mul-1-neg98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in z around inf 88.4%
+-commutative88.4%
mul-1-neg88.4%
sub-neg88.4%
*-commutative88.4%
Simplified88.4%
if -1.12e10 < z < 4.00000000000000005e-125 or 1.02000000000000005e-69 < z < 1.60000000000000008e27Initial program 100.0%
Taylor expanded in t around inf 79.8%
if 4.00000000000000005e-125 < z < 1.02000000000000005e-69Initial program 100.0%
Taylor expanded in x around -inf 100.0%
+-commutative100.0%
fma-def100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 77.0%
mul-1-neg77.0%
sub-neg77.0%
*-commutative77.0%
Simplified77.0%
Final simplification83.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z t))))
(if (<= z -1.2e+121)
t_1
(if (<= z -3.3e-6)
(* z x)
(if (<= z -1.92e-94)
x
(if (<= z 1.4e+48) (* y t) (if (<= z 2.25e+219) (* z x) t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = -(z * t);
double tmp;
if (z <= -1.2e+121) {
tmp = t_1;
} else if (z <= -3.3e-6) {
tmp = z * x;
} else if (z <= -1.92e-94) {
tmp = x;
} else if (z <= 1.4e+48) {
tmp = y * t;
} else if (z <= 2.25e+219) {
tmp = z * x;
} 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 = -(z * t)
if (z <= (-1.2d+121)) then
tmp = t_1
else if (z <= (-3.3d-6)) then
tmp = z * x
else if (z <= (-1.92d-94)) then
tmp = x
else if (z <= 1.4d+48) then
tmp = y * t
else if (z <= 2.25d+219) then
tmp = z * x
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 = -(z * t);
double tmp;
if (z <= -1.2e+121) {
tmp = t_1;
} else if (z <= -3.3e-6) {
tmp = z * x;
} else if (z <= -1.92e-94) {
tmp = x;
} else if (z <= 1.4e+48) {
tmp = y * t;
} else if (z <= 2.25e+219) {
tmp = z * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -(z * t) tmp = 0 if z <= -1.2e+121: tmp = t_1 elif z <= -3.3e-6: tmp = z * x elif z <= -1.92e-94: tmp = x elif z <= 1.4e+48: tmp = y * t elif z <= 2.25e+219: tmp = z * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(-Float64(z * t)) tmp = 0.0 if (z <= -1.2e+121) tmp = t_1; elseif (z <= -3.3e-6) tmp = Float64(z * x); elseif (z <= -1.92e-94) tmp = x; elseif (z <= 1.4e+48) tmp = Float64(y * t); elseif (z <= 2.25e+219) tmp = Float64(z * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -(z * t); tmp = 0.0; if (z <= -1.2e+121) tmp = t_1; elseif (z <= -3.3e-6) tmp = z * x; elseif (z <= -1.92e-94) tmp = x; elseif (z <= 1.4e+48) tmp = y * t; elseif (z <= 2.25e+219) tmp = z * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = (-N[(z * t), $MachinePrecision])}, If[LessEqual[z, -1.2e+121], t$95$1, If[LessEqual[z, -3.3e-6], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.92e-94], x, If[LessEqual[z, 1.4e+48], N[(y * t), $MachinePrecision], If[LessEqual[z, 2.25e+219], N[(z * x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -z \cdot t\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+121}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -3.3 \cdot 10^{-6}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1.92 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+48}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{+219}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.2e121 or 2.25000000000000012e219 < z Initial program 99.9%
Taylor expanded in t around inf 71.4%
Taylor expanded in z around inf 68.1%
mul-1-neg68.1%
*-commutative68.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
if -1.2e121 < z < -3.30000000000000017e-6 or 1.40000000000000006e48 < z < 2.25000000000000012e219Initial program 100.0%
Taylor expanded in x around -inf 95.5%
+-commutative95.5%
fma-def100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 82.0%
+-commutative82.0%
mul-1-neg82.0%
sub-neg82.0%
*-commutative82.0%
Simplified82.0%
Taylor expanded in x around inf 57.6%
if -3.30000000000000017e-6 < z < -1.92e-94Initial program 100.0%
Taylor expanded in t around inf 71.1%
Taylor expanded in x around inf 49.6%
if -1.92e-94 < z < 1.40000000000000006e48Initial program 100.0%
Taylor expanded in t around inf 77.6%
Taylor expanded in y around inf 46.6%
Final simplification54.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.3e-6) (not (<= z 1.05e+28))) (* z (- x t)) (+ x (* y (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.3e-6) || !(z <= 1.05e+28)) {
tmp = z * (x - t);
} else {
tmp = x + (y * (t - 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) :: tmp
if ((z <= (-3.3d-6)) .or. (.not. (z <= 1.05d+28))) then
tmp = z * (x - t)
else
tmp = x + (y * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.3e-6) || !(z <= 1.05e+28)) {
tmp = z * (x - t);
} else {
tmp = x + (y * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.3e-6) or not (z <= 1.05e+28): tmp = z * (x - t) else: tmp = x + (y * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.3e-6) || !(z <= 1.05e+28)) tmp = Float64(z * Float64(x - t)); else tmp = Float64(x + Float64(y * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.3e-6) || ~((z <= 1.05e+28))) tmp = z * (x - t); else tmp = x + (y * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.3e-6], N[Not[LessEqual[z, 1.05e+28]], $MachinePrecision]], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-6} \lor \neg \left(z \leq 1.05 \cdot 10^{+28}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(t - x\right)\\
\end{array}
\end{array}
if z < -3.30000000000000017e-6 or 1.04999999999999995e28 < z Initial program 99.9%
Taylor expanded in x around -inf 95.1%
+-commutative95.1%
fma-def98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in z around inf 87.3%
+-commutative87.3%
mul-1-neg87.3%
sub-neg87.3%
*-commutative87.3%
Simplified87.3%
if -3.30000000000000017e-6 < z < 1.04999999999999995e28Initial program 100.0%
Taylor expanded in z around 0 93.1%
Final simplification90.3%
(FPCore (x y z t) :precision binary64 (if (<= z -1.05e-14) (- x (* z (- t x))) (if (<= z 6.5e+26) (+ x (* y (- t x))) (* z (- x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e-14) {
tmp = x - (z * (t - x));
} else if (z <= 6.5e+26) {
tmp = x + (y * (t - x));
} else {
tmp = 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 (z <= (-1.05d-14)) then
tmp = x - (z * (t - x))
else if (z <= 6.5d+26) then
tmp = x + (y * (t - x))
else
tmp = z * (x - t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e-14) {
tmp = x - (z * (t - x));
} else if (z <= 6.5e+26) {
tmp = x + (y * (t - x));
} else {
tmp = z * (x - t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.05e-14: tmp = x - (z * (t - x)) elif z <= 6.5e+26: tmp = x + (y * (t - x)) else: tmp = z * (x - t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.05e-14) tmp = Float64(x - Float64(z * Float64(t - x))); elseif (z <= 6.5e+26) tmp = Float64(x + Float64(y * Float64(t - x))); else tmp = Float64(z * Float64(x - t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.05e-14) tmp = x - (z * (t - x)); elseif (z <= 6.5e+26) tmp = x + (y * (t - x)); else tmp = z * (x - t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e-14], N[(x - N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+26], N[(x + N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-14}:\\
\;\;\;\;x - z \cdot \left(t - x\right)\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+26}:\\
\;\;\;\;x + y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\end{array}
\end{array}
if z < -1.0499999999999999e-14Initial program 100.0%
Taylor expanded in y around 0 85.8%
+-commutative85.8%
mul-1-neg85.8%
unsub-neg85.8%
*-commutative85.8%
Simplified85.8%
if -1.0499999999999999e-14 < z < 6.50000000000000022e26Initial program 100.0%
Taylor expanded in z around 0 93.3%
if 6.50000000000000022e26 < z Initial program 99.9%
Taylor expanded in x around -inf 91.2%
+-commutative91.2%
fma-def96.5%
mul-1-neg96.5%
distribute-rgt-neg-in96.5%
+-commutative96.5%
Simplified96.5%
Taylor expanded in z around inf 89.7%
+-commutative89.7%
mul-1-neg89.7%
sub-neg89.7%
*-commutative89.7%
Simplified89.7%
Final simplification90.4%
(FPCore (x y z t) :precision binary64 (if (<= z -3.3e-6) (* z x) (if (<= z -1.75e-94) x (if (<= z 1.85e+49) (* y t) (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e-6) {
tmp = z * x;
} else if (z <= -1.75e-94) {
tmp = x;
} else if (z <= 1.85e+49) {
tmp = y * t;
} else {
tmp = z * 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) :: tmp
if (z <= (-3.3d-6)) then
tmp = z * x
else if (z <= (-1.75d-94)) then
tmp = x
else if (z <= 1.85d+49) then
tmp = y * t
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e-6) {
tmp = z * x;
} else if (z <= -1.75e-94) {
tmp = x;
} else if (z <= 1.85e+49) {
tmp = y * t;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.3e-6: tmp = z * x elif z <= -1.75e-94: tmp = x elif z <= 1.85e+49: tmp = y * t else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.3e-6) tmp = Float64(z * x); elseif (z <= -1.75e-94) tmp = x; elseif (z <= 1.85e+49) tmp = Float64(y * t); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.3e-6) tmp = z * x; elseif (z <= -1.75e-94) tmp = x; elseif (z <= 1.85e+49) tmp = y * t; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.3e-6], N[(z * x), $MachinePrecision], If[LessEqual[z, -1.75e-94], x, If[LessEqual[z, 1.85e+49], N[(y * t), $MachinePrecision], N[(z * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-6}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -1.75 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{+49}:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -3.30000000000000017e-6 or 1.85000000000000009e49 < z Initial program 99.9%
Taylor expanded in x around -inf 95.0%
+-commutative95.0%
fma-def98.3%
mul-1-neg98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in z around inf 87.6%
+-commutative87.6%
mul-1-neg87.6%
sub-neg87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in x around inf 49.0%
if -3.30000000000000017e-6 < z < -1.74999999999999999e-94Initial program 100.0%
Taylor expanded in t around inf 71.1%
Taylor expanded in x around inf 49.6%
if -1.74999999999999999e-94 < z < 1.85000000000000009e49Initial program 100.0%
Taylor expanded in t around inf 77.6%
Taylor expanded in y around inf 46.6%
Final simplification47.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2e-6) (not (<= z 6.2e+27))) (* z (- x t)) (* y (- t x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e-6) || !(z <= 6.2e+27)) {
tmp = z * (x - t);
} else {
tmp = y * (t - 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) :: tmp
if ((z <= (-2d-6)) .or. (.not. (z <= 6.2d+27))) then
tmp = z * (x - t)
else
tmp = y * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2e-6) || !(z <= 6.2e+27)) {
tmp = z * (x - t);
} else {
tmp = y * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2e-6) or not (z <= 6.2e+27): tmp = z * (x - t) else: tmp = y * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2e-6) || !(z <= 6.2e+27)) tmp = Float64(z * Float64(x - t)); else tmp = Float64(y * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2e-6) || ~((z <= 6.2e+27))) tmp = z * (x - t); else tmp = y * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2e-6], N[Not[LessEqual[z, 6.2e+27]], $MachinePrecision]], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-6} \lor \neg \left(z \leq 6.2 \cdot 10^{+27}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\end{array}
\end{array}
if z < -1.99999999999999991e-6 or 6.19999999999999992e27 < z Initial program 99.9%
Taylor expanded in x around -inf 95.1%
+-commutative95.1%
fma-def98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in z around inf 87.3%
+-commutative87.3%
mul-1-neg87.3%
sub-neg87.3%
*-commutative87.3%
Simplified87.3%
if -1.99999999999999991e-6 < z < 6.19999999999999992e27Initial program 100.0%
Taylor expanded in x around -inf 96.9%
+-commutative96.9%
fma-def99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in y around inf 63.6%
mul-1-neg63.6%
sub-neg63.6%
*-commutative63.6%
Simplified63.6%
Final simplification75.0%
(FPCore (x y z t) :precision binary64 (if (<= x -1e+92) (* z x) (if (<= x 8.4e+158) (* (- y z) t) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1e+92) {
tmp = z * x;
} else if (x <= 8.4e+158) {
tmp = (y - z) * t;
} else {
tmp = z * 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) :: tmp
if (x <= (-1d+92)) then
tmp = z * x
else if (x <= 8.4d+158) then
tmp = (y - z) * t
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1e+92) {
tmp = z * x;
} else if (x <= 8.4e+158) {
tmp = (y - z) * t;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1e+92: tmp = z * x elif x <= 8.4e+158: tmp = (y - z) * t else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1e+92) tmp = Float64(z * x); elseif (x <= 8.4e+158) tmp = Float64(Float64(y - z) * t); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1e+92) tmp = z * x; elseif (x <= 8.4e+158) tmp = (y - z) * t; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1e+92], N[(z * x), $MachinePrecision], If[LessEqual[x, 8.4e+158], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+92}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{+158}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if x < -1e92 or 8.3999999999999996e158 < x Initial program 100.0%
Taylor expanded in x around -inf 90.5%
+-commutative90.5%
fma-def97.6%
mul-1-neg97.6%
distribute-rgt-neg-in97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in z around inf 54.8%
+-commutative54.8%
mul-1-neg54.8%
sub-neg54.8%
*-commutative54.8%
Simplified54.8%
Taylor expanded in x around inf 50.3%
if -1e92 < x < 8.3999999999999996e158Initial program 99.9%
Taylor expanded in x around -inf 98.8%
+-commutative98.8%
fma-def99.4%
mul-1-neg99.4%
distribute-rgt-neg-in99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in t around inf 64.9%
Final simplification60.1%
(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 (if (<= y -2.05e-189) (* y t) (if (<= y 2.02e-75) x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e-189) {
tmp = y * t;
} else if (y <= 2.02e-75) {
tmp = 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 (y <= (-2.05d-189)) then
tmp = y * t
else if (y <= 2.02d-75) then
tmp = 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 (y <= -2.05e-189) {
tmp = y * t;
} else if (y <= 2.02e-75) {
tmp = x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.05e-189: tmp = y * t elif y <= 2.02e-75: tmp = x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.05e-189) tmp = Float64(y * t); elseif (y <= 2.02e-75) tmp = x; else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.05e-189) tmp = y * t; elseif (y <= 2.02e-75) tmp = x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.05e-189], N[(y * t), $MachinePrecision], If[LessEqual[y, 2.02e-75], x, N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-189}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 2.02 \cdot 10^{-75}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -2.05000000000000015e-189 or 2.0200000000000001e-75 < y Initial program 100.0%
Taylor expanded in t around inf 58.5%
Taylor expanded in y around inf 39.1%
if -2.05000000000000015e-189 < y < 2.0200000000000001e-75Initial program 99.9%
Taylor expanded in t around inf 76.0%
Taylor expanded in x around inf 42.1%
Final simplification40.0%
(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 63.9%
Taylor expanded in x around inf 17.2%
Final simplification17.2%
(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 2023257
(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))))