
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* x y) (* z t))))
(if (or (<= t_1 -2e+282) (not (<= t_1 2e+253)))
(fma (/ (- z) a) t (* (/ y a) x))
(/ t_1 a))))assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -2e+282) || !(t_1 <= 2e+253)) {
tmp = fma((-z / a), t, ((y / a) * x));
} else {
tmp = t_1 / a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if ((t_1 <= -2e+282) || !(t_1 <= 2e+253)) tmp = fma(Float64(Float64(-z) / a), t, Float64(Float64(y / a) * x)); else tmp = Float64(t_1 / a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+282], N[Not[LessEqual[t$95$1, 2e+253]], $MachinePrecision]], N[(N[((-z) / a), $MachinePrecision] * t + N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+282} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+253}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{a}, t, \frac{y}{a} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -2.00000000000000007e282 or 1.9999999999999999e253 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 74.9%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f6475.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.7
Applied rewrites75.7%
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
if -2.00000000000000007e282 < (-.f64 (*.f64 x y) (*.f64 z t)) < 1.9999999999999999e253Initial program 98.9%
Final simplification96.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- (* x y) (* z t)) a)))
(if (<= t_1 (- INFINITY))
(* (/ x a) y)
(if (<= t_1 5e+274) (/ (* x y) a) (* (/ y a) x)))))assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - (z * t)) / a;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (x / a) * y;
} else if (t_1 <= 5e+274) {
tmp = (x * y) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - (z * t)) / a;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (x / a) * y;
} else if (t_1 <= 5e+274) {
tmp = (x * y) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = ((x * y) - (z * t)) / a tmp = 0 if t_1 <= -math.inf: tmp = (x / a) * y elif t_1 <= 5e+274: tmp = (x * y) / a else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(x * y) - Float64(z * t)) / a) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(x / a) * y); elseif (t_1 <= 5e+274) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = ((x * y) - (z * t)) / a;
tmp = 0.0;
if (t_1 <= -Inf)
tmp = (x / a) * y;
elseif (t_1 <= 5e+274)
tmp = (x * y) / a;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 5e+274], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y - z \cdot t}{a}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+274}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < -inf.0Initial program 78.0%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6456.4
Applied rewrites56.4%
if -inf.0 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 4.9999999999999998e274Initial program 98.8%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6447.5
Applied rewrites47.5%
Applied rewrites47.4%
Applied rewrites55.2%
if 4.9999999999999998e274 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) Initial program 81.7%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6455.3
Applied rewrites55.3%
Applied rewrites50.5%
Final simplification54.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= (* x y) -1e+85)
(* (/ y a) x)
(if (<= (* x y) 1e-85)
(/ (* (- z) t) a)
(if (<= (* x y) 2e+269) (/ (* x y) a) (* (/ x a) y)))))assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = (-z * t) / a;
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-1d+85)) then
tmp = (y / a) * x
else if ((x * y) <= 1d-85) then
tmp = (-z * t) / a
else if ((x * y) <= 2d+269) then
tmp = (x * y) / a
else
tmp = (x / a) * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = (-z * t) / a;
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+85: tmp = (y / a) * x elif (x * y) <= 1e-85: tmp = (-z * t) / a elif (x * y) <= 2e+269: tmp = (x * y) / a else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+85) tmp = Float64(Float64(y / a) * x); elseif (Float64(x * y) <= 1e-85) tmp = Float64(Float64(Float64(-z) * t) / a); elseif (Float64(x * y) <= 2e+269) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e+85)
tmp = (y / a) * x;
elseif ((x * y) <= 1e-85)
tmp = (-z * t) / a;
elseif ((x * y) <= 2e+269)
tmp = (x * y) / a;
else
tmp = (x / a) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+85], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e-85], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+269], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+85}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{elif}\;x \cdot y \leq 10^{-85}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+269}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1e85Initial program 83.2%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites80.8%
if -1e85 < (*.f64 x y) < 9.9999999999999998e-86Initial program 95.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6478.3
Applied rewrites78.3%
if 9.9999999999999998e-86 < (*.f64 x y) < 2.0000000000000001e269Initial program 98.1%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6464.3
Applied rewrites64.3%
Applied rewrites67.0%
Applied rewrites77.0%
if 2.0000000000000001e269 < (*.f64 x y) Initial program 61.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification80.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= (* x y) -1e+85)
(* (/ y a) x)
(if (<= (* x y) 1e-85)
(* (- z) (/ t a))
(if (<= (* x y) 2e+269) (/ (* x y) a) (* (/ x a) y)))))assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = -z * (t / a);
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-1d+85)) then
tmp = (y / a) * x
else if ((x * y) <= 1d-85) then
tmp = -z * (t / a)
else if ((x * y) <= 2d+269) then
tmp = (x * y) / a
else
tmp = (x / a) * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = -z * (t / a);
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+85: tmp = (y / a) * x elif (x * y) <= 1e-85: tmp = -z * (t / a) elif (x * y) <= 2e+269: tmp = (x * y) / a else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+85) tmp = Float64(Float64(y / a) * x); elseif (Float64(x * y) <= 1e-85) tmp = Float64(Float64(-z) * Float64(t / a)); elseif (Float64(x * y) <= 2e+269) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e+85)
tmp = (y / a) * x;
elseif ((x * y) <= 1e-85)
tmp = -z * (t / a);
elseif ((x * y) <= 2e+269)
tmp = (x * y) / a;
else
tmp = (x / a) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+85], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e-85], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+269], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+85}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{elif}\;x \cdot y \leq 10^{-85}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+269}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1e85Initial program 83.2%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites80.8%
if -1e85 < (*.f64 x y) < 9.9999999999999998e-86Initial program 95.7%
Taylor expanded in x around 0
associate-*r/N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l/N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
if 9.9999999999999998e-86 < (*.f64 x y) < 2.0000000000000001e269Initial program 98.1%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6464.3
Applied rewrites64.3%
Applied rewrites67.0%
Applied rewrites77.0%
if 2.0000000000000001e269 < (*.f64 x y) Initial program 61.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification80.1%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= (* x y) -1e+85)
(* (/ y a) x)
(if (<= (* x y) 1e-85)
(* t (/ (- z) a))
(if (<= (* x y) 2e+269) (/ (* x y) a) (* (/ x a) y)))))assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = t * (-z / a);
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-1d+85)) then
tmp = (y / a) * x
else if ((x * y) <= 1d-85) then
tmp = t * (-z / a)
else if ((x * y) <= 2d+269) then
tmp = (x * y) / a
else
tmp = (x / a) * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+85) {
tmp = (y / a) * x;
} else if ((x * y) <= 1e-85) {
tmp = t * (-z / a);
} else if ((x * y) <= 2e+269) {
tmp = (x * y) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+85: tmp = (y / a) * x elif (x * y) <= 1e-85: tmp = t * (-z / a) elif (x * y) <= 2e+269: tmp = (x * y) / a else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+85) tmp = Float64(Float64(y / a) * x); elseif (Float64(x * y) <= 1e-85) tmp = Float64(t * Float64(Float64(-z) / a)); elseif (Float64(x * y) <= 2e+269) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e+85)
tmp = (y / a) * x;
elseif ((x * y) <= 1e-85)
tmp = t * (-z / a);
elseif ((x * y) <= 2e+269)
tmp = (x * y) / a;
else
tmp = (x / a) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+85], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e-85], N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+269], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+85}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{elif}\;x \cdot y \leq 10^{-85}:\\
\;\;\;\;t \cdot \frac{-z}{a}\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+269}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1e85Initial program 83.2%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites80.8%
if -1e85 < (*.f64 x y) < 9.9999999999999998e-86Initial program 95.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f6494.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6494.6
Applied rewrites94.6%
Taylor expanded in x around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
if 9.9999999999999998e-86 < (*.f64 x y) < 2.0000000000000001e269Initial program 98.1%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6464.3
Applied rewrites64.3%
Applied rewrites67.0%
Applied rewrites77.0%
if 2.0000000000000001e269 < (*.f64 x y) Initial program 61.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification80.1%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) (- INFINITY)) (* (/ y a) x) (if (<= (* x y) 2e+269) (/ (- (* x y) (* z t)) a) (* (/ x a) y))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -((double) INFINITY)) {
tmp = (y / a) * x;
} else if ((x * y) <= 2e+269) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -Double.POSITIVE_INFINITY) {
tmp = (y / a) * x;
} else if ((x * y) <= 2e+269) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -math.inf: tmp = (y / a) * x elif (x * y) <= 2e+269: tmp = ((x * y) - (z * t)) / a else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= Float64(-Inf)) tmp = Float64(Float64(y / a) * x); elseif (Float64(x * y) <= 2e+269) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -Inf)
tmp = (y / a) * x;
elseif ((x * y) <= 2e+269)
tmp = ((x * y) - (z * t)) / a;
else
tmp = (x / a) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+269], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+269}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 74.6%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6496.2
Applied rewrites96.2%
Applied rewrites96.2%
if -inf.0 < (*.f64 x y) < 2.0000000000000001e269Initial program 96.4%
if 2.0000000000000001e269 < (*.f64 x y) Initial program 61.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification96.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= a 5.4e-21) (/ (- (* x y) (* z t)) a) (fma (/ y a) x (* t (/ (- z) a)))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 5.4e-21) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = fma((y / a), x, (t * (-z / a)));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 5.4e-21) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = fma(Float64(y / a), x, Float64(t * Float64(Float64(-z) / a))); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 5.4e-21], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x + N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.4 \cdot 10^{-21}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, t \cdot \frac{-z}{a}\right)\\
\end{array}
\end{array}
if a < 5.4000000000000002e-21Initial program 94.5%
if 5.4000000000000002e-21 < a Initial program 82.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
Final simplification94.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* (/ x a) y))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x / a) * y
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (x / a) * y
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(x / a) * y) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (x / a) * y;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x}{a} \cdot y
\end{array}
Initial program 91.2%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6450.9
Applied rewrites50.9%
Final simplification50.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
(if (< z -2.468684968699548e+170)
t_1
(if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = ((y / a) * x) - ((t / a) * z)
if (z < (-2.468684968699548d+170)) then
tmp = t_1
else if (z < 6.309831121978371d-71) then
tmp = ((x * y) - (z * t)) / a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y / a) * x) - ((t / a) * z) tmp = 0 if z < -2.468684968699548e+170: tmp = t_1 elif z < 6.309831121978371e-71: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z)) tmp = 0.0 if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y / a) * x) - ((t / a) * z); tmp = 0.0; if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = ((x * y) - (z * t)) / a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024342
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))
(/ (- (* x y) (* z t)) a))