
(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-define100.0%
Simplified100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- x))))
(if (<= z -6.6e+28)
(* z x)
(if (<= z -3.7e-152)
t_1
(if (<= z 3e-259)
x
(if (<= z 2.5e-181) t_1 (if (<= z 4.4e-9) x (* z x))))))))
double code(double x, double y, double z, double t) {
double t_1 = y * -x;
double tmp;
if (z <= -6.6e+28) {
tmp = z * x;
} else if (z <= -3.7e-152) {
tmp = t_1;
} else if (z <= 3e-259) {
tmp = x;
} else if (z <= 2.5e-181) {
tmp = t_1;
} else if (z <= 4.4e-9) {
tmp = x;
} 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) :: tmp
t_1 = y * -x
if (z <= (-6.6d+28)) then
tmp = z * x
else if (z <= (-3.7d-152)) then
tmp = t_1
else if (z <= 3d-259) then
tmp = x
else if (z <= 2.5d-181) then
tmp = t_1
else if (z <= 4.4d-9) then
tmp = x
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 = y * -x;
double tmp;
if (z <= -6.6e+28) {
tmp = z * x;
} else if (z <= -3.7e-152) {
tmp = t_1;
} else if (z <= 3e-259) {
tmp = x;
} else if (z <= 2.5e-181) {
tmp = t_1;
} else if (z <= 4.4e-9) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * -x tmp = 0 if z <= -6.6e+28: tmp = z * x elif z <= -3.7e-152: tmp = t_1 elif z <= 3e-259: tmp = x elif z <= 2.5e-181: tmp = t_1 elif z <= 4.4e-9: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(-x)) tmp = 0.0 if (z <= -6.6e+28) tmp = Float64(z * x); elseif (z <= -3.7e-152) tmp = t_1; elseif (z <= 3e-259) tmp = x; elseif (z <= 2.5e-181) tmp = t_1; elseif (z <= 4.4e-9) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * -x; tmp = 0.0; if (z <= -6.6e+28) tmp = z * x; elseif (z <= -3.7e-152) tmp = t_1; elseif (z <= 3e-259) tmp = x; elseif (z <= 2.5e-181) tmp = t_1; elseif (z <= 4.4e-9) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * (-x)), $MachinePrecision]}, If[LessEqual[z, -6.6e+28], N[(z * x), $MachinePrecision], If[LessEqual[z, -3.7e-152], t$95$1, If[LessEqual[z, 3e-259], x, If[LessEqual[z, 2.5e-181], t$95$1, If[LessEqual[z, 4.4e-9], x, N[(z * x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -6.6 \cdot 10^{+28}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-152}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-259}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-181}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -6.6e28 or 4.3999999999999997e-9 < z Initial program 100.0%
Taylor expanded in x around inf 60.2%
mul-1-neg60.2%
unsub-neg60.2%
Simplified60.2%
Taylor expanded in z around inf 48.5%
*-commutative48.5%
Simplified48.5%
if -6.6e28 < z < -3.6999999999999998e-152 or 3.0000000000000002e-259 < z < 2.5000000000000001e-181Initial program 99.9%
Taylor expanded in x around inf 60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
Taylor expanded in y around inf 44.3%
mul-1-neg44.3%
distribute-lft-neg-out44.3%
*-commutative44.3%
Simplified44.3%
if -3.6999999999999998e-152 < z < 3.0000000000000002e-259 or 2.5000000000000001e-181 < z < 4.3999999999999997e-9Initial program 100.0%
Taylor expanded in y around 0 49.7%
mul-1-neg49.7%
unsub-neg49.7%
Simplified49.7%
Taylor expanded in z around 0 44.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.8e+19) (not (<= z 4.4e-9))) (* z (- x t)) (+ x (* y (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.8e+19) || !(z <= 4.4e-9)) {
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 <= (-4.8d+19)) .or. (.not. (z <= 4.4d-9))) 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 <= -4.8e+19) || !(z <= 4.4e-9)) {
tmp = z * (x - t);
} else {
tmp = x + (y * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.8e+19) or not (z <= 4.4e-9): tmp = z * (x - t) else: tmp = x + (y * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.8e+19) || !(z <= 4.4e-9)) 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 <= -4.8e+19) || ~((z <= 4.4e-9))) tmp = z * (x - t); else tmp = x + (y * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.8e+19], N[Not[LessEqual[z, 4.4e-9]], $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 -4.8 \cdot 10^{+19} \lor \neg \left(z \leq 4.4 \cdot 10^{-9}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(t - x\right)\\
\end{array}
\end{array}
if z < -4.8e19 or 4.3999999999999997e-9 < z Initial program 100.0%
Taylor expanded in y around 0 85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in z around inf 85.0%
if -4.8e19 < z < 4.3999999999999997e-9Initial program 100.0%
Taylor expanded in y around inf 94.4%
*-commutative94.4%
Simplified94.4%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.1e+87) (not (<= x 2e+59))) (* x (+ (- z y) 1.0)) (+ x (* (- y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.1e+87) || !(x <= 2e+59)) {
tmp = x * ((z - y) + 1.0);
} else {
tmp = x + ((y - z) * 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 <= (-2.1d+87)) .or. (.not. (x <= 2d+59))) then
tmp = x * ((z - y) + 1.0d0)
else
tmp = x + ((y - z) * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.1e+87) || !(x <= 2e+59)) {
tmp = x * ((z - y) + 1.0);
} else {
tmp = x + ((y - z) * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.1e+87) or not (x <= 2e+59): tmp = x * ((z - y) + 1.0) else: tmp = x + ((y - z) * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.1e+87) || !(x <= 2e+59)) tmp = Float64(x * Float64(Float64(z - y) + 1.0)); else tmp = Float64(x + Float64(Float64(y - z) * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.1e+87) || ~((x <= 2e+59))) tmp = x * ((z - y) + 1.0); else tmp = x + ((y - z) * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.1e+87], N[Not[LessEqual[x, 2e+59]], $MachinePrecision]], N[(x * N[(N[(z - y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+87} \lor \neg \left(x \leq 2 \cdot 10^{+59}\right):\\
\;\;\;\;x \cdot \left(\left(z - y\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - z\right) \cdot t\\
\end{array}
\end{array}
if x < -2.1e87 or 1.99999999999999994e59 < x Initial program 100.0%
Taylor expanded in x around inf 91.4%
mul-1-neg91.4%
unsub-neg91.4%
Simplified91.4%
if -2.1e87 < x < 1.99999999999999994e59Initial program 99.9%
Taylor expanded in t around inf 83.7%
Final simplification87.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- x t)))) (if (<= z -4.6e+19) t_1 (if (<= z 1.8e-31) (+ x (* y (- t x))) (+ x t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -4.6e+19) {
tmp = t_1;
} else if (z <= 1.8e-31) {
tmp = x + (y * (t - x));
} else {
tmp = x + 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 * (x - t)
if (z <= (-4.6d+19)) then
tmp = t_1
else if (z <= 1.8d-31) then
tmp = x + (y * (t - x))
else
tmp = x + 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 tmp;
if (z <= -4.6e+19) {
tmp = t_1;
} else if (z <= 1.8e-31) {
tmp = x + (y * (t - x));
} else {
tmp = x + t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) tmp = 0 if z <= -4.6e+19: tmp = t_1 elif z <= 1.8e-31: tmp = x + (y * (t - x)) else: tmp = x + t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -4.6e+19) tmp = t_1; elseif (z <= 1.8e-31) tmp = Float64(x + Float64(y * Float64(t - x))); else tmp = Float64(x + t_1); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); tmp = 0.0; if (z <= -4.6e+19) tmp = t_1; elseif (z <= 1.8e-31) tmp = x + (y * (t - x)); else tmp = x + t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e+19], t$95$1, If[LessEqual[z, 1.8e-31], N[(x + N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-31}:\\
\;\;\;\;x + y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1\\
\end{array}
\end{array}
if z < -4.6e19Initial program 100.0%
Taylor expanded in y around 0 86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
Taylor expanded in z around inf 86.8%
if -4.6e19 < z < 1.80000000000000002e-31Initial program 100.0%
Taylor expanded in y around inf 95.6%
*-commutative95.6%
Simplified95.6%
if 1.80000000000000002e-31 < z Initial program 99.9%
Taylor expanded in y around 0 82.7%
mul-1-neg82.7%
unsub-neg82.7%
Simplified82.7%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.8e-25) (not (<= z 1.8e-31))) (* z (- x t)) (+ x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.8e-25) || !(z <= 1.8e-31)) {
tmp = z * (x - t);
} 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 <= (-1.8d-25)) .or. (.not. (z <= 1.8d-31))) then
tmp = z * (x - t)
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 <= -1.8e-25) || !(z <= 1.8e-31)) {
tmp = z * (x - t);
} else {
tmp = x + (y * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.8e-25) or not (z <= 1.8e-31): tmp = z * (x - t) else: tmp = x + (y * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.8e-25) || !(z <= 1.8e-31)) tmp = Float64(z * Float64(x - t)); else tmp = Float64(x + Float64(y * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.8e-25) || ~((z <= 1.8e-31))) tmp = z * (x - t); else tmp = x + (y * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.8e-25], N[Not[LessEqual[z, 1.8e-31]], $MachinePrecision]], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-25} \lor \neg \left(z \leq 1.8 \cdot 10^{-31}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot t\\
\end{array}
\end{array}
if z < -1.8e-25 or 1.80000000000000002e-31 < z Initial program 100.0%
Taylor expanded in y around 0 81.7%
mul-1-neg81.7%
unsub-neg81.7%
Simplified81.7%
Taylor expanded in z around inf 80.9%
if -1.8e-25 < z < 1.80000000000000002e-31Initial program 100.0%
Taylor expanded in t around inf 82.4%
Taylor expanded in y around inf 79.3%
Final simplification80.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.6e+19) (not (<= z 6.5e-12))) (* z (- x t)) (* x (- 1.0 y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.6e+19) || !(z <= 6.5e-12)) {
tmp = z * (x - t);
} 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 <= (-2.6d+19)) .or. (.not. (z <= 6.5d-12))) then
tmp = z * (x - t)
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 <= -2.6e+19) || !(z <= 6.5e-12)) {
tmp = z * (x - t);
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.6e+19) or not (z <= 6.5e-12): tmp = z * (x - t) else: tmp = x * (1.0 - y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.6e+19) || !(z <= 6.5e-12)) tmp = Float64(z * Float64(x - t)); 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 <= -2.6e+19) || ~((z <= 6.5e-12))) tmp = z * (x - t); else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.6e+19], N[Not[LessEqual[z, 6.5e-12]], $MachinePrecision]], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+19} \lor \neg \left(z \leq 6.5 \cdot 10^{-12}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -2.6e19 or 6.5000000000000002e-12 < z Initial program 100.0%
Taylor expanded in y around 0 85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in z around inf 85.0%
if -2.6e19 < z < 6.5000000000000002e-12Initial program 100.0%
Taylor expanded in x around inf 58.2%
mul-1-neg58.2%
unsub-neg58.2%
Simplified58.2%
Taylor expanded in z around 0 57.6%
Final simplification69.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.95) (not (<= y 9e+67))) (* x (- 1.0 y)) (* x (+ z 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95) || !(y <= 9e+67)) {
tmp = x * (1.0 - y);
} 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 <= (-1.95d0)) .or. (.not. (y <= 9d+67))) then
tmp = x * (1.0d0 - y)
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 <= -1.95) || !(y <= 9e+67)) {
tmp = x * (1.0 - y);
} else {
tmp = x * (z + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.95) or not (y <= 9e+67): tmp = x * (1.0 - y) else: tmp = x * (z + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.95) || !(y <= 9e+67)) tmp = Float64(x * Float64(1.0 - y)); 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 <= -1.95) || ~((y <= 9e+67))) tmp = x * (1.0 - y); else tmp = x * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.95], N[Not[LessEqual[y, 9e+67]], $MachinePrecision]], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \lor \neg \left(y \leq 9 \cdot 10^{+67}\right):\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < -1.94999999999999996 or 8.9999999999999997e67 < y Initial program 100.0%
Taylor expanded in x around inf 54.2%
mul-1-neg54.2%
unsub-neg54.2%
Simplified54.2%
Taylor expanded in z around 0 45.3%
if -1.94999999999999996 < y < 8.9999999999999997e67Initial program 99.9%
Taylor expanded in x around inf 61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
Taylor expanded in y around 0 61.0%
+-commutative61.0%
Simplified61.0%
Final simplification54.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.0) (not (<= y 1.22e+68))) (* y (- x)) (* x (+ z 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.0) || !(y <= 1.22e+68)) {
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 <= (-2.0d0)) .or. (.not. (y <= 1.22d+68))) 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 <= -2.0) || !(y <= 1.22e+68)) {
tmp = y * -x;
} else {
tmp = x * (z + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.0) or not (y <= 1.22e+68): tmp = y * -x else: tmp = x * (z + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.0) || !(y <= 1.22e+68)) 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 <= -2.0) || ~((y <= 1.22e+68))) tmp = y * -x; else tmp = x * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.0], N[Not[LessEqual[y, 1.22e+68]], $MachinePrecision]], N[(y * (-x)), $MachinePrecision], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \lor \neg \left(y \leq 1.22 \cdot 10^{+68}\right):\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < -2 or 1.22e68 < y Initial program 100.0%
Taylor expanded in x around inf 54.2%
mul-1-neg54.2%
unsub-neg54.2%
Simplified54.2%
Taylor expanded in y around inf 45.3%
mul-1-neg45.3%
distribute-lft-neg-out45.3%
*-commutative45.3%
Simplified45.3%
if -2 < y < 1.22e68Initial program 99.9%
Taylor expanded in x around inf 61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
Taylor expanded in y around 0 61.0%
+-commutative61.0%
Simplified61.0%
Final simplification54.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -820000000.0) (not (<= z 4.4e-9))) (* z x) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -820000000.0) || !(z <= 4.4e-9)) {
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 <= (-820000000.0d0)) .or. (.not. (z <= 4.4d-9))) 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 <= -820000000.0) || !(z <= 4.4e-9)) {
tmp = z * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -820000000.0) or not (z <= 4.4e-9): tmp = z * x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -820000000.0) || !(z <= 4.4e-9)) tmp = Float64(z * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -820000000.0) || ~((z <= 4.4e-9))) tmp = z * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -820000000.0], N[Not[LessEqual[z, 4.4e-9]], $MachinePrecision]], N[(z * x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -820000000 \lor \neg \left(z \leq 4.4 \cdot 10^{-9}\right):\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.2e8 or 4.3999999999999997e-9 < z Initial program 99.9%
Taylor expanded in x around inf 59.9%
mul-1-neg59.9%
unsub-neg59.9%
Simplified59.9%
Taylor expanded in z around inf 47.7%
*-commutative47.7%
Simplified47.7%
if -8.2e8 < z < 4.3999999999999997e-9Initial program 100.0%
Taylor expanded in y around 0 40.9%
mul-1-neg40.9%
unsub-neg40.9%
Simplified40.9%
Taylor expanded in z around 0 36.4%
Final simplification41.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%
(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 y around 0 60.6%
mul-1-neg60.6%
unsub-neg60.6%
Simplified60.6%
Taylor expanded in z around 0 21.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 2024091
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:alt
(+ x (+ (* t (- y z)) (* (- x) (- y z))))
(+ x (* (- y z) (- t x))))