
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -2e+218) (- (* y (* z x))) (if (<= (* y z) 2e+99) (fma (* y (- z)) x x) (/ z (/ -1.0 (* y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -2e+218) {
tmp = -(y * (z * x));
} else if ((y * z) <= 2e+99) {
tmp = fma((y * -z), x, x);
} else {
tmp = z / (-1.0 / (y * x));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -2e+218) tmp = Float64(-Float64(y * Float64(z * x))); elseif (Float64(y * z) <= 2e+99) tmp = fma(Float64(y * Float64(-z)), x, x); else tmp = Float64(z / Float64(-1.0 / Float64(y * x))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -2e+218], (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 2e+99], N[(N[(y * (-z)), $MachinePrecision] * x + x), $MachinePrecision], N[(z / N[(-1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+218}:\\
\;\;\;\;-y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(-z\right), x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{-1}{y \cdot x}}\\
\end{array}
\end{array}
if (*.f64 y z) < -2.00000000000000017e218Initial program 79.1%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
if -2.00000000000000017e218 < (*.f64 y z) < 1.9999999999999999e99Initial program 99.8%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
if 1.9999999999999999e99 < (*.f64 y z) Initial program 84.1%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6495.0
Applied rewrites95.0%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identity95.0
Applied rewrites95.0%
Applied rewrites95.0%
Final simplification99.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* y z)))))
(if (<= t_0 -2e+114)
(- (* z (* y x)))
(if (<= t_0 5e+306) (* x (fma (- z) y 1.0)) (- (* y (* z x)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= -2e+114) {
tmp = -(z * (y * x));
} else if (t_0 <= 5e+306) {
tmp = x * fma(-z, y, 1.0);
} else {
tmp = -(y * (z * x));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(y * z))) tmp = 0.0 if (t_0 <= -2e+114) tmp = Float64(-Float64(z * Float64(y * x))); elseif (t_0 <= 5e+306) tmp = Float64(x * fma(Float64(-z), y, 1.0)); else tmp = Float64(-Float64(y * Float64(z * x))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+114], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), If[LessEqual[t$95$0, 5e+306], N[(x * N[((-z) * y + 1.0), $MachinePrecision]), $MachinePrecision], (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision])]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+114}:\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(-z, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;-y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) < -2e114Initial program 90.0%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6489.5
Applied rewrites89.5%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identity67.0
Applied rewrites67.0%
if -2e114 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) < 4.99999999999999993e306Initial program 99.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
if 4.99999999999999993e306 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) Initial program 74.1%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Final simplification91.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* y z)))))
(if (<= t_0 -1e-31)
(- (* z (* y x)))
(if (<= t_0 5e+306) t_0 (- (* y (* z x)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= -1e-31) {
tmp = -(z * (y * x));
} else if (t_0 <= 5e+306) {
tmp = t_0;
} else {
tmp = -(y * (z * x));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - (y * z))
if (t_0 <= (-1d-31)) then
tmp = -(z * (y * x))
else if (t_0 <= 5d+306) then
tmp = t_0
else
tmp = -(y * (z * x))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= -1e-31) {
tmp = -(z * (y * x));
} else if (t_0 <= 5e+306) {
tmp = t_0;
} else {
tmp = -(y * (z * x));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = x * (1.0 - (y * z)) tmp = 0 if t_0 <= -1e-31: tmp = -(z * (y * x)) elif t_0 <= 5e+306: tmp = t_0 else: tmp = -(y * (z * x)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(y * z))) tmp = 0.0 if (t_0 <= -1e-31) tmp = Float64(-Float64(z * Float64(y * x))); elseif (t_0 <= 5e+306) tmp = t_0; else tmp = Float64(-Float64(y * Float64(z * x))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = x * (1.0 - (y * z));
tmp = 0.0;
if (t_0 <= -1e-31)
tmp = -(z * (y * x));
elseif (t_0 <= 5e+306)
tmp = t_0;
else
tmp = -(y * (z * x));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-31], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), If[LessEqual[t$95$0, 5e+306], t$95$0, (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision])]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-31}:\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) < -1e-31Initial program 92.8%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6492.4
Applied rewrites92.4%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identity56.2
Applied rewrites56.2%
if -1e-31 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) < 4.99999999999999993e306Initial program 99.7%
if 4.99999999999999993e306 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 y z))) Initial program 74.1%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Final simplification84.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -2e+218) (- (* y (* z x))) (if (<= (* y z) 2e+99) (fma (* y (- z)) x x) (- (* z (* y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -2e+218) {
tmp = -(y * (z * x));
} else if ((y * z) <= 2e+99) {
tmp = fma((y * -z), x, x);
} else {
tmp = -(z * (y * x));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -2e+218) tmp = Float64(-Float64(y * Float64(z * x))); elseif (Float64(y * z) <= 2e+99) tmp = fma(Float64(y * Float64(-z)), x, x); else tmp = Float64(-Float64(z * Float64(y * x))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -2e+218], (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 2e+99], N[(N[(y * (-z)), $MachinePrecision] * x + x), $MachinePrecision], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+218}:\\
\;\;\;\;-y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(-z\right), x, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2.00000000000000017e218Initial program 79.1%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
if -2.00000000000000017e218 < (*.f64 y z) < 1.9999999999999999e99Initial program 99.8%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
if 1.9999999999999999e99 < (*.f64 y z) Initial program 84.1%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6495.0
Applied rewrites95.0%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identity95.0
Applied rewrites95.0%
Final simplification99.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -20000000000.0) (- (* y (* z x))) (if (<= (* y z) 1.0) (* x 1.0) (- (* z (* y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -20000000000.0) {
tmp = -(y * (z * x));
} else if ((y * z) <= 1.0) {
tmp = x * 1.0;
} else {
tmp = -(z * (y * x));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y * z) <= (-20000000000.0d0)) then
tmp = -(y * (z * x))
else if ((y * z) <= 1.0d0) then
tmp = x * 1.0d0
else
tmp = -(z * (y * x))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -20000000000.0) {
tmp = -(y * (z * x));
} else if ((y * z) <= 1.0) {
tmp = x * 1.0;
} else {
tmp = -(z * (y * x));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -20000000000.0: tmp = -(y * (z * x)) elif (y * z) <= 1.0: tmp = x * 1.0 else: tmp = -(z * (y * x)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -20000000000.0) tmp = Float64(-Float64(y * Float64(z * x))); elseif (Float64(y * z) <= 1.0) tmp = Float64(x * 1.0); else tmp = Float64(-Float64(z * Float64(y * x))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((y * z) <= -20000000000.0)
tmp = -(y * (z * x));
elseif ((y * z) <= 1.0)
tmp = x * 1.0;
else
tmp = -(z * (y * x));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -20000000000.0], (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 1.0], N[(x * 1.0), $MachinePrecision], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -20000000000:\\
\;\;\;\;-y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \cdot z \leq 1:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2e10Initial program 87.9%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6493.5
Applied rewrites93.5%
if -2e10 < (*.f64 y z) < 1Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites96.4%
if 1 < (*.f64 y z) Initial program 87.2%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6488.7
Applied rewrites88.7%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identity88.8
Applied rewrites88.8%
Final simplification94.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (- (* y (* z x))))) (if (<= (* y z) -20000000000.0) t_0 (if (<= (* y z) 1.0) (* x 1.0) t_0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = -(y * (z * x));
double tmp;
if ((y * z) <= -20000000000.0) {
tmp = t_0;
} else if ((y * z) <= 1.0) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = -(y * (z * x))
if ((y * z) <= (-20000000000.0d0)) then
tmp = t_0
else if ((y * z) <= 1.0d0) then
tmp = x * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = -(y * (z * x));
double tmp;
if ((y * z) <= -20000000000.0) {
tmp = t_0;
} else if ((y * z) <= 1.0) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = -(y * (z * x)) tmp = 0 if (y * z) <= -20000000000.0: tmp = t_0 elif (y * z) <= 1.0: tmp = x * 1.0 else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(-Float64(y * Float64(z * x))) tmp = 0.0 if (Float64(y * z) <= -20000000000.0) tmp = t_0; elseif (Float64(y * z) <= 1.0) tmp = Float64(x * 1.0); else tmp = t_0; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = -(y * (z * x));
tmp = 0.0;
if ((y * z) <= -20000000000.0)
tmp = t_0;
elseif ((y * z) <= 1.0)
tmp = x * 1.0;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = (-N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[N[(y * z), $MachinePrecision], -20000000000.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 1.0], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := -y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;y \cdot z \leq -20000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 1:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -2e10 or 1 < (*.f64 y z) Initial program 87.6%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6493.1
Applied rewrites93.1%
if -2e10 < (*.f64 y z) < 1Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites96.4%
Final simplification94.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x 1.0))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * 1.0;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * 1.0d0
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * 1.0;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * 1.0
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * 1.0) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * 1.0;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot 1
\end{array}
Initial program 94.1%
Taylor expanded in y around 0
Applied rewrites52.1%
herbie shell --seed 2024233
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))