
(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
(if (<= y -1.22e+93)
(* y t)
(if (<= y -5.2e+59)
(* y (- x))
(if (<= y -5.4e-10)
(* y t)
(if (<= y -3.5e-247)
(* z x)
(if (<= y 5e-54) (* z (- t)) (if (<= y 4.1e+20) (* z x) (* y t))))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.22e+93) {
tmp = y * t;
} else if (y <= -5.2e+59) {
tmp = y * -x;
} else if (y <= -5.4e-10) {
tmp = y * t;
} else if (y <= -3.5e-247) {
tmp = z * x;
} else if (y <= 5e-54) {
tmp = z * -t;
} else if (y <= 4.1e+20) {
tmp = z * 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 <= (-1.22d+93)) then
tmp = y * t
else if (y <= (-5.2d+59)) then
tmp = y * -x
else if (y <= (-5.4d-10)) then
tmp = y * t
else if (y <= (-3.5d-247)) then
tmp = z * x
else if (y <= 5d-54) then
tmp = z * -t
else if (y <= 4.1d+20) then
tmp = z * 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 <= -1.22e+93) {
tmp = y * t;
} else if (y <= -5.2e+59) {
tmp = y * -x;
} else if (y <= -5.4e-10) {
tmp = y * t;
} else if (y <= -3.5e-247) {
tmp = z * x;
} else if (y <= 5e-54) {
tmp = z * -t;
} else if (y <= 4.1e+20) {
tmp = z * x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.22e+93: tmp = y * t elif y <= -5.2e+59: tmp = y * -x elif y <= -5.4e-10: tmp = y * t elif y <= -3.5e-247: tmp = z * x elif y <= 5e-54: tmp = z * -t elif y <= 4.1e+20: tmp = z * x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.22e+93) tmp = Float64(y * t); elseif (y <= -5.2e+59) tmp = Float64(y * Float64(-x)); elseif (y <= -5.4e-10) tmp = Float64(y * t); elseif (y <= -3.5e-247) tmp = Float64(z * x); elseif (y <= 5e-54) tmp = Float64(z * Float64(-t)); elseif (y <= 4.1e+20) tmp = Float64(z * x); else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.22e+93) tmp = y * t; elseif (y <= -5.2e+59) tmp = y * -x; elseif (y <= -5.4e-10) tmp = y * t; elseif (y <= -3.5e-247) tmp = z * x; elseif (y <= 5e-54) tmp = z * -t; elseif (y <= 4.1e+20) tmp = z * x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.22e+93], N[(y * t), $MachinePrecision], If[LessEqual[y, -5.2e+59], N[(y * (-x)), $MachinePrecision], If[LessEqual[y, -5.4e-10], N[(y * t), $MachinePrecision], If[LessEqual[y, -3.5e-247], N[(z * x), $MachinePrecision], If[LessEqual[y, 5e-54], N[(z * (-t)), $MachinePrecision], If[LessEqual[y, 4.1e+20], N[(z * x), $MachinePrecision], N[(y * t), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22 \cdot 10^{+93}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{+59}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{-10}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-247}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-54}:\\
\;\;\;\;z \cdot \left(-t\right)\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+20}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -1.21999999999999995e93 or -5.19999999999999999e59 < y < -5.4e-10 or 4.1e20 < y Initial program 100.0%
Taylor expanded in x around 0 64.6%
Taylor expanded in y around inf 53.0%
if -1.21999999999999995e93 < y < -5.19999999999999999e59Initial program 100.0%
Taylor expanded in y around inf 67.0%
Taylor expanded in t around 0 67.4%
mul-1-neg67.4%
distribute-rgt-neg-out67.4%
Simplified67.4%
if -5.4e-10 < y < -3.4999999999999999e-247 or 5.00000000000000015e-54 < y < 4.1e20Initial program 100.0%
Taylor expanded in z around inf 71.1%
mul-1-neg71.1%
distribute-lft-neg-out71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in t around 0 49.6%
if -3.4999999999999999e-247 < y < 5.00000000000000015e-54Initial program 100.0%
Taylor expanded in x around 0 50.6%
Taylor expanded in y around 0 47.9%
associate-*r*47.9%
neg-mul-147.9%
Simplified47.9%
Final simplification51.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))) (t_2 (* x (+ z 1.0))))
(if (<= y -5.8e-10)
t_1
(if (<= y 2.35e-203)
t_2
(if (<= y 2.3e-58) (* (- y z) t) (if (<= y 3.2e+21) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = x * (z + 1.0);
double tmp;
if (y <= -5.8e-10) {
tmp = t_1;
} else if (y <= 2.35e-203) {
tmp = t_2;
} else if (y <= 2.3e-58) {
tmp = (y - z) * t;
} else if (y <= 3.2e+21) {
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 = y * (t - x)
t_2 = x * (z + 1.0d0)
if (y <= (-5.8d-10)) then
tmp = t_1
else if (y <= 2.35d-203) then
tmp = t_2
else if (y <= 2.3d-58) then
tmp = (y - z) * t
else if (y <= 3.2d+21) 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 = y * (t - x);
double t_2 = x * (z + 1.0);
double tmp;
if (y <= -5.8e-10) {
tmp = t_1;
} else if (y <= 2.35e-203) {
tmp = t_2;
} else if (y <= 2.3e-58) {
tmp = (y - z) * t;
} else if (y <= 3.2e+21) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (t - x) t_2 = x * (z + 1.0) tmp = 0 if y <= -5.8e-10: tmp = t_1 elif y <= 2.35e-203: tmp = t_2 elif y <= 2.3e-58: tmp = (y - z) * t elif y <= 3.2e+21: 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(x * Float64(z + 1.0)) tmp = 0.0 if (y <= -5.8e-10) tmp = t_1; elseif (y <= 2.35e-203) tmp = t_2; elseif (y <= 2.3e-58) tmp = Float64(Float64(y - z) * t); elseif (y <= 3.2e+21) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (t - x); t_2 = x * (z + 1.0); tmp = 0.0; if (y <= -5.8e-10) tmp = t_1; elseif (y <= 2.35e-203) tmp = t_2; elseif (y <= 2.3e-58) tmp = (y - z) * t; elseif (y <= 3.2e+21) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.8e-10], t$95$1, If[LessEqual[y, 2.35e-203], t$95$2, If[LessEqual[y, 2.3e-58], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[y, 3.2e+21], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := x \cdot \left(z + 1\right)\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{-10}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-203}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-58}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+21}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -5.79999999999999962e-10 or 3.2e21 < y Initial program 100.0%
Taylor expanded in y around inf 78.8%
if -5.79999999999999962e-10 < y < 2.35000000000000003e-203 or 2.2999999999999999e-58 < y < 3.2e21Initial program 100.0%
Taylor expanded in x around inf 66.7%
+-commutative66.7%
distribute-rgt1-in66.7%
mul-1-neg66.7%
cancel-sign-sub-inv66.7%
Simplified66.7%
Taylor expanded in x around 0 66.7%
Taylor expanded in y around 0 66.2%
if 2.35000000000000003e-203 < y < 2.2999999999999999e-58Initial program 100.0%
Taylor expanded in x around 0 60.7%
Final simplification71.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.02e+65) (not (<= t 2.2e-71))) (* (- y z) t) (* x (- (+ z 1.0) y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.02e+65) || !(t <= 2.2e-71)) {
tmp = (y - z) * t;
} else {
tmp = x * ((z + 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 ((t <= (-1.02d+65)) .or. (.not. (t <= 2.2d-71))) then
tmp = (y - z) * t
else
tmp = x * ((z + 1.0d0) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.02e+65) || !(t <= 2.2e-71)) {
tmp = (y - z) * t;
} else {
tmp = x * ((z + 1.0) - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.02e+65) or not (t <= 2.2e-71): tmp = (y - z) * t else: tmp = x * ((z + 1.0) - y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.02e+65) || !(t <= 2.2e-71)) tmp = Float64(Float64(y - z) * t); else tmp = Float64(x * Float64(Float64(z + 1.0) - y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.02e+65) || ~((t <= 2.2e-71))) tmp = (y - z) * t; else tmp = x * ((z + 1.0) - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.02e+65], N[Not[LessEqual[t, 2.2e-71]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(x * N[(N[(z + 1.0), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.02 \cdot 10^{+65} \lor \neg \left(t \leq 2.2 \cdot 10^{-71}\right):\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\
\end{array}
\end{array}
if t < -1.02000000000000005e65 or 2.19999999999999997e-71 < t Initial program 100.0%
Taylor expanded in x around 0 78.9%
if -1.02000000000000005e65 < t < 2.19999999999999997e-71Initial program 100.0%
Taylor expanded in x around inf 79.0%
+-commutative79.0%
distribute-rgt1-in79.0%
mul-1-neg79.0%
cancel-sign-sub-inv79.0%
Simplified79.0%
Taylor expanded in x around 0 79.0%
Final simplification79.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -5.8e+62) (not (<= t 2.4e-71))) (* (- y z) t) (+ x (* x (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5.8e+62) || !(t <= 2.4e-71)) {
tmp = (y - z) * t;
} 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 <= (-5.8d+62)) .or. (.not. (t <= 2.4d-71))) then
tmp = (y - z) * t
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 <= -5.8e+62) || !(t <= 2.4e-71)) {
tmp = (y - z) * t;
} else {
tmp = x + (x * (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -5.8e+62) or not (t <= 2.4e-71): tmp = (y - z) * t else: tmp = x + (x * (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -5.8e+62) || !(t <= 2.4e-71)) tmp = Float64(Float64(y - z) * t); 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 <= -5.8e+62) || ~((t <= 2.4e-71))) tmp = (y - z) * t; else tmp = x + (x * (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -5.8e+62], N[Not[LessEqual[t, 2.4e-71]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(x + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+62} \lor \neg \left(t \leq 2.4 \cdot 10^{-71}\right):\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z - y\right)\\
\end{array}
\end{array}
if t < -5.79999999999999968e62 or 2.4e-71 < t Initial program 100.0%
Taylor expanded in x around 0 78.9%
if -5.79999999999999968e62 < t < 2.4e-71Initial program 100.0%
Taylor expanded in x around inf 79.0%
+-commutative79.0%
distribute-rgt1-in79.0%
mul-1-neg79.0%
cancel-sign-sub-inv79.0%
Simplified79.0%
Final simplification79.0%
(FPCore (x y z t) :precision binary64 (if (<= t -4.1e+111) (* y t) (if (<= t 7.2e-206) (* z x) (if (<= t 5.2e-34) x (* y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.1e+111) {
tmp = y * t;
} else if (t <= 7.2e-206) {
tmp = z * x;
} else if (t <= 5.2e-34) {
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 (t <= (-4.1d+111)) then
tmp = y * t
else if (t <= 7.2d-206) then
tmp = z * x
else if (t <= 5.2d-34) 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 (t <= -4.1e+111) {
tmp = y * t;
} else if (t <= 7.2e-206) {
tmp = z * x;
} else if (t <= 5.2e-34) {
tmp = x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -4.1e+111: tmp = y * t elif t <= 7.2e-206: tmp = z * x elif t <= 5.2e-34: tmp = x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -4.1e+111) tmp = Float64(y * t); elseif (t <= 7.2e-206) tmp = Float64(z * x); elseif (t <= 5.2e-34) tmp = x; else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -4.1e+111) tmp = y * t; elseif (t <= 7.2e-206) tmp = z * x; elseif (t <= 5.2e-34) tmp = x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -4.1e+111], N[(y * t), $MachinePrecision], If[LessEqual[t, 7.2e-206], N[(z * x), $MachinePrecision], If[LessEqual[t, 5.2e-34], x, N[(y * t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{+111}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;t \leq 7.2 \cdot 10^{-206}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;t \leq 5.2 \cdot 10^{-34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if t < -4.09999999999999986e111 or 5.1999999999999999e-34 < t Initial program 100.0%
Taylor expanded in x around 0 80.9%
Taylor expanded in y around inf 47.9%
if -4.09999999999999986e111 < t < 7.19999999999999987e-206Initial program 100.0%
Taylor expanded in z around inf 58.2%
mul-1-neg58.2%
distribute-lft-neg-out58.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in t around 0 43.9%
if 7.19999999999999987e-206 < t < 5.1999999999999999e-34Initial program 100.0%
Taylor expanded in x around inf 66.4%
+-commutative66.4%
distribute-rgt1-in66.5%
mul-1-neg66.5%
cancel-sign-sub-inv66.5%
Simplified66.5%
Taylor expanded in z around 0 52.9%
Taylor expanded in y around 0 36.5%
Final simplification44.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.15e+15) (not (<= y 2.25e+22))) (* y (- t x)) (* z (- x t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.15e+15) || !(y <= 2.25e+22)) {
tmp = 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 ((y <= (-2.15d+15)) .or. (.not. (y <= 2.25d+22))) then
tmp = 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 ((y <= -2.15e+15) || !(y <= 2.25e+22)) {
tmp = y * (t - x);
} else {
tmp = z * (x - t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.15e+15) or not (y <= 2.25e+22): tmp = y * (t - x) else: tmp = z * (x - t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.15e+15) || !(y <= 2.25e+22)) tmp = 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 ((y <= -2.15e+15) || ~((y <= 2.25e+22))) tmp = y * (t - x); else tmp = z * (x - t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.15e+15], N[Not[LessEqual[y, 2.25e+22]], $MachinePrecision]], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+15} \lor \neg \left(y \leq 2.25 \cdot 10^{+22}\right):\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\end{array}
\end{array}
if y < -2.15e15 or 2.2499999999999999e22 < y Initial program 100.0%
Taylor expanded in y around inf 79.8%
if -2.15e15 < y < 2.2499999999999999e22Initial program 100.0%
Taylor expanded in z around inf 69.6%
mul-1-neg69.6%
distribute-lft-neg-out69.6%
*-commutative69.6%
Simplified69.6%
Final simplification74.3%
(FPCore (x y z t) :precision binary64 (if (<= x -1.04e+99) (* z x) (if (<= x 1.26e+73) (* (- y z) t) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.04e+99) {
tmp = z * x;
} else if (x <= 1.26e+73) {
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 <= (-1.04d+99)) then
tmp = z * x
else if (x <= 1.26d+73) 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 <= -1.04e+99) {
tmp = z * x;
} else if (x <= 1.26e+73) {
tmp = (y - z) * t;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.04e+99: tmp = z * x elif x <= 1.26e+73: tmp = (y - z) * t else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.04e+99) tmp = Float64(z * x); elseif (x <= 1.26e+73) 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 <= -1.04e+99) tmp = z * x; elseif (x <= 1.26e+73) tmp = (y - z) * t; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.04e+99], N[(z * x), $MachinePrecision], If[LessEqual[x, 1.26e+73], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{+99}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq 1.26 \cdot 10^{+73}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if x < -1.04e99 or 1.25999999999999993e73 < x Initial program 100.0%
Taylor expanded in z around inf 53.5%
mul-1-neg53.5%
distribute-lft-neg-out53.5%
*-commutative53.5%
Simplified53.5%
Taylor expanded in t around 0 48.0%
if -1.04e99 < x < 1.25999999999999993e73Initial program 100.0%
Taylor expanded in x around 0 69.8%
Final simplification62.3%
(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 (if (<= y -4.8e-58) (* y t) (if (<= y 300000.0) x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.8e-58) {
tmp = y * t;
} else if (y <= 300000.0) {
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 <= (-4.8d-58)) then
tmp = y * t
else if (y <= 300000.0d0) 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 <= -4.8e-58) {
tmp = y * t;
} else if (y <= 300000.0) {
tmp = x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.8e-58: tmp = y * t elif y <= 300000.0: tmp = x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.8e-58) tmp = Float64(y * t); elseif (y <= 300000.0) tmp = x; else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.8e-58) tmp = y * t; elseif (y <= 300000.0) tmp = x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.8e-58], N[(y * t), $MachinePrecision], If[LessEqual[y, 300000.0], x, N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 300000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -4.8000000000000001e-58 or 3e5 < y Initial program 100.0%
Taylor expanded in x around 0 60.4%
Taylor expanded in y around inf 46.9%
if -4.8000000000000001e-58 < y < 3e5Initial program 100.0%
Taylor expanded in x around inf 62.0%
+-commutative62.0%
distribute-rgt1-in62.0%
mul-1-neg62.0%
cancel-sign-sub-inv62.0%
Simplified62.0%
Taylor expanded in z around 0 29.0%
Taylor expanded in y around 0 29.0%
Final simplification38.4%
(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 52.6%
+-commutative52.6%
distribute-rgt1-in52.6%
mul-1-neg52.6%
cancel-sign-sub-inv52.6%
Simplified52.6%
Taylor expanded in z around 0 30.5%
Taylor expanded in y around 0 15.7%
Final simplification15.7%
(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 2023200
(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))))