
(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 10 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 (* z (- x t))) (t_2 (- x (* z t))))
(if (<= z -1.05)
t_1
(if (<= z 5e-234)
t_2
(if (<= z 5.4e-94)
(* y t)
(if (<= z 1.12e-21) t_2 (if (<= z 0.00025) (* y t) t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double t_2 = x - (z * t);
double tmp;
if (z <= -1.05) {
tmp = t_1;
} else if (z <= 5e-234) {
tmp = t_2;
} else if (z <= 5.4e-94) {
tmp = y * t;
} else if (z <= 1.12e-21) {
tmp = t_2;
} else if (z <= 0.00025) {
tmp = y * t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = z * (x - t)
t_2 = x - (z * t)
if (z <= (-1.05d0)) then
tmp = t_1
else if (z <= 5d-234) then
tmp = t_2
else if (z <= 5.4d-94) then
tmp = y * t
else if (z <= 1.12d-21) then
tmp = t_2
else if (z <= 0.00025d0) then
tmp = y * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double t_2 = x - (z * t);
double tmp;
if (z <= -1.05) {
tmp = t_1;
} else if (z <= 5e-234) {
tmp = t_2;
} else if (z <= 5.4e-94) {
tmp = y * t;
} else if (z <= 1.12e-21) {
tmp = t_2;
} else if (z <= 0.00025) {
tmp = y * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) t_2 = x - (z * t) tmp = 0 if z <= -1.05: tmp = t_1 elif z <= 5e-234: tmp = t_2 elif z <= 5.4e-94: tmp = y * t elif z <= 1.12e-21: tmp = t_2 elif z <= 0.00025: tmp = y * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) t_2 = Float64(x - Float64(z * t)) tmp = 0.0 if (z <= -1.05) tmp = t_1; elseif (z <= 5e-234) tmp = t_2; elseif (z <= 5.4e-94) tmp = Float64(y * t); elseif (z <= 1.12e-21) tmp = t_2; elseif (z <= 0.00025) tmp = Float64(y * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); t_2 = x - (z * t); tmp = 0.0; if (z <= -1.05) tmp = t_1; elseif (z <= 5e-234) tmp = t_2; elseif (z <= 5.4e-94) tmp = y * t; elseif (z <= 1.12e-21) tmp = t_2; elseif (z <= 0.00025) tmp = y * t; 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[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05], t$95$1, If[LessEqual[z, 5e-234], t$95$2, If[LessEqual[z, 5.4e-94], N[(y * t), $MachinePrecision], If[LessEqual[z, 1.12e-21], t$95$2, If[LessEqual[z, 0.00025], N[(y * t), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
t_2 := x - z \cdot t\\
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-234}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-94}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-21}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 0.00025:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 2.5000000000000001e-4 < z Initial program 100.0%
Taylor expanded in y around 0 82.9%
+-commutative82.9%
mul-1-neg82.9%
unsub-neg82.9%
*-commutative82.9%
Simplified82.9%
sub-neg82.9%
distribute-lft-in78.7%
Applied egg-rr78.7%
Taylor expanded in z around inf 82.9%
*-commutative82.9%
mul-1-neg82.9%
sub-neg82.9%
associate-*r*82.9%
neg-mul-182.9%
sub-neg82.9%
+-commutative82.9%
distribute-lft-in78.7%
distribute-rgt-neg-in78.7%
distribute-lft-neg-in78.7%
remove-double-neg78.7%
cancel-sign-sub-inv78.7%
distribute-lft-out--82.9%
Simplified82.9%
if -1.05000000000000004 < z < 4.99999999999999979e-234 or 5.4000000000000002e-94 < z < 1.11999999999999998e-21Initial program 99.9%
Taylor expanded in y around 0 43.0%
+-commutative43.0%
mul-1-neg43.0%
unsub-neg43.0%
*-commutative43.0%
Simplified43.0%
Taylor expanded in t around inf 42.4%
*-commutative42.4%
Simplified42.4%
if 4.99999999999999979e-234 < z < 5.4000000000000002e-94 or 1.11999999999999998e-21 < z < 2.5000000000000001e-4Initial program 100.0%
Taylor expanded in t around inf 79.3%
Taylor expanded in y around inf 61.8%
Final simplification67.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -1.1e+15)
t_1
(if (<= z -3.3e-55)
(- x (* y x))
(if (<= z 1.16e+15) (+ x (* (- y z) t)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -1.1e+15) {
tmp = t_1;
} else if (z <= -3.3e-55) {
tmp = x - (y * x);
} else if (z <= 1.16e+15) {
tmp = x + ((y - z) * t);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = z * (x - t)
if (z <= (-1.1d+15)) then
tmp = t_1
else if (z <= (-3.3d-55)) then
tmp = x - (y * x)
else if (z <= 1.16d+15) then
tmp = x + ((y - z) * t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -1.1e+15) {
tmp = t_1;
} else if (z <= -3.3e-55) {
tmp = x - (y * x);
} else if (z <= 1.16e+15) {
tmp = x + ((y - z) * t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) tmp = 0 if z <= -1.1e+15: tmp = t_1 elif z <= -3.3e-55: tmp = x - (y * x) elif z <= 1.16e+15: tmp = x + ((y - z) * t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -1.1e+15) tmp = t_1; elseif (z <= -3.3e-55) tmp = Float64(x - Float64(y * x)); elseif (z <= 1.16e+15) tmp = Float64(x + Float64(Float64(y - z) * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); tmp = 0.0; if (z <= -1.1e+15) tmp = t_1; elseif (z <= -3.3e-55) tmp = x - (y * x); elseif (z <= 1.16e+15) tmp = x + ((y - z) * t); 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]}, If[LessEqual[z, -1.1e+15], t$95$1, If[LessEqual[z, -3.3e-55], N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.16e+15], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -3.3 \cdot 10^{-55}:\\
\;\;\;\;x - y \cdot x\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+15}:\\
\;\;\;\;x + \left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.1e15 or 1.16e15 < z Initial program 100.0%
Taylor expanded in y around 0 86.2%
+-commutative86.2%
mul-1-neg86.2%
unsub-neg86.2%
*-commutative86.2%
Simplified86.2%
sub-neg86.2%
distribute-lft-in81.7%
Applied egg-rr81.7%
Taylor expanded in z around inf 86.2%
*-commutative86.2%
mul-1-neg86.2%
sub-neg86.2%
associate-*r*86.2%
neg-mul-186.2%
sub-neg86.2%
+-commutative86.2%
distribute-lft-in81.7%
distribute-rgt-neg-in81.7%
distribute-lft-neg-in81.7%
remove-double-neg81.7%
cancel-sign-sub-inv81.7%
distribute-lft-out--86.2%
Simplified86.2%
if -1.1e15 < z < -3.2999999999999999e-55Initial program 99.9%
Taylor expanded in z around 0 96.8%
Taylor expanded in t around 0 76.7%
associate-*r*76.7%
*-commutative76.7%
mul-1-neg76.7%
Simplified76.7%
if -3.2999999999999999e-55 < z < 1.16e15Initial program 100.0%
Taylor expanded in t around inf 73.4%
Final simplification80.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -2e+16)
t_1
(if (<= z 6.8e-221) (- x (* y x)) (if (<= z 3e-92) (* y t) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -2e+16) {
tmp = t_1;
} else if (z <= 6.8e-221) {
tmp = x - (y * x);
} else if (z <= 3e-92) {
tmp = y * t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = z * (x - t)
if (z <= (-2d+16)) then
tmp = t_1
else if (z <= 6.8d-221) then
tmp = x - (y * x)
else if (z <= 3d-92) then
tmp = y * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -2e+16) {
tmp = t_1;
} else if (z <= 6.8e-221) {
tmp = x - (y * x);
} else if (z <= 3e-92) {
tmp = y * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) tmp = 0 if z <= -2e+16: tmp = t_1 elif z <= 6.8e-221: tmp = x - (y * x) elif z <= 3e-92: tmp = y * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -2e+16) tmp = t_1; elseif (z <= 6.8e-221) tmp = Float64(x - Float64(y * x)); elseif (z <= 3e-92) tmp = Float64(y * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); tmp = 0.0; if (z <= -2e+16) tmp = t_1; elseif (z <= 6.8e-221) tmp = x - (y * x); elseif (z <= 3e-92) tmp = y * t; 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]}, If[LessEqual[z, -2e+16], t$95$1, If[LessEqual[z, 6.8e-221], N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e-92], N[(y * t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -2 \cdot 10^{+16}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-221}:\\
\;\;\;\;x - y \cdot x\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-92}:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -2e16 or 3.00000000000000013e-92 < z Initial program 99.9%
Taylor expanded in y around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
*-commutative81.4%
Simplified81.4%
sub-neg81.4%
distribute-lft-in77.5%
Applied egg-rr77.5%
Taylor expanded in z around inf 79.2%
*-commutative79.2%
mul-1-neg79.2%
sub-neg79.2%
associate-*r*79.2%
neg-mul-179.2%
sub-neg79.2%
+-commutative79.2%
distribute-lft-in75.4%
distribute-rgt-neg-in75.4%
distribute-lft-neg-in75.4%
remove-double-neg75.4%
cancel-sign-sub-inv75.4%
distribute-lft-out--79.2%
Simplified79.2%
if -2e16 < z < 6.8000000000000003e-221Initial program 100.0%
Taylor expanded in z around 0 95.6%
Taylor expanded in t around 0 69.9%
associate-*r*69.9%
*-commutative69.9%
mul-1-neg69.9%
Simplified69.9%
if 6.8000000000000003e-221 < z < 3.00000000000000013e-92Initial program 100.0%
Taylor expanded in t around inf 82.0%
Taylor expanded in y around inf 63.3%
Final simplification74.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.6e+14) (not (<= z 6.6e+18))) (* z (- x t)) (+ x (* y (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.6e+14) || !(z <= 6.6e+18)) {
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 <= (-2.6d+14)) .or. (.not. (z <= 6.6d+18))) 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 <= -2.6e+14) || !(z <= 6.6e+18)) {
tmp = z * (x - t);
} else {
tmp = x + (y * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.6e+14) or not (z <= 6.6e+18): tmp = z * (x - t) else: tmp = x + (y * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.6e+14) || !(z <= 6.6e+18)) 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 <= -2.6e+14) || ~((z <= 6.6e+18))) tmp = z * (x - t); else tmp = x + (y * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.6e+14], N[Not[LessEqual[z, 6.6e+18]], $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 -2.6 \cdot 10^{+14} \lor \neg \left(z \leq 6.6 \cdot 10^{+18}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(t - x\right)\\
\end{array}
\end{array}
if z < -2.6e14 or 6.6e18 < z Initial program 100.0%
Taylor expanded in y around 0 86.2%
+-commutative86.2%
mul-1-neg86.2%
unsub-neg86.2%
*-commutative86.2%
Simplified86.2%
sub-neg86.2%
distribute-lft-in81.7%
Applied egg-rr81.7%
Taylor expanded in z around inf 86.2%
*-commutative86.2%
mul-1-neg86.2%
sub-neg86.2%
associate-*r*86.2%
neg-mul-186.2%
sub-neg86.2%
+-commutative86.2%
distribute-lft-in81.7%
distribute-rgt-neg-in81.7%
distribute-lft-neg-in81.7%
remove-double-neg81.7%
cancel-sign-sub-inv81.7%
distribute-lft-out--86.2%
Simplified86.2%
if -2.6e14 < z < 6.6e18Initial program 99.9%
Taylor expanded in z around 0 89.7%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.7e+14) (not (<= z 2.9e-92))) (* z (- x t)) (* y t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e+14) || !(z <= 2.9e-92)) {
tmp = z * (x - t);
} 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 ((z <= (-2.7d+14)) .or. (.not. (z <= 2.9d-92))) then
tmp = z * (x - t)
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 ((z <= -2.7e+14) || !(z <= 2.9e-92)) {
tmp = z * (x - t);
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.7e+14) or not (z <= 2.9e-92): tmp = z * (x - t) else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.7e+14) || !(z <= 2.9e-92)) tmp = Float64(z * Float64(x - t)); else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.7e+14) || ~((z <= 2.9e-92))) tmp = z * (x - t); else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.7e+14], N[Not[LessEqual[z, 2.9e-92]], $MachinePrecision]], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], N[(y * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+14} \lor \neg \left(z \leq 2.9 \cdot 10^{-92}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if z < -2.7e14 or 2.89999999999999985e-92 < z Initial program 99.9%
Taylor expanded in y around 0 81.4%
+-commutative81.4%
mul-1-neg81.4%
unsub-neg81.4%
*-commutative81.4%
Simplified81.4%
sub-neg81.4%
distribute-lft-in77.5%
Applied egg-rr77.5%
Taylor expanded in z around inf 79.2%
*-commutative79.2%
mul-1-neg79.2%
sub-neg79.2%
associate-*r*79.2%
neg-mul-179.2%
sub-neg79.2%
+-commutative79.2%
distribute-lft-in75.4%
distribute-rgt-neg-in75.4%
distribute-lft-neg-in75.4%
remove-double-neg75.4%
cancel-sign-sub-inv75.4%
distribute-lft-out--79.2%
Simplified79.2%
if -2.7e14 < z < 2.89999999999999985e-92Initial program 100.0%
Taylor expanded in t around inf 71.0%
Taylor expanded in y around inf 40.1%
Final simplification63.6%
(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 (or (<= z -5.5e+16) (not (<= z 2.4e-92))) (* z (- t)) (* y t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.5e+16) || !(z <= 2.4e-92)) {
tmp = z * -t;
} 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 ((z <= (-5.5d+16)) .or. (.not. (z <= 2.4d-92))) then
tmp = z * -t
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 ((z <= -5.5e+16) || !(z <= 2.4e-92)) {
tmp = z * -t;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.5e+16) or not (z <= 2.4e-92): tmp = z * -t else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.5e+16) || !(z <= 2.4e-92)) tmp = Float64(z * Float64(-t)); else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.5e+16) || ~((z <= 2.4e-92))) tmp = z * -t; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.5e+16], N[Not[LessEqual[z, 2.4e-92]], $MachinePrecision]], N[(z * (-t)), $MachinePrecision], N[(y * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+16} \lor \neg \left(z \leq 2.4 \cdot 10^{-92}\right):\\
\;\;\;\;z \cdot \left(-t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if z < -5.5e16 or 2.4000000000000001e-92 < z Initial program 99.9%
Taylor expanded in t around inf 55.4%
Taylor expanded in z around inf 43.2%
mul-1-neg43.2%
distribute-rgt-neg-out43.2%
Simplified43.2%
if -5.5e16 < z < 2.4000000000000001e-92Initial program 100.0%
Taylor expanded in t around inf 71.0%
Taylor expanded in y around inf 40.1%
Final simplification41.9%
(FPCore (x y z t) :precision binary64 (if (<= y -9e-17) (* y t) (if (<= y 4.8e-97) x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9e-17) {
tmp = y * t;
} else if (y <= 4.8e-97) {
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 <= (-9d-17)) then
tmp = y * t
else if (y <= 4.8d-97) 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 <= -9e-17) {
tmp = y * t;
} else if (y <= 4.8e-97) {
tmp = x;
} else {
tmp = y * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -9e-17: tmp = y * t elif y <= 4.8e-97: tmp = x else: tmp = y * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -9e-17) tmp = Float64(y * t); elseif (y <= 4.8e-97) tmp = x; else tmp = Float64(y * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -9e-17) tmp = y * t; elseif (y <= 4.8e-97) tmp = x; else tmp = y * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -9e-17], N[(y * t), $MachinePrecision], If[LessEqual[y, 4.8e-97], x, N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-17}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-97}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -8.99999999999999957e-17 or 4.8e-97 < y Initial program 100.0%
Taylor expanded in t around inf 52.6%
Taylor expanded in y around inf 34.7%
if -8.99999999999999957e-17 < y < 4.8e-97Initial program 99.9%
Taylor expanded in t around inf 75.8%
Taylor expanded in x around inf 29.9%
Final simplification32.8%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in t around inf 61.6%
Taylor expanded in x around inf 14.3%
Final simplification14.3%
(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 2023240
(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))))