
(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 5 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}
(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}
Initial program 98.0%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.2e-91) (not (<= z 7.4e+130))) (* z (* x (- y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e-91) || !(z <= 7.4e+130)) {
tmp = z * (x * -y);
} else {
tmp = x;
}
return tmp;
}
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 ((z <= (-6.2d-91)) .or. (.not. (z <= 7.4d+130))) then
tmp = z * (x * -y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e-91) || !(z <= 7.4e+130)) {
tmp = z * (x * -y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.2e-91) or not (z <= 7.4e+130): tmp = z * (x * -y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.2e-91) || !(z <= 7.4e+130)) tmp = Float64(z * Float64(x * Float64(-y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.2e-91) || ~((z <= 7.4e+130))) tmp = z * (x * -y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.2e-91], N[Not[LessEqual[z, 7.4e+130]], $MachinePrecision]], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-91} \lor \neg \left(z \leq 7.4 \cdot 10^{+130}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.19999999999999962e-91 or 7.4000000000000003e130 < z Initial program 96.1%
Taylor expanded in y around inf 68.9%
mul-1-neg68.9%
associate-*r*68.0%
Simplified68.0%
if -6.19999999999999962e-91 < z < 7.4000000000000003e130Initial program 99.8%
Taylor expanded in y around 0 68.8%
Final simplification68.4%
(FPCore (x y z) :precision binary64 (if (<= z -6.2e-91) (* z (* x (- y))) (if (<= z 1.95e+132) x (* x (* y (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.2e-91) {
tmp = z * (x * -y);
} else if (z <= 1.95e+132) {
tmp = x;
} else {
tmp = x * (y * -z);
}
return tmp;
}
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 (z <= (-6.2d-91)) then
tmp = z * (x * -y)
else if (z <= 1.95d+132) then
tmp = x
else
tmp = x * (y * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.2e-91) {
tmp = z * (x * -y);
} else if (z <= 1.95e+132) {
tmp = x;
} else {
tmp = x * (y * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.2e-91: tmp = z * (x * -y) elif z <= 1.95e+132: tmp = x else: tmp = x * (y * -z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.2e-91) tmp = Float64(z * Float64(x * Float64(-y))); elseif (z <= 1.95e+132) tmp = x; else tmp = Float64(x * Float64(y * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.2e-91) tmp = z * (x * -y); elseif (z <= 1.95e+132) tmp = x; else tmp = x * (y * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.2e-91], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.95e+132], x, N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-91}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+132}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if z < -6.19999999999999962e-91Initial program 96.3%
Taylor expanded in y around inf 63.0%
mul-1-neg63.0%
associate-*r*63.1%
Simplified63.1%
if -6.19999999999999962e-91 < z < 1.95000000000000001e132Initial program 99.8%
Taylor expanded in y around 0 68.8%
if 1.95000000000000001e132 < z Initial program 95.8%
Taylor expanded in y around inf 78.9%
mul-1-neg78.9%
distribute-rgt-neg-in78.9%
distribute-rgt-neg-out78.9%
Simplified78.9%
Final simplification68.8%
(FPCore (x y z) :precision binary64 (if (<= z -5.9e-91) (* y (* x (- z))) (if (<= z 1.08e+130) x (* x (* y (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e-91) {
tmp = y * (x * -z);
} else if (z <= 1.08e+130) {
tmp = x;
} else {
tmp = x * (y * -z);
}
return tmp;
}
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 (z <= (-5.9d-91)) then
tmp = y * (x * -z)
else if (z <= 1.08d+130) then
tmp = x
else
tmp = x * (y * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e-91) {
tmp = y * (x * -z);
} else if (z <= 1.08e+130) {
tmp = x;
} else {
tmp = x * (y * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.9e-91: tmp = y * (x * -z) elif z <= 1.08e+130: tmp = x else: tmp = x * (y * -z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.9e-91) tmp = Float64(y * Float64(x * Float64(-z))); elseif (z <= 1.08e+130) tmp = x; else tmp = Float64(x * Float64(y * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.9e-91) tmp = y * (x * -z); elseif (z <= 1.08e+130) tmp = x; else tmp = x * (y * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.9e-91], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.08e+130], x, N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{-91}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 1.08 \cdot 10^{+130}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if z < -5.90000000000000025e-91Initial program 96.3%
Taylor expanded in y around inf 63.0%
mul-1-neg63.0%
associate-*r*63.1%
distribute-rgt-neg-in63.1%
*-commutative63.1%
associate-*r*63.0%
Simplified63.0%
if -5.90000000000000025e-91 < z < 1.08e130Initial program 99.8%
Taylor expanded in y around 0 68.8%
if 1.08e130 < z Initial program 95.8%
Taylor expanded in y around inf 78.9%
mul-1-neg78.9%
distribute-rgt-neg-in78.9%
distribute-rgt-neg-out78.9%
Simplified78.9%
Final simplification68.8%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 98.0%
Taylor expanded in y around 0 50.2%
Final simplification50.2%
herbie shell --seed 2024043
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))