
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- (* x y) (* y z)) t)))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+284)))
(* y (* t (- x z)))
(fma (* y (- x z)) t (* t (fma y (- z) (* y z)))))))assert(y < t);
double code(double x, double y, double z, double t) {
double t_1 = ((x * y) - (y * z)) * t;
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+284)) {
tmp = y * (t * (x - z));
} else {
tmp = fma((y * (x - z)), t, (t * fma(y, -z, (y * z))));
}
return tmp;
}
y, t = sort([y, t]) function code(x, y, z, t) t_1 = Float64(Float64(Float64(x * y) - Float64(y * z)) * t) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+284)) tmp = Float64(y * Float64(t * Float64(x - z))); else tmp = fma(Float64(y * Float64(x - z)), t, Float64(t * fma(y, Float64(-z), Float64(y * z)))); end return tmp end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+284]], $MachinePrecision]], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t + N[(t * N[(y * (-z) + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot y - y \cdot z\right) \cdot t\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+284}\right):\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(x - z\right), t, t \cdot \mathsf{fma}\left(y, -z, y \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < -inf.0 or 4.9999999999999999e284 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) Initial program 71.7%
distribute-rgt-out--75.3%
associate-*l*98.8%
Simplified98.8%
if -inf.0 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < 4.9999999999999999e284Initial program 99.1%
distribute-rgt-out--99.1%
associate-*l*88.3%
Simplified88.3%
associate-*r*99.1%
distribute-rgt-out--99.1%
*-commutative99.1%
prod-diff99.2%
*-commutative99.2%
fma-neg99.1%
distribute-rgt-in99.2%
fma-def99.3%
distribute-rgt-out--99.3%
*-commutative99.3%
fma-udef99.1%
distribute-lft-neg-in99.1%
distribute-rgt-neg-in99.1%
fma-def99.3%
*-commutative99.3%
Applied egg-rr99.3%
Final simplification99.2%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (- (* x y) (* y z)) 5e+162) (* t (* y (- x z))) (* y (* t (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((x * y) - (y * z)) <= 5e+162) {
tmp = t * (y * (x - z));
} else {
tmp = y * (t * (x - z));
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 * y) - (y * z)) <= 5d+162) then
tmp = t * (y * (x - z))
else
tmp = y * (t * (x - z))
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * y) - (y * z)) <= 5e+162) {
tmp = t * (y * (x - z));
} else {
tmp = y * (t * (x - z));
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if ((x * y) - (y * z)) <= 5e+162: tmp = t * (y * (x - z)) else: tmp = y * (t * (x - z)) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * y) - Float64(y * z)) <= 5e+162) tmp = Float64(t * Float64(y * Float64(x - z))); else tmp = Float64(y * Float64(t * Float64(x - z))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (((x * y) - (y * z)) <= 5e+162)
tmp = t * (y * (x - z));
else
tmp = y * (t * (x - z));
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], 5e+162], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - y \cdot z \leq 5 \cdot 10^{+162}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z y)) < 4.9999999999999997e162Initial program 96.3%
distribute-rgt-out--96.3%
Simplified96.3%
if 4.9999999999999997e162 < (-.f64 (*.f64 x y) (*.f64 z y)) Initial program 72.8%
distribute-rgt-out--77.3%
associate-*l*98.5%
Simplified98.5%
Final simplification96.9%
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (* t (- z)))))
(if (<= z -4.6e-33)
t_1
(if (<= z 2e-99)
(* x (* y t))
(if (or (<= z 1.8e-51) (not (<= z 8e+75))) t_1 (* (* x y) t))))))assert(y < t);
double code(double x, double y, double z, double t) {
double t_1 = y * (t * -z);
double tmp;
if (z <= -4.6e-33) {
tmp = t_1;
} else if (z <= 2e-99) {
tmp = x * (y * t);
} else if ((z <= 1.8e-51) || !(z <= 8e+75)) {
tmp = t_1;
} else {
tmp = (x * y) * t;
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 * (t * -z)
if (z <= (-4.6d-33)) then
tmp = t_1
else if (z <= 2d-99) then
tmp = x * (y * t)
else if ((z <= 1.8d-51) .or. (.not. (z <= 8d+75))) then
tmp = t_1
else
tmp = (x * y) * t
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double t_1 = y * (t * -z);
double tmp;
if (z <= -4.6e-33) {
tmp = t_1;
} else if (z <= 2e-99) {
tmp = x * (y * t);
} else if ((z <= 1.8e-51) || !(z <= 8e+75)) {
tmp = t_1;
} else {
tmp = (x * y) * t;
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): t_1 = y * (t * -z) tmp = 0 if z <= -4.6e-33: tmp = t_1 elif z <= 2e-99: tmp = x * (y * t) elif (z <= 1.8e-51) or not (z <= 8e+75): tmp = t_1 else: tmp = (x * y) * t return tmp
y, t = sort([y, t]) function code(x, y, z, t) t_1 = Float64(y * Float64(t * Float64(-z))) tmp = 0.0 if (z <= -4.6e-33) tmp = t_1; elseif (z <= 2e-99) tmp = Float64(x * Float64(y * t)); elseif ((z <= 1.8e-51) || !(z <= 8e+75)) tmp = t_1; else tmp = Float64(Float64(x * y) * t); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = y * (t * -z);
tmp = 0.0;
if (z <= -4.6e-33)
tmp = t_1;
elseif (z <= 2e-99)
tmp = x * (y * t);
elseif ((z <= 1.8e-51) || ~((z <= 8e+75)))
tmp = t_1;
else
tmp = (x * y) * t;
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e-33], t$95$1, If[LessEqual[z, 2e-99], N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.8e-51], N[Not[LessEqual[z, 8e+75]], $MachinePrecision]], t$95$1, N[(N[(x * y), $MachinePrecision] * t), $MachinePrecision]]]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
t_1 := y \cdot \left(t \cdot \left(-z\right)\right)\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{-33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-99}:\\
\;\;\;\;x \cdot \left(y \cdot t\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-51} \lor \neg \left(z \leq 8 \cdot 10^{+75}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot t\\
\end{array}
\end{array}
if z < -4.59999999999999971e-33 or 2e-99 < z < 1.8e-51 or 7.99999999999999941e75 < z Initial program 86.4%
distribute-rgt-out--88.6%
associate-*l*90.1%
Simplified90.1%
Taylor expanded in x around 0 76.5%
associate-*r*76.5%
neg-mul-176.5%
Simplified76.5%
if -4.59999999999999971e-33 < z < 2e-99Initial program 94.7%
distribute-rgt-out--94.7%
flip--73.4%
associate-*r/67.5%
Applied egg-rr67.5%
associate-/l*73.3%
difference-of-squares73.3%
associate-/r*94.6%
*-inverses94.6%
Simplified94.6%
associate-*l/92.5%
associate-/l*94.4%
clear-num94.4%
associate-/r/94.5%
/-rgt-identity94.5%
*-commutative94.5%
sub-neg94.5%
add-sqr-sqrt55.5%
sqrt-unprod88.7%
sqr-neg88.7%
sqrt-unprod34.6%
add-sqr-sqrt81.4%
Applied egg-rr81.4%
Taylor expanded in x around inf 81.8%
*-commutative81.8%
Simplified81.8%
associate-/r/81.7%
/-rgt-identity81.7%
*-commutative81.7%
associate-*r*81.9%
Applied egg-rr81.9%
if 1.8e-51 < z < 7.99999999999999941e75Initial program 94.0%
Taylor expanded in x around inf 73.3%
Final simplification78.0%
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (* y (- t)))))
(if (<= z -3.8e-33)
t_1
(if (<= z 2.5e-99)
(* x (* y t))
(if (<= z 8.5e-53)
t_1
(if (<= z 2.9e+75) (* (* x y) t) (* y (* t (- z)))))))))assert(y < t);
double code(double x, double y, double z, double t) {
double t_1 = z * (y * -t);
double tmp;
if (z <= -3.8e-33) {
tmp = t_1;
} else if (z <= 2.5e-99) {
tmp = x * (y * t);
} else if (z <= 8.5e-53) {
tmp = t_1;
} else if (z <= 2.9e+75) {
tmp = (x * y) * t;
} else {
tmp = y * (t * -z);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 * (y * -t)
if (z <= (-3.8d-33)) then
tmp = t_1
else if (z <= 2.5d-99) then
tmp = x * (y * t)
else if (z <= 8.5d-53) then
tmp = t_1
else if (z <= 2.9d+75) then
tmp = (x * y) * t
else
tmp = y * (t * -z)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double t_1 = z * (y * -t);
double tmp;
if (z <= -3.8e-33) {
tmp = t_1;
} else if (z <= 2.5e-99) {
tmp = x * (y * t);
} else if (z <= 8.5e-53) {
tmp = t_1;
} else if (z <= 2.9e+75) {
tmp = (x * y) * t;
} else {
tmp = y * (t * -z);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): t_1 = z * (y * -t) tmp = 0 if z <= -3.8e-33: tmp = t_1 elif z <= 2.5e-99: tmp = x * (y * t) elif z <= 8.5e-53: tmp = t_1 elif z <= 2.9e+75: tmp = (x * y) * t else: tmp = y * (t * -z) return tmp
y, t = sort([y, t]) function code(x, y, z, t) t_1 = Float64(z * Float64(y * Float64(-t))) tmp = 0.0 if (z <= -3.8e-33) tmp = t_1; elseif (z <= 2.5e-99) tmp = Float64(x * Float64(y * t)); elseif (z <= 8.5e-53) tmp = t_1; elseif (z <= 2.9e+75) tmp = Float64(Float64(x * y) * t); else tmp = Float64(y * Float64(t * Float64(-z))); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = z * (y * -t);
tmp = 0.0;
if (z <= -3.8e-33)
tmp = t_1;
elseif (z <= 2.5e-99)
tmp = x * (y * t);
elseif (z <= 8.5e-53)
tmp = t_1;
elseif (z <= 2.9e+75)
tmp = (x * y) * t;
else
tmp = y * (t * -z);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y * (-t)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.8e-33], t$95$1, If[LessEqual[z, 2.5e-99], N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.5e-53], t$95$1, If[LessEqual[z, 2.9e+75], N[(N[(x * y), $MachinePrecision] * t), $MachinePrecision], N[(y * N[(t * (-z)), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
t_1 := z \cdot \left(y \cdot \left(-t\right)\right)\\
\mathbf{if}\;z \leq -3.8 \cdot 10^{-33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-99}:\\
\;\;\;\;x \cdot \left(y \cdot t\right)\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-53}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+75}:\\
\;\;\;\;\left(x \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if z < -3.79999999999999994e-33 or 2.49999999999999985e-99 < z < 8.50000000000000044e-53Initial program 91.1%
Taylor expanded in x around 0 76.8%
neg-mul-176.8%
distribute-lft-neg-in76.8%
Simplified76.8%
associate-*l*75.6%
neg-mul-175.6%
*-commutative75.6%
metadata-eval75.6%
div-inv75.6%
associate-*l*76.8%
associate-/r/76.8%
associate-*l/79.2%
associate-/l*76.5%
Applied egg-rr76.5%
associate-/l*79.2%
associate-/r/79.2%
associate-/l*79.1%
Simplified79.1%
clear-num79.0%
associate-/r/79.2%
frac-2neg79.2%
metadata-eval79.2%
remove-double-div79.2%
Applied egg-rr79.2%
if -3.79999999999999994e-33 < z < 2.49999999999999985e-99Initial program 94.7%
distribute-rgt-out--94.7%
flip--73.4%
associate-*r/67.5%
Applied egg-rr67.5%
associate-/l*73.3%
difference-of-squares73.3%
associate-/r*94.6%
*-inverses94.6%
Simplified94.6%
associate-*l/92.5%
associate-/l*94.4%
clear-num94.4%
associate-/r/94.5%
/-rgt-identity94.5%
*-commutative94.5%
sub-neg94.5%
add-sqr-sqrt55.5%
sqrt-unprod88.7%
sqr-neg88.7%
sqrt-unprod34.6%
add-sqr-sqrt81.4%
Applied egg-rr81.4%
Taylor expanded in x around inf 81.8%
*-commutative81.8%
Simplified81.8%
associate-/r/81.7%
/-rgt-identity81.7%
*-commutative81.7%
associate-*r*81.9%
Applied egg-rr81.9%
if 8.50000000000000044e-53 < z < 2.8999999999999998e75Initial program 94.0%
Taylor expanded in x around inf 73.3%
if 2.8999999999999998e75 < z Initial program 80.2%
distribute-rgt-out--80.2%
associate-*l*90.1%
Simplified90.1%
Taylor expanded in x around 0 77.5%
associate-*r*77.5%
neg-mul-177.5%
Simplified77.5%
Final simplification79.1%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t 1.95e-66) (* y (* x t)) (* x (* y t))))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.95e-66) {
tmp = y * (x * t);
} else {
tmp = x * (y * t);
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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.95d-66) then
tmp = y * (x * t)
else
tmp = x * (y * t)
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.95e-66) {
tmp = y * (x * t);
} else {
tmp = x * (y * t);
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if t <= 1.95e-66: tmp = y * (x * t) else: tmp = x * (y * t) return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (t <= 1.95e-66) tmp = Float64(y * Float64(x * t)); else tmp = Float64(x * Float64(y * t)); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= 1.95e-66)
tmp = y * (x * t);
else
tmp = x * (y * t);
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, 1.95e-66], N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.95 \cdot 10^{-66}:\\
\;\;\;\;y \cdot \left(x \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot t\right)\\
\end{array}
\end{array}
if t < 1.94999999999999991e-66Initial program 88.3%
distribute-rgt-out--88.9%
associate-*l*91.6%
Simplified91.6%
Taylor expanded in x around inf 48.6%
if 1.94999999999999991e-66 < t Initial program 94.2%
distribute-rgt-out--96.6%
flip--66.5%
associate-*r/66.4%
Applied egg-rr66.4%
associate-/l*66.3%
difference-of-squares71.2%
associate-/r*96.5%
*-inverses96.5%
Simplified96.5%
associate-*l/96.4%
associate-/l*91.9%
clear-num91.9%
associate-/r/92.0%
/-rgt-identity92.0%
*-commutative92.0%
sub-neg92.0%
add-sqr-sqrt42.4%
sqrt-unprod57.3%
sqr-neg57.3%
sqrt-unprod24.5%
add-sqr-sqrt41.1%
Applied egg-rr41.1%
Taylor expanded in x around inf 44.9%
*-commutative44.9%
Simplified44.9%
associate-/r/44.9%
/-rgt-identity44.9%
*-commutative44.9%
associate-*r*52.7%
Applied egg-rr52.7%
Final simplification50.0%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -3e-36) (* x (* y t)) (* (* x y) t)))
assert(y < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3e-36) {
tmp = x * (y * t);
} else {
tmp = (x * y) * t;
}
return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 <= (-3d-36)) then
tmp = x * (y * t)
else
tmp = (x * y) * t
end if
code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3e-36) {
tmp = x * (y * t);
} else {
tmp = (x * y) * t;
}
return tmp;
}
[y, t] = sort([y, t]) def code(x, y, z, t): tmp = 0 if y <= -3e-36: tmp = x * (y * t) else: tmp = (x * y) * t return tmp
y, t = sort([y, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -3e-36) tmp = Float64(x * Float64(y * t)); else tmp = Float64(Float64(x * y) * t); end return tmp end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -3e-36)
tmp = x * (y * t);
else
tmp = (x * y) * t;
end
tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -3e-36], N[(x * N[(y * t), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-36}:\\
\;\;\;\;x \cdot \left(y \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot t\\
\end{array}
\end{array}
if y < -3.0000000000000002e-36Initial program 83.4%
distribute-rgt-out--86.3%
flip--72.2%
associate-*r/65.9%
Applied egg-rr65.9%
associate-/l*72.1%
difference-of-squares73.7%
associate-/r*86.2%
*-inverses86.2%
Simplified86.2%
associate-*l/98.4%
associate-/l*92.9%
clear-num92.8%
associate-/r/92.9%
/-rgt-identity92.9%
*-commutative92.9%
sub-neg92.9%
add-sqr-sqrt43.6%
sqrt-unprod55.6%
sqr-neg55.6%
sqrt-unprod19.1%
add-sqr-sqrt36.6%
Applied egg-rr36.6%
Taylor expanded in x around inf 39.7%
*-commutative39.7%
Simplified39.7%
associate-/r/39.7%
/-rgt-identity39.7%
*-commutative39.7%
associate-*r*48.0%
Applied egg-rr48.0%
if -3.0000000000000002e-36 < y Initial program 92.8%
Taylor expanded in x around inf 52.2%
Final simplification51.1%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* y (* t (- x z))))
assert(y < t);
double code(double x, double y, double z, double t) {
return y * (t * (x - z));
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 = y * (t * (x - z))
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
return y * (t * (x - z));
}
[y, t] = sort([y, t]) def code(x, y, z, t): return y * (t * (x - z))
y, t = sort([y, t]) function code(x, y, z, t) return Float64(y * Float64(t * Float64(x - z))) end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
tmp = y * (t * (x - z));
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(t \cdot \left(x - z\right)\right)
\end{array}
Initial program 90.2%
distribute-rgt-out--91.4%
associate-*l*91.7%
Simplified91.7%
Final simplification91.7%
NOTE: y and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* y (* x t)))
assert(y < t);
double code(double x, double y, double z, double t) {
return y * (x * t);
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 = y * (x * t)
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
return y * (x * t);
}
[y, t] = sort([y, t]) def code(x, y, z, t): return y * (x * t)
y, t = sort([y, t]) function code(x, y, z, t) return Float64(y * Float64(x * t)) end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
tmp = y * (x * t);
end
NOTE: y and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(x \cdot t\right)
\end{array}
Initial program 90.2%
distribute-rgt-out--91.4%
associate-*l*91.7%
Simplified91.7%
Taylor expanded in x around inf 47.4%
Final simplification47.4%
(FPCore (x y z t) :precision binary64 (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t < -9.231879582886777e-80) {
tmp = (y * t) * (x - z);
} else if (t < 2.543067051564877e+83) {
tmp = y * (t * (x - z));
} else {
tmp = (y * (x - 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 (t < (-9.231879582886777d-80)) then
tmp = (y * t) * (x - z)
else if (t < 2.543067051564877d+83) then
tmp = y * (t * (x - z))
else
tmp = (y * (x - z)) * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t < -9.231879582886777e-80) {
tmp = (y * t) * (x - z);
} else if (t < 2.543067051564877e+83) {
tmp = y * (t * (x - z));
} else {
tmp = (y * (x - z)) * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t < -9.231879582886777e-80: tmp = (y * t) * (x - z) elif t < 2.543067051564877e+83: tmp = y * (t * (x - z)) else: tmp = (y * (x - z)) * t return tmp
function code(x, y, z, t) tmp = 0.0 if (t < -9.231879582886777e-80) tmp = Float64(Float64(y * t) * Float64(x - z)); elseif (t < 2.543067051564877e+83) tmp = Float64(y * Float64(t * Float64(x - z))); else tmp = Float64(Float64(y * Float64(x - z)) * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t < -9.231879582886777e-80) tmp = (y * t) * (x - z); elseif (t < 2.543067051564877e+83) tmp = y * (t * (x - z)); else tmp = (y * (x - z)) * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Less[t, -9.231879582886777e-80], N[(N[(y * t), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], If[Less[t, 2.543067051564877e+83], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\
\;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\
\mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\
\end{array}
\end{array}
herbie shell --seed 2023240
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))
(* (- (* x y) (* z y)) t))