
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* (+ y -1.0) (* z x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (y + (-1.0d0)) * (z * x)
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = (y + -1.0) * (z * x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(y + -1.0) * Float64(z * x)); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = (y + -1.0) * (z * x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 91.3%
Taylor expanded in z around inf 90.2%
associate-*r*98.8%
sub-neg98.8%
distribute-lft-in88.1%
*-commutative88.1%
associate-*l*95.7%
metadata-eval95.7%
Applied egg-rr95.7%
associate-*r*88.1%
*-commutative88.1%
distribute-lft-in98.8%
*-commutative98.8%
*-commutative98.8%
Applied egg-rr98.8%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 99.0%
associate-*r*91.3%
*-commutative91.3%
Simplified91.3%
Taylor expanded in x around 0 99.0%
+-commutative99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x y z)
:precision binary64
(if (or (<= y -2.9e+122)
(not
(or (<= y -6.3e+75) (and (not (<= y -1.75e+20)) (<= y 8.4e+14)))))
(* x (* y z))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.9e+122) || !((y <= -6.3e+75) || (!(y <= -1.75e+20) && (y <= 8.4e+14)))) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - 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 ((y <= (-2.9d+122)) .or. (.not. (y <= (-6.3d+75)) .or. (.not. (y <= (-1.75d+20))) .and. (y <= 8.4d+14))) then
tmp = x * (y * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.9e+122) || !((y <= -6.3e+75) || (!(y <= -1.75e+20) && (y <= 8.4e+14)))) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.9e+122) or not ((y <= -6.3e+75) or (not (y <= -1.75e+20) and (y <= 8.4e+14))): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.9e+122) || !((y <= -6.3e+75) || (!(y <= -1.75e+20) && (y <= 8.4e+14)))) tmp = Float64(x * Float64(y * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.9e+122) || ~(((y <= -6.3e+75) || (~((y <= -1.75e+20)) && (y <= 8.4e+14))))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.9e+122], N[Not[Or[LessEqual[y, -6.3e+75], And[N[Not[LessEqual[y, -1.75e+20]], $MachinePrecision], LessEqual[y, 8.4e+14]]]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+122} \lor \neg \left(y \leq -6.3 \cdot 10^{+75} \lor \neg \left(y \leq -1.75 \cdot 10^{+20}\right) \land y \leq 8.4 \cdot 10^{+14}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.9000000000000001e122 or -6.30000000000000036e75 < y < -1.75e20 or 8.4e14 < y Initial program 89.4%
Taylor expanded in y around inf 71.9%
*-commutative71.9%
Simplified71.9%
if -2.9000000000000001e122 < y < -6.30000000000000036e75 or -1.75e20 < y < 8.4e14Initial program 100.0%
Taylor expanded in y around 0 97.4%
Final simplification86.7%
(FPCore (x y z)
:precision binary64
(if (<= y -3.5e+122)
(* x (* y z))
(if (or (<= y -1.65e+74) (and (not (<= y -1.06e+20)) (<= y 800000000000.0)))
(* x (- 1.0 z))
(* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+122) {
tmp = x * (y * z);
} else if ((y <= -1.65e+74) || (!(y <= -1.06e+20) && (y <= 800000000000.0))) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * 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 (y <= (-3.5d+122)) then
tmp = x * (y * z)
else if ((y <= (-1.65d+74)) .or. (.not. (y <= (-1.06d+20))) .and. (y <= 800000000000.0d0)) then
tmp = x * (1.0d0 - z)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+122) {
tmp = x * (y * z);
} else if ((y <= -1.65e+74) || (!(y <= -1.06e+20) && (y <= 800000000000.0))) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+122: tmp = x * (y * z) elif (y <= -1.65e+74) or (not (y <= -1.06e+20) and (y <= 800000000000.0)): tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+122) tmp = Float64(x * Float64(y * z)); elseif ((y <= -1.65e+74) || (!(y <= -1.06e+20) && (y <= 800000000000.0))) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.5e+122) tmp = x * (y * z); elseif ((y <= -1.65e+74) || (~((y <= -1.06e+20)) && (y <= 800000000000.0))) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+122], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1.65e+74], And[N[Not[LessEqual[y, -1.06e+20]], $MachinePrecision], LessEqual[y, 800000000000.0]]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+122}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq -1.65 \cdot 10^{+74} \lor \neg \left(y \leq -1.06 \cdot 10^{+20}\right) \land y \leq 800000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -3.50000000000000014e122Initial program 92.9%
Taylor expanded in y around inf 77.5%
*-commutative77.5%
Simplified77.5%
if -3.50000000000000014e122 < y < -1.6500000000000001e74 or -1.06e20 < y < 8e11Initial program 100.0%
Taylor expanded in y around 0 97.4%
if -1.6500000000000001e74 < y < -1.06e20 or 8e11 < y Initial program 87.3%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
associate-*l*79.9%
*-commutative79.9%
Simplified79.9%
Final simplification89.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
(if (<= z -1.25e+25)
t_0
(if (<= z -2.9e-85)
t_1
(if (<= z 7.2e-37) x (if (<= z 3.4e+20) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -1.25e+25) {
tmp = t_0;
} else if (z <= -2.9e-85) {
tmp = t_1;
} else if (z <= 7.2e-37) {
tmp = x;
} else if (z <= 3.4e+20) {
tmp = t_1;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = x * (y * z)
if (z <= (-1.25d+25)) then
tmp = t_0
else if (z <= (-2.9d-85)) then
tmp = t_1
else if (z <= 7.2d-37) then
tmp = x
else if (z <= 3.4d+20) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -1.25e+25) {
tmp = t_0;
} else if (z <= -2.9e-85) {
tmp = t_1;
} else if (z <= 7.2e-37) {
tmp = x;
} else if (z <= 3.4e+20) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (y * z) tmp = 0 if z <= -1.25e+25: tmp = t_0 elif z <= -2.9e-85: tmp = t_1 elif z <= 7.2e-37: tmp = x elif z <= 3.4e+20: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -1.25e+25) tmp = t_0; elseif (z <= -2.9e-85) tmp = t_1; elseif (z <= 7.2e-37) tmp = x; elseif (z <= 3.4e+20) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (y * z); tmp = 0.0; if (z <= -1.25e+25) tmp = t_0; elseif (z <= -2.9e-85) tmp = t_1; elseif (z <= 7.2e-37) tmp = x; elseif (z <= 3.4e+20) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.25e+25], t$95$0, If[LessEqual[z, -2.9e-85], t$95$1, If[LessEqual[z, 7.2e-37], x, If[LessEqual[z, 3.4e+20], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.25 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{-85}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.25000000000000006e25 or 3.4e20 < z Initial program 90.3%
Taylor expanded in z around inf 90.3%
Taylor expanded in y around 0 65.4%
mul-1-neg65.4%
distribute-rgt-neg-in65.4%
Simplified65.4%
if -1.25000000000000006e25 < z < -2.9000000000000002e-85 or 7.20000000000000014e-37 < z < 3.4e20Initial program 99.7%
Taylor expanded in y around inf 70.7%
*-commutative70.7%
Simplified70.7%
if -2.9000000000000002e-85 < z < 7.20000000000000014e-37Initial program 100.0%
Taylor expanded in z around 0 83.6%
Final simplification73.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* y x))) (t_1 (* x (- 1.0 z))))
(if (<= y -2.75e+122)
t_0
(if (<= y -5.6e+76)
t_1
(if (<= y -1.3e+20) (* y (* z x)) (if (<= y 3100000000.0) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y * x);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -2.75e+122) {
tmp = t_0;
} else if (y <= -5.6e+76) {
tmp = t_1;
} else if (y <= -1.3e+20) {
tmp = y * (z * x);
} else if (y <= 3100000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * (y * x)
t_1 = x * (1.0d0 - z)
if (y <= (-2.75d+122)) then
tmp = t_0
else if (y <= (-5.6d+76)) then
tmp = t_1
else if (y <= (-1.3d+20)) then
tmp = y * (z * x)
else if (y <= 3100000000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y * x);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -2.75e+122) {
tmp = t_0;
} else if (y <= -5.6e+76) {
tmp = t_1;
} else if (y <= -1.3e+20) {
tmp = y * (z * x);
} else if (y <= 3100000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y * x) t_1 = x * (1.0 - z) tmp = 0 if y <= -2.75e+122: tmp = t_0 elif y <= -5.6e+76: tmp = t_1 elif y <= -1.3e+20: tmp = y * (z * x) elif y <= 3100000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y * x)) t_1 = Float64(x * Float64(1.0 - z)) tmp = 0.0 if (y <= -2.75e+122) tmp = t_0; elseif (y <= -5.6e+76) tmp = t_1; elseif (y <= -1.3e+20) tmp = Float64(y * Float64(z * x)); elseif (y <= 3100000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y * x); t_1 = x * (1.0 - z); tmp = 0.0; if (y <= -2.75e+122) tmp = t_0; elseif (y <= -5.6e+76) tmp = t_1; elseif (y <= -1.3e+20) tmp = y * (z * x); elseif (y <= 3100000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.75e+122], t$95$0, If[LessEqual[y, -5.6e+76], t$95$1, If[LessEqual[y, -1.3e+20], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3100000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y \cdot x\right)\\
t_1 := x \cdot \left(1 - z\right)\\
\mathbf{if}\;y \leq -2.75 \cdot 10^{+122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{+76}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{+20}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 3100000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.7499999999999999e122 or 3.1e9 < y Initial program 89.0%
Taylor expanded in y around inf 71.1%
associate-*r*80.6%
*-commutative80.6%
Simplified80.6%
if -2.7499999999999999e122 < y < -5.5999999999999997e76 or -1.3e20 < y < 3.1e9Initial program 100.0%
Taylor expanded in y around 0 97.4%
if -5.5999999999999997e76 < y < -1.3e20Initial program 92.6%
Taylor expanded in y around inf 77.6%
*-commutative77.6%
associate-*l*84.9%
*-commutative84.9%
Simplified84.9%
Final simplification90.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ 1.0 (* y z)))))
(if (<= y -260000000000.0)
t_0
(if (<= y 0.0002)
(* x (- 1.0 z))
(if (<= y 3.6e+244) t_0 (* z (* y x)))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 + (y * z));
double tmp;
if (y <= -260000000000.0) {
tmp = t_0;
} else if (y <= 0.0002) {
tmp = x * (1.0 - z);
} else if (y <= 3.6e+244) {
tmp = t_0;
} else {
tmp = z * (y * 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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 + (y * z))
if (y <= (-260000000000.0d0)) then
tmp = t_0
else if (y <= 0.0002d0) then
tmp = x * (1.0d0 - z)
else if (y <= 3.6d+244) then
tmp = t_0
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + (y * z));
double tmp;
if (y <= -260000000000.0) {
tmp = t_0;
} else if (y <= 0.0002) {
tmp = x * (1.0 - z);
} else if (y <= 3.6e+244) {
tmp = t_0;
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 + (y * z)) tmp = 0 if y <= -260000000000.0: tmp = t_0 elif y <= 0.0002: tmp = x * (1.0 - z) elif y <= 3.6e+244: tmp = t_0 else: tmp = z * (y * x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(y * z))) tmp = 0.0 if (y <= -260000000000.0) tmp = t_0; elseif (y <= 0.0002) tmp = Float64(x * Float64(1.0 - z)); elseif (y <= 3.6e+244) tmp = t_0; else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 + (y * z)); tmp = 0.0; if (y <= -260000000000.0) tmp = t_0; elseif (y <= 0.0002) tmp = x * (1.0 - z); elseif (y <= 3.6e+244) tmp = t_0; else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -260000000000.0], t$95$0, If[LessEqual[y, 0.0002], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e+244], t$95$0, N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 + y \cdot z\right)\\
\mathbf{if}\;y \leq -260000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 0.0002:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+244}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -2.6e11 or 2.0000000000000001e-4 < y < 3.6e244Initial program 95.3%
Taylor expanded in z around 0 95.3%
Taylor expanded in y around inf 95.0%
associate-*r*90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in x around 0 95.0%
+-commutative95.0%
Simplified95.0%
if -2.6e11 < y < 2.0000000000000001e-4Initial program 100.0%
Taylor expanded in y around 0 99.4%
if 3.6e244 < y Initial program 56.3%
Taylor expanded in y around inf 54.3%
associate-*r*97.4%
*-commutative97.4%
Simplified97.4%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -2e+218) (* (+ y -1.0) (* z x)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -2e+218) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
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 (((1.0d0 - y) * z) <= (-2d+218)) then
tmp = (y + (-1.0d0)) * (z * x)
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -2e+218) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -2e+218: tmp = (y + -1.0) * (z * x) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -2e+218) tmp = Float64(Float64(y + -1.0) * Float64(z * x)); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -2e+218) tmp = (y + -1.0) * (z * x); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -2e+218], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -2 \cdot 10^{+218}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -2.00000000000000017e218Initial program 71.8%
Taylor expanded in z around inf 71.8%
associate-*r*99.8%
sub-neg99.8%
distribute-lft-in85.0%
*-commutative85.0%
associate-*l*96.0%
metadata-eval96.0%
Applied egg-rr96.0%
associate-*r*85.0%
*-commutative85.0%
distribute-lft-in99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
if -2.00000000000000017e218 < (*.f64 (-.f64 1 y) z) Initial program 98.3%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (* (+ y -1.0) x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x * (1.0 + (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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * ((y + (-1.0d0)) * x)
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * ((y + -1.0) * x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(Float64(y + -1.0) * x)); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = z * ((y + -1.0) * x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 91.3%
Taylor expanded in z around inf 90.2%
*-commutative90.2%
associate-*l*98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
Simplified98.7%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 99.0%
associate-*r*91.3%
*-commutative91.3%
Simplified91.3%
Taylor expanded in x around 0 99.0%
+-commutative99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * -x;
} 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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 91.3%
Taylor expanded in z around inf 90.2%
Taylor expanded in y around 0 60.7%
mul-1-neg60.7%
distribute-rgt-neg-in60.7%
Simplified60.7%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 73.2%
Final simplification66.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 95.5%
Taylor expanded in z around 0 37.4%
Final simplification37.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2024018
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))