
(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 (* x (- 1.0 y))) (t_2 (+ x (* y t))))
(if (<= z -3.5)
(* x (+ z 1.0))
(if (<= z -2.15e-260)
t_2
(if (<= z 1.6e-109)
t_1
(if (<= z 7.4e-62)
t_2
(if (<= z 4.5e+44)
t_1
(if (<= z 4.1e+192) (- x (* z t)) (* z x)))))))))
double code(double x, double y, double z, double t) {
double t_1 = x * (1.0 - y);
double t_2 = x + (y * t);
double tmp;
if (z <= -3.5) {
tmp = x * (z + 1.0);
} else if (z <= -2.15e-260) {
tmp = t_2;
} else if (z <= 1.6e-109) {
tmp = t_1;
} else if (z <= 7.4e-62) {
tmp = t_2;
} else if (z <= 4.5e+44) {
tmp = t_1;
} else if (z <= 4.1e+192) {
tmp = x - (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x * (1.0d0 - y)
t_2 = x + (y * t)
if (z <= (-3.5d0)) then
tmp = x * (z + 1.0d0)
else if (z <= (-2.15d-260)) then
tmp = t_2
else if (z <= 1.6d-109) then
tmp = t_1
else if (z <= 7.4d-62) then
tmp = t_2
else if (z <= 4.5d+44) then
tmp = t_1
else if (z <= 4.1d+192) then
tmp = x - (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 t_1 = x * (1.0 - y);
double t_2 = x + (y * t);
double tmp;
if (z <= -3.5) {
tmp = x * (z + 1.0);
} else if (z <= -2.15e-260) {
tmp = t_2;
} else if (z <= 1.6e-109) {
tmp = t_1;
} else if (z <= 7.4e-62) {
tmp = t_2;
} else if (z <= 4.5e+44) {
tmp = t_1;
} else if (z <= 4.1e+192) {
tmp = x - (z * t);
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (1.0 - y) t_2 = x + (y * t) tmp = 0 if z <= -3.5: tmp = x * (z + 1.0) elif z <= -2.15e-260: tmp = t_2 elif z <= 1.6e-109: tmp = t_1 elif z <= 7.4e-62: tmp = t_2 elif z <= 4.5e+44: tmp = t_1 elif z <= 4.1e+192: tmp = x - (z * t) else: tmp = z * x return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(1.0 - y)) t_2 = Float64(x + Float64(y * t)) tmp = 0.0 if (z <= -3.5) tmp = Float64(x * Float64(z + 1.0)); elseif (z <= -2.15e-260) tmp = t_2; elseif (z <= 1.6e-109) tmp = t_1; elseif (z <= 7.4e-62) tmp = t_2; elseif (z <= 4.5e+44) tmp = t_1; elseif (z <= 4.1e+192) tmp = Float64(x - Float64(z * t)); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (1.0 - y); t_2 = x + (y * t); tmp = 0.0; if (z <= -3.5) tmp = x * (z + 1.0); elseif (z <= -2.15e-260) tmp = t_2; elseif (z <= 1.6e-109) tmp = t_1; elseif (z <= 7.4e-62) tmp = t_2; elseif (z <= 4.5e+44) tmp = t_1; elseif (z <= 4.1e+192) tmp = x - (z * t); else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2.15e-260], t$95$2, If[LessEqual[z, 1.6e-109], t$95$1, If[LessEqual[z, 7.4e-62], t$95$2, If[LessEqual[z, 4.5e+44], t$95$1, If[LessEqual[z, 4.1e+192], N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(1 - y\right)\\
t_2 := x + y \cdot t\\
\mathbf{if}\;z \leq -3.5:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{elif}\;z \leq -2.15 \cdot 10^{-260}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-109}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-62}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+44}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+192}:\\
\;\;\;\;x - z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -3.5Initial program 99.9%
Taylor expanded in x around inf 58.1%
mul-1-neg58.1%
unsub-neg58.1%
Simplified58.1%
Taylor expanded in y around 0 47.2%
+-commutative47.2%
Simplified47.2%
if -3.5 < z < -2.15000000000000011e-260 or 1.6000000000000001e-109 < z < 7.3999999999999996e-62Initial program 100.0%
Taylor expanded in y around inf 90.9%
*-commutative90.9%
Simplified90.9%
Taylor expanded in t around inf 75.5%
*-commutative75.5%
Simplified75.5%
if -2.15000000000000011e-260 < z < 1.6000000000000001e-109 or 7.3999999999999996e-62 < z < 4.5e44Initial program 100.0%
Taylor expanded in x around inf 75.5%
mul-1-neg75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in z around 0 68.1%
if 4.5e44 < z < 4.10000000000000003e192Initial program 99.9%
Taylor expanded in t around inf 64.0%
Taylor expanded in y around 0 52.0%
mul-1-neg52.0%
unsub-neg52.0%
*-commutative52.0%
Simplified52.0%
if 4.10000000000000003e192 < z Initial program 99.9%
Taylor expanded in x around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
Simplified73.9%
Taylor expanded in y around 0 68.9%
+-commutative68.9%
Simplified68.9%
distribute-rgt-in68.9%
*-un-lft-identity68.9%
Applied egg-rr68.9%
Taylor expanded in z around inf 68.9%
Final simplification62.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (- 1.0 y))) (t_2 (* x (+ z 1.0))) (t_3 (+ x (* y t))))
(if (<= z -29.0)
t_2
(if (<= z -3.8e-260)
t_3
(if (<= z 1.82e-110)
t_1
(if (<= z 6.5e-62) t_3 (if (<= z 13.0) t_1 t_2)))))))
double code(double x, double y, double z, double t) {
double t_1 = x * (1.0 - y);
double t_2 = x * (z + 1.0);
double t_3 = x + (y * t);
double tmp;
if (z <= -29.0) {
tmp = t_2;
} else if (z <= -3.8e-260) {
tmp = t_3;
} else if (z <= 1.82e-110) {
tmp = t_1;
} else if (z <= 6.5e-62) {
tmp = t_3;
} else if (z <= 13.0) {
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) :: t_3
real(8) :: tmp
t_1 = x * (1.0d0 - y)
t_2 = x * (z + 1.0d0)
t_3 = x + (y * t)
if (z <= (-29.0d0)) then
tmp = t_2
else if (z <= (-3.8d-260)) then
tmp = t_3
else if (z <= 1.82d-110) then
tmp = t_1
else if (z <= 6.5d-62) then
tmp = t_3
else if (z <= 13.0d0) 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 = x * (1.0 - y);
double t_2 = x * (z + 1.0);
double t_3 = x + (y * t);
double tmp;
if (z <= -29.0) {
tmp = t_2;
} else if (z <= -3.8e-260) {
tmp = t_3;
} else if (z <= 1.82e-110) {
tmp = t_1;
} else if (z <= 6.5e-62) {
tmp = t_3;
} else if (z <= 13.0) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (1.0 - y) t_2 = x * (z + 1.0) t_3 = x + (y * t) tmp = 0 if z <= -29.0: tmp = t_2 elif z <= -3.8e-260: tmp = t_3 elif z <= 1.82e-110: tmp = t_1 elif z <= 6.5e-62: tmp = t_3 elif z <= 13.0: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(1.0 - y)) t_2 = Float64(x * Float64(z + 1.0)) t_3 = Float64(x + Float64(y * t)) tmp = 0.0 if (z <= -29.0) tmp = t_2; elseif (z <= -3.8e-260) tmp = t_3; elseif (z <= 1.82e-110) tmp = t_1; elseif (z <= 6.5e-62) tmp = t_3; elseif (z <= 13.0) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (1.0 - y); t_2 = x * (z + 1.0); t_3 = x + (y * t); tmp = 0.0; if (z <= -29.0) tmp = t_2; elseif (z <= -3.8e-260) tmp = t_3; elseif (z <= 1.82e-110) tmp = t_1; elseif (z <= 6.5e-62) tmp = t_3; elseif (z <= 13.0) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -29.0], t$95$2, If[LessEqual[z, -3.8e-260], t$95$3, If[LessEqual[z, 1.82e-110], t$95$1, If[LessEqual[z, 6.5e-62], t$95$3, If[LessEqual[z, 13.0], t$95$1, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(1 - y\right)\\
t_2 := x \cdot \left(z + 1\right)\\
t_3 := x + y \cdot t\\
\mathbf{if}\;z \leq -29:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{-260}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 1.82 \cdot 10^{-110}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-62}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 13:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -29 or 13 < z Initial program 99.9%
Taylor expanded in x around inf 58.4%
mul-1-neg58.4%
unsub-neg58.4%
Simplified58.4%
Taylor expanded in y around 0 47.7%
+-commutative47.7%
Simplified47.7%
if -29 < z < -3.8000000000000003e-260 or 1.82000000000000013e-110 < z < 6.50000000000000026e-62Initial program 100.0%
Taylor expanded in y around inf 90.9%
*-commutative90.9%
Simplified90.9%
Taylor expanded in t around inf 75.5%
*-commutative75.5%
Simplified75.5%
if -3.8000000000000003e-260 < z < 1.82000000000000013e-110 or 6.50000000000000026e-62 < z < 13Initial program 100.0%
Taylor expanded in x around inf 74.9%
mul-1-neg74.9%
unsub-neg74.9%
Simplified74.9%
Taylor expanded in z around 0 74.2%
Final simplification60.8%
(FPCore (x y z t)
:precision binary64
(if (or (<= t -750.0)
(and (not (<= t 4.1e-79)) (or (<= t 9.2e+65) (not (<= t 1.8e+128)))))
(- x (* t (- z y)))
(* x (+ (- z y) 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -750.0) || (!(t <= 4.1e-79) && ((t <= 9.2e+65) || !(t <= 1.8e+128)))) {
tmp = x - (t * (z - y));
} else {
tmp = x * ((z - y) + 1.0);
}
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 <= (-750.0d0)) .or. (.not. (t <= 4.1d-79)) .and. (t <= 9.2d+65) .or. (.not. (t <= 1.8d+128))) then
tmp = x - (t * (z - y))
else
tmp = x * ((z - y) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -750.0) || (!(t <= 4.1e-79) && ((t <= 9.2e+65) || !(t <= 1.8e+128)))) {
tmp = x - (t * (z - y));
} else {
tmp = x * ((z - y) + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -750.0) or (not (t <= 4.1e-79) and ((t <= 9.2e+65) or not (t <= 1.8e+128))): tmp = x - (t * (z - y)) else: tmp = x * ((z - y) + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -750.0) || (!(t <= 4.1e-79) && ((t <= 9.2e+65) || !(t <= 1.8e+128)))) tmp = Float64(x - Float64(t * Float64(z - y))); else tmp = Float64(x * Float64(Float64(z - y) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -750.0) || (~((t <= 4.1e-79)) && ((t <= 9.2e+65) || ~((t <= 1.8e+128))))) tmp = x - (t * (z - y)); else tmp = x * ((z - y) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -750.0], And[N[Not[LessEqual[t, 4.1e-79]], $MachinePrecision], Or[LessEqual[t, 9.2e+65], N[Not[LessEqual[t, 1.8e+128]], $MachinePrecision]]]], N[(x - N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z - y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -750 \lor \neg \left(t \leq 4.1 \cdot 10^{-79}\right) \land \left(t \leq 9.2 \cdot 10^{+65} \lor \neg \left(t \leq 1.8 \cdot 10^{+128}\right)\right):\\
\;\;\;\;x - t \cdot \left(z - y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(z - y\right) + 1\right)\\
\end{array}
\end{array}
if t < -750 or 4.09999999999999994e-79 < t < 9.2e65 or 1.80000000000000014e128 < t Initial program 100.0%
Taylor expanded in t around inf 83.2%
if -750 < t < 4.09999999999999994e-79 or 9.2e65 < t < 1.80000000000000014e128Initial program 100.0%
Taylor expanded in x around inf 86.3%
mul-1-neg86.3%
unsub-neg86.3%
Simplified86.3%
Final simplification84.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- x))))
(if (<= y -1.0)
t_1
(if (<= y -8.5e-229) x (if (<= y 9.2e+54) (* z x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * -x;
double tmp;
if (y <= -1.0) {
tmp = t_1;
} else if (y <= -8.5e-229) {
tmp = x;
} else if (y <= 9.2e+54) {
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 = y * -x
if (y <= (-1.0d0)) then
tmp = t_1
else if (y <= (-8.5d-229)) then
tmp = x
else if (y <= 9.2d+54) 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 = y * -x;
double tmp;
if (y <= -1.0) {
tmp = t_1;
} else if (y <= -8.5e-229) {
tmp = x;
} else if (y <= 9.2e+54) {
tmp = z * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * -x tmp = 0 if y <= -1.0: tmp = t_1 elif y <= -8.5e-229: tmp = x elif y <= 9.2e+54: tmp = z * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(-x)) tmp = 0.0 if (y <= -1.0) tmp = t_1; elseif (y <= -8.5e-229) tmp = x; elseif (y <= 9.2e+54) tmp = Float64(z * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * -x; tmp = 0.0; if (y <= -1.0) tmp = t_1; elseif (y <= -8.5e-229) tmp = x; elseif (y <= 9.2e+54) tmp = z * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * (-x)), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$1, If[LessEqual[y, -8.5e-229], x, If[LessEqual[y, 9.2e+54], N[(z * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-229}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+54}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -1 or 9.19999999999999977e54 < y Initial program 100.0%
Taylor expanded in y around inf 82.4%
*-commutative82.4%
Simplified82.4%
Taylor expanded in t around 0 45.1%
associate-*r*45.1%
mul-1-neg45.1%
Simplified45.1%
Taylor expanded in y around inf 44.8%
mul-1-neg44.8%
*-commutative44.8%
distribute-rgt-neg-in44.8%
Simplified44.8%
if -1 < y < -8.49999999999999977e-229Initial program 100.0%
Taylor expanded in x around inf 73.3%
mul-1-neg73.3%
unsub-neg73.3%
Simplified73.3%
Taylor expanded in y around 0 72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in z around 0 49.1%
if -8.49999999999999977e-229 < y < 9.19999999999999977e54Initial program 99.9%
Taylor expanded in x around inf 61.2%
mul-1-neg61.2%
unsub-neg61.2%
Simplified61.2%
Taylor expanded in y around 0 60.5%
+-commutative60.5%
Simplified60.5%
distribute-rgt-in60.5%
*-un-lft-identity60.5%
Applied egg-rr60.5%
Taylor expanded in z around inf 36.5%
Final simplification42.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.15e-98) (not (<= x 3.5e-128))) (* x (+ (- z y) 1.0)) (+ x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e-98) || !(x <= 3.5e-128)) {
tmp = x * ((z - y) + 1.0);
} 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 ((x <= (-1.15d-98)) .or. (.not. (x <= 3.5d-128))) then
tmp = x * ((z - y) + 1.0d0)
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 ((x <= -1.15e-98) || !(x <= 3.5e-128)) {
tmp = x * ((z - y) + 1.0);
} else {
tmp = x + (y * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.15e-98) or not (x <= 3.5e-128): tmp = x * ((z - y) + 1.0) else: tmp = x + (y * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.15e-98) || !(x <= 3.5e-128)) tmp = Float64(x * Float64(Float64(z - y) + 1.0)); else tmp = Float64(x + Float64(y * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.15e-98) || ~((x <= 3.5e-128))) tmp = x * ((z - y) + 1.0); else tmp = x + (y * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.15e-98], N[Not[LessEqual[x, 3.5e-128]], $MachinePrecision]], N[(x * N[(N[(z - y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-98} \lor \neg \left(x \leq 3.5 \cdot 10^{-128}\right):\\
\;\;\;\;x \cdot \left(\left(z - y\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot t\\
\end{array}
\end{array}
if x < -1.15e-98 or 3.5e-128 < x Initial program 100.0%
Taylor expanded in x around inf 77.9%
mul-1-neg77.9%
unsub-neg77.9%
Simplified77.9%
if -1.15e-98 < x < 3.5e-128Initial program 100.0%
Taylor expanded in y around inf 63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in t around inf 57.2%
*-commutative57.2%
Simplified57.2%
Final simplification71.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.4e+28) (not (<= z 1.8e-43))) (+ x (* z (- x t))) (- x (* y (- x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.4e+28) || !(z <= 1.8e-43)) {
tmp = x + (z * (x - t));
} else {
tmp = x - (y * (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 <= (-2.4d+28)) .or. (.not. (z <= 1.8d-43))) then
tmp = x + (z * (x - t))
else
tmp = x - (y * (x - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.4e+28) || !(z <= 1.8e-43)) {
tmp = x + (z * (x - t));
} else {
tmp = x - (y * (x - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.4e+28) or not (z <= 1.8e-43): tmp = x + (z * (x - t)) else: tmp = x - (y * (x - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.4e+28) || !(z <= 1.8e-43)) tmp = Float64(x + Float64(z * Float64(x - t))); else tmp = Float64(x - Float64(y * Float64(x - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.4e+28) || ~((z <= 1.8e-43))) tmp = x + (z * (x - t)); else tmp = x - (y * (x - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.4e+28], N[Not[LessEqual[z, 1.8e-43]], $MachinePrecision]], N[(x + N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+28} \lor \neg \left(z \leq 1.8 \cdot 10^{-43}\right):\\
\;\;\;\;x + z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(x - t\right)\\
\end{array}
\end{array}
if z < -2.39999999999999981e28 or 1.7999999999999999e-43 < z Initial program 100.0%
Taylor expanded in y around 0 83.3%
mul-1-neg83.3%
unsub-neg83.3%
Simplified83.3%
if -2.39999999999999981e28 < z < 1.7999999999999999e-43Initial program 100.0%
Taylor expanded in y around inf 90.2%
*-commutative90.2%
Simplified90.2%
Final simplification86.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -42000000000000.0) (not (<= y 4.2e+55))) (* y (- x)) (* x (+ z 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -42000000000000.0) || !(y <= 4.2e+55)) {
tmp = y * -x;
} else {
tmp = x * (z + 1.0);
}
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 <= (-42000000000000.0d0)) .or. (.not. (y <= 4.2d+55))) then
tmp = y * -x
else
tmp = x * (z + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -42000000000000.0) || !(y <= 4.2e+55)) {
tmp = y * -x;
} else {
tmp = x * (z + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -42000000000000.0) or not (y <= 4.2e+55): tmp = y * -x else: tmp = x * (z + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -42000000000000.0) || !(y <= 4.2e+55)) tmp = Float64(y * Float64(-x)); else tmp = Float64(x * Float64(z + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -42000000000000.0) || ~((y <= 4.2e+55))) tmp = y * -x; else tmp = x * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -42000000000000.0], N[Not[LessEqual[y, 4.2e+55]], $MachinePrecision]], N[(y * (-x)), $MachinePrecision], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -42000000000000 \lor \neg \left(y \leq 4.2 \cdot 10^{+55}\right):\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < -4.2e13 or 4.2000000000000001e55 < y Initial program 100.0%
Taylor expanded in y around inf 83.4%
*-commutative83.4%
Simplified83.4%
Taylor expanded in t around 0 45.6%
associate-*r*45.6%
mul-1-neg45.6%
Simplified45.6%
Taylor expanded in y around inf 45.6%
mul-1-neg45.6%
*-commutative45.6%
distribute-rgt-neg-in45.6%
Simplified45.6%
if -4.2e13 < y < 4.2000000000000001e55Initial program 100.0%
Taylor expanded in x around inf 65.2%
mul-1-neg65.2%
unsub-neg65.2%
Simplified65.2%
Taylor expanded in y around 0 63.7%
+-commutative63.7%
Simplified63.7%
Final simplification55.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.1e-10) (not (<= z 920.0))) (* x (+ z 1.0)) (* x (- 1.0 y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.1e-10) || !(z <= 920.0)) {
tmp = x * (z + 1.0);
} else {
tmp = x * (1.0 - 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 <= (-4.1d-10)) .or. (.not. (z <= 920.0d0))) then
tmp = x * (z + 1.0d0)
else
tmp = x * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.1e-10) || !(z <= 920.0)) {
tmp = x * (z + 1.0);
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.1e-10) or not (z <= 920.0): tmp = x * (z + 1.0) else: tmp = x * (1.0 - y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.1e-10) || !(z <= 920.0)) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(x * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.1e-10) || ~((z <= 920.0))) tmp = x * (z + 1.0); else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.1e-10], N[Not[LessEqual[z, 920.0]], $MachinePrecision]], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{-10} \lor \neg \left(z \leq 920\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -4.0999999999999998e-10 or 920 < z Initial program 99.9%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
unsub-neg57.8%
Simplified57.8%
Taylor expanded in y around 0 47.4%
+-commutative47.4%
Simplified47.4%
if -4.0999999999999998e-10 < z < 920Initial program 100.0%
Taylor expanded in x around inf 63.1%
mul-1-neg63.1%
unsub-neg63.1%
Simplified63.1%
Taylor expanded in z around 0 62.7%
Final simplification54.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.5e-8) (not (<= z 0.00185))) (* z x) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.5e-8) || !(z <= 0.00185)) {
tmp = z * x;
} else {
tmp = 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 <= (-5.5d-8)) .or. (.not. (z <= 0.00185d0))) then
tmp = z * x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.5e-8) || !(z <= 0.00185)) {
tmp = z * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.5e-8) or not (z <= 0.00185): tmp = z * x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.5e-8) || !(z <= 0.00185)) tmp = Float64(z * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.5e-8) || ~((z <= 0.00185))) tmp = z * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.5e-8], N[Not[LessEqual[z, 0.00185]], $MachinePrecision]], N[(z * x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-8} \lor \neg \left(z \leq 0.00185\right):\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.5000000000000003e-8 or 0.0018500000000000001 < z Initial program 99.9%
Taylor expanded in x around inf 57.8%
mul-1-neg57.8%
unsub-neg57.8%
Simplified57.8%
Taylor expanded in y around 0 46.7%
+-commutative46.7%
Simplified46.7%
distribute-rgt-in46.6%
*-un-lft-identity46.6%
Applied egg-rr46.6%
Taylor expanded in z around inf 44.9%
if -5.5000000000000003e-8 < z < 0.0018500000000000001Initial program 100.0%
Taylor expanded in x around inf 63.1%
mul-1-neg63.1%
unsub-neg63.1%
Simplified63.1%
Taylor expanded in y around 0 36.2%
+-commutative36.2%
Simplified36.2%
Taylor expanded in z around 0 35.5%
Final simplification40.5%
(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%
Final simplification100.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 x around inf 60.3%
mul-1-neg60.3%
unsub-neg60.3%
Simplified60.3%
Taylor expanded in y around 0 41.7%
+-commutative41.7%
Simplified41.7%
Taylor expanded in z around 0 18.4%
Final simplification18.4%
(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 2024026
(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))))