
(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 12 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 (fma (+ y -1.0) (* x z) x))
double code(double x, double y, double z) {
return fma((y + -1.0), (x * z), x);
}
function code(x, y, z) return fma(Float64(y + -1.0), Float64(x * z), x) end
code[x_, y_, z_] := N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y + -1, x \cdot z, x\right)
\end{array}
Initial program 97.7%
distribute-rgt-out--97.7%
*-lft-identity97.7%
cancel-sign-sub-inv97.7%
+-commutative97.7%
distribute-lft-neg-in97.7%
associate-*l*98.2%
fma-def98.3%
neg-sub098.3%
associate--r-98.3%
metadata-eval98.3%
+-commutative98.3%
*-commutative98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -3.9e+158)
t_0
(if (<= z -3.6e-32)
t_1
(if (<= z 5.2e-87)
x
(if (or (<= z 1.3e+44) (and (not (<= z 2.7e+72)) (<= z 4.8e+119)))
t_1
t_0))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -3.9e+158) {
tmp = t_0;
} else if (z <= -3.6e-32) {
tmp = t_1;
} else if (z <= 5.2e-87) {
tmp = x;
} else if ((z <= 1.3e+44) || (!(z <= 2.7e+72) && (z <= 4.8e+119))) {
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 = x * -z
t_1 = x * (y * z)
if (z <= (-3.9d+158)) then
tmp = t_0
else if (z <= (-3.6d-32)) then
tmp = t_1
else if (z <= 5.2d-87) then
tmp = x
else if ((z <= 1.3d+44) .or. (.not. (z <= 2.7d+72)) .and. (z <= 4.8d+119)) 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 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -3.9e+158) {
tmp = t_0;
} else if (z <= -3.6e-32) {
tmp = t_1;
} else if (z <= 5.2e-87) {
tmp = x;
} else if ((z <= 1.3e+44) || (!(z <= 2.7e+72) && (z <= 4.8e+119))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (y * z) tmp = 0 if z <= -3.9e+158: tmp = t_0 elif z <= -3.6e-32: tmp = t_1 elif z <= 5.2e-87: tmp = x elif (z <= 1.3e+44) or (not (z <= 2.7e+72) and (z <= 4.8e+119)): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -3.9e+158) tmp = t_0; elseif (z <= -3.6e-32) tmp = t_1; elseif (z <= 5.2e-87) tmp = x; elseif ((z <= 1.3e+44) || (!(z <= 2.7e+72) && (z <= 4.8e+119))) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = x * (y * z); tmp = 0.0; if (z <= -3.9e+158) tmp = t_0; elseif (z <= -3.6e-32) tmp = t_1; elseif (z <= 5.2e-87) tmp = x; elseif ((z <= 1.3e+44) || (~((z <= 2.7e+72)) && (z <= 4.8e+119))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.9e+158], t$95$0, If[LessEqual[z, -3.6e-32], t$95$1, If[LessEqual[z, 5.2e-87], x, If[Or[LessEqual[z, 1.3e+44], And[N[Not[LessEqual[z, 2.7e+72]], $MachinePrecision], LessEqual[z, 4.8e+119]]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -3.9 \cdot 10^{+158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-32}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-87}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+44} \lor \neg \left(z \leq 2.7 \cdot 10^{+72}\right) \land z \leq 4.8 \cdot 10^{+119}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3.9e158 or 1.3e44 < z < 2.7000000000000001e72 or 4.8e119 < z Initial program 95.1%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 68.8%
neg-mul-168.8%
Simplified68.8%
if -3.9e158 < z < -3.59999999999999993e-32 or 5.20000000000000005e-87 < z < 1.3e44 or 2.7000000000000001e72 < z < 4.8e119Initial program 96.7%
Taylor expanded in y around inf 62.1%
*-commutative62.1%
Simplified62.1%
if -3.59999999999999993e-32 < z < 5.20000000000000005e-87Initial program 99.9%
Taylor expanded in z around 0 81.1%
Final simplification72.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* y (* x z))))
(if (<= z -8.5e+161)
t_0
(if (<= z -3e-32)
t_1
(if (<= z 7e-87)
x
(if (<= z 2.75e+51)
t_1
(if (or (<= z 4.5e+71) (not (<= z 4e+119))) t_0 (* x (* y z)))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * (x * z);
double tmp;
if (z <= -8.5e+161) {
tmp = t_0;
} else if (z <= -3e-32) {
tmp = t_1;
} else if (z <= 7e-87) {
tmp = x;
} else if (z <= 2.75e+51) {
tmp = t_1;
} else if ((z <= 4.5e+71) || !(z <= 4e+119)) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * -z
t_1 = y * (x * z)
if (z <= (-8.5d+161)) then
tmp = t_0
else if (z <= (-3d-32)) then
tmp = t_1
else if (z <= 7d-87) then
tmp = x
else if (z <= 2.75d+51) then
tmp = t_1
else if ((z <= 4.5d+71) .or. (.not. (z <= 4d+119))) then
tmp = t_0
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * (x * z);
double tmp;
if (z <= -8.5e+161) {
tmp = t_0;
} else if (z <= -3e-32) {
tmp = t_1;
} else if (z <= 7e-87) {
tmp = x;
} else if (z <= 2.75e+51) {
tmp = t_1;
} else if ((z <= 4.5e+71) || !(z <= 4e+119)) {
tmp = t_0;
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = y * (x * z) tmp = 0 if z <= -8.5e+161: tmp = t_0 elif z <= -3e-32: tmp = t_1 elif z <= 7e-87: tmp = x elif z <= 2.75e+51: tmp = t_1 elif (z <= 4.5e+71) or not (z <= 4e+119): tmp = t_0 else: tmp = x * (y * z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(y * Float64(x * z)) tmp = 0.0 if (z <= -8.5e+161) tmp = t_0; elseif (z <= -3e-32) tmp = t_1; elseif (z <= 7e-87) tmp = x; elseif (z <= 2.75e+51) tmp = t_1; elseif ((z <= 4.5e+71) || !(z <= 4e+119)) tmp = t_0; else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = y * (x * z); tmp = 0.0; if (z <= -8.5e+161) tmp = t_0; elseif (z <= -3e-32) tmp = t_1; elseif (z <= 7e-87) tmp = x; elseif (z <= 2.75e+51) tmp = t_1; elseif ((z <= 4.5e+71) || ~((z <= 4e+119))) tmp = t_0; else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.5e+161], t$95$0, If[LessEqual[z, -3e-32], t$95$1, If[LessEqual[z, 7e-87], x, If[LessEqual[z, 2.75e+51], t$95$1, If[Or[LessEqual[z, 4.5e+71], N[Not[LessEqual[z, 4e+119]], $MachinePrecision]], t$95$0, N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-32}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-87}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+51}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+71} \lor \neg \left(z \leq 4 \cdot 10^{+119}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -8.50000000000000007e161 or 2.75e51 < z < 4.50000000000000043e71 or 3.99999999999999978e119 < z Initial program 95.1%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 68.8%
neg-mul-168.8%
Simplified68.8%
if -8.50000000000000007e161 < z < -3e-32 or 7.00000000000000023e-87 < z < 2.75e51Initial program 95.9%
Taylor expanded in y around inf 62.1%
if -3e-32 < z < 7.00000000000000023e-87Initial program 99.9%
Taylor expanded in z around 0 81.1%
if 4.50000000000000043e71 < z < 3.99999999999999978e119Initial program 100.0%
Taylor expanded in y around inf 78.3%
*-commutative78.3%
Simplified78.3%
Final simplification73.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= z -4.8e+160)
t_0
(if (<= z -1.38e-31)
(* z (* y x))
(if (<= z 6.8e-87)
x
(if (<= z 6.1e+47)
(* y (* x z))
(if (or (<= z 1.8e+73) (not (<= z 6.4e+119)))
t_0
(* x (* y z)))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -4.8e+160) {
tmp = t_0;
} else if (z <= -1.38e-31) {
tmp = z * (y * x);
} else if (z <= 6.8e-87) {
tmp = x;
} else if (z <= 6.1e+47) {
tmp = y * (x * z);
} else if ((z <= 1.8e+73) || !(z <= 6.4e+119)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * -z
if (z <= (-4.8d+160)) then
tmp = t_0
else if (z <= (-1.38d-31)) then
tmp = z * (y * x)
else if (z <= 6.8d-87) then
tmp = x
else if (z <= 6.1d+47) then
tmp = y * (x * z)
else if ((z <= 1.8d+73) .or. (.not. (z <= 6.4d+119))) then
tmp = t_0
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -4.8e+160) {
tmp = t_0;
} else if (z <= -1.38e-31) {
tmp = z * (y * x);
} else if (z <= 6.8e-87) {
tmp = x;
} else if (z <= 6.1e+47) {
tmp = y * (x * z);
} else if ((z <= 1.8e+73) || !(z <= 6.4e+119)) {
tmp = t_0;
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if z <= -4.8e+160: tmp = t_0 elif z <= -1.38e-31: tmp = z * (y * x) elif z <= 6.8e-87: tmp = x elif z <= 6.1e+47: tmp = y * (x * z) elif (z <= 1.8e+73) or not (z <= 6.4e+119): tmp = t_0 else: tmp = x * (y * z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -4.8e+160) tmp = t_0; elseif (z <= -1.38e-31) tmp = Float64(z * Float64(y * x)); elseif (z <= 6.8e-87) tmp = x; elseif (z <= 6.1e+47) tmp = Float64(y * Float64(x * z)); elseif ((z <= 1.8e+73) || !(z <= 6.4e+119)) tmp = t_0; else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (z <= -4.8e+160) tmp = t_0; elseif (z <= -1.38e-31) tmp = z * (y * x); elseif (z <= 6.8e-87) tmp = x; elseif (z <= 6.1e+47) tmp = y * (x * z); elseif ((z <= 1.8e+73) || ~((z <= 6.4e+119))) tmp = t_0; else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -4.8e+160], t$95$0, If[LessEqual[z, -1.38e-31], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.8e-87], x, If[LessEqual[z, 6.1e+47], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.8e+73], N[Not[LessEqual[z, 6.4e+119]], $MachinePrecision]], t$95$0, N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -4.8 \cdot 10^{+160}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.38 \cdot 10^{-31}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-87}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6.1 \cdot 10^{+47}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+73} \lor \neg \left(z \leq 6.4 \cdot 10^{+119}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -4.8000000000000003e160 or 6.10000000000000019e47 < z < 1.7999999999999999e73 or 6.39999999999999979e119 < z Initial program 95.1%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 68.8%
neg-mul-168.8%
Simplified68.8%
if -4.8000000000000003e160 < z < -1.38000000000000004e-31Initial program 93.6%
Taylor expanded in y around inf 59.5%
associate-*r*53.4%
*-commutative53.4%
associate-*l*59.6%
Simplified59.6%
if -1.38000000000000004e-31 < z < 6.7999999999999997e-87Initial program 99.9%
Taylor expanded in z around 0 81.1%
if 6.7999999999999997e-87 < z < 6.10000000000000019e47Initial program 99.5%
Taylor expanded in y around inf 66.0%
if 1.7999999999999999e73 < z < 6.39999999999999979e119Initial program 100.0%
Taylor expanded in y around inf 78.3%
*-commutative78.3%
Simplified78.3%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.55e-33) (not (<= z 8e-88))) (* x (* z (+ y -1.0))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.55e-33) || !(z <= 8e-88)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x - (x * 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 <= (-2.55d-33)) .or. (.not. (z <= 8d-88))) then
tmp = x * (z * (y + (-1.0d0)))
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.55e-33) || !(z <= 8e-88)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.55e-33) or not (z <= 8e-88): tmp = x * (z * (y + -1.0)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.55e-33) || !(z <= 8e-88)) tmp = Float64(x * Float64(z * Float64(y + -1.0))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.55e-33) || ~((z <= 8e-88))) tmp = x * (z * (y + -1.0)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.55e-33], N[Not[LessEqual[z, 8e-88]], $MachinePrecision]], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.55 \cdot 10^{-33} \lor \neg \left(z \leq 8 \cdot 10^{-88}\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if z < -2.55000000000000004e-33 or 7.99999999999999947e-88 < z Initial program 95.8%
Taylor expanded in z around inf 90.4%
if -2.55000000000000004e-33 < z < 7.99999999999999947e-88Initial program 99.9%
Taylor expanded in y around 0 81.1%
*-commutative81.1%
distribute-rgt-out--81.1%
*-lft-identity81.1%
Simplified81.1%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.05e-31) (not (<= z 7.8e-16))) (* z (- (* y x) x)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.05e-31) || !(z <= 7.8e-16)) {
tmp = z * ((y * x) - x);
} else {
tmp = x - (x * 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 <= (-3.05d-31)) .or. (.not. (z <= 7.8d-16))) then
tmp = z * ((y * x) - x)
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.05e-31) || !(z <= 7.8e-16)) {
tmp = z * ((y * x) - x);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.05e-31) or not (z <= 7.8e-16): tmp = z * ((y * x) - x) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.05e-31) || !(z <= 7.8e-16)) tmp = Float64(z * Float64(Float64(y * x) - x)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.05e-31) || ~((z <= 7.8e-16))) tmp = z * ((y * x) - x); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.05e-31], N[Not[LessEqual[z, 7.8e-16]], $MachinePrecision]], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.05 \cdot 10^{-31} \lor \neg \left(z \leq 7.8 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if z < -3.0499999999999999e-31 or 7.79999999999999954e-16 < z Initial program 95.5%
Taylor expanded in z around inf 97.8%
*-commutative97.8%
sub-neg97.8%
metadata-eval97.8%
distribute-rgt-in97.8%
neg-mul-197.8%
unsub-neg97.8%
Simplified97.8%
if -3.0499999999999999e-31 < z < 7.79999999999999954e-16Initial program 99.9%
Taylor expanded in y around 0 78.2%
*-commutative78.2%
distribute-rgt-out--78.2%
*-lft-identity78.2%
Simplified78.2%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.02) (not (<= z 2.9e-10))) (* z (- (* y x) x)) (+ x (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02) || !(z <= 2.9e-10)) {
tmp = z * ((y * x) - x);
} else {
tmp = x + (y * (x * 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.02d0)) .or. (.not. (z <= 2.9d-10))) then
tmp = z * ((y * x) - x)
else
tmp = x + (y * (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02) || !(z <= 2.9e-10)) {
tmp = z * ((y * x) - x);
} else {
tmp = x + (y * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.02) or not (z <= 2.9e-10): tmp = z * ((y * x) - x) else: tmp = x + (y * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.02) || !(z <= 2.9e-10)) tmp = Float64(z * Float64(Float64(y * x) - x)); else tmp = Float64(x + Float64(y * Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.02) || ~((z <= 2.9e-10))) tmp = z * ((y * x) - x); else tmp = x + (y * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.02], N[Not[LessEqual[z, 2.9e-10]], $MachinePrecision]], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \lor \neg \left(z \leq 2.9 \cdot 10^{-10}\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -1.02 or 2.89999999999999981e-10 < z Initial program 95.3%
Taylor expanded in z around inf 99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
if -1.02 < z < 2.89999999999999981e-10Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 96.0%
Final simplification97.8%
(FPCore (x y z) :precision binary64 (if (<= y -3.55e+186) (* z (* y x)) (if (<= y 1.55e+21) (- x (* x z)) (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.55e+186) {
tmp = z * (y * x);
} else if (y <= 1.55e+21) {
tmp = x - (x * z);
} else {
tmp = y * (x * 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 <= (-3.55d+186)) then
tmp = z * (y * x)
else if (y <= 1.55d+21) then
tmp = x - (x * z)
else
tmp = y * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.55e+186) {
tmp = z * (y * x);
} else if (y <= 1.55e+21) {
tmp = x - (x * z);
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.55e+186: tmp = z * (y * x) elif y <= 1.55e+21: tmp = x - (x * z) else: tmp = y * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.55e+186) tmp = Float64(z * Float64(y * x)); elseif (y <= 1.55e+21) tmp = Float64(x - Float64(x * z)); else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.55e+186) tmp = z * (y * x); elseif (y <= 1.55e+21) tmp = x - (x * z); else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.55e+186], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.55e+21], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.55 \cdot 10^{+186}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+21}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -3.54999999999999978e186Initial program 88.4%
Taylor expanded in y around inf 72.5%
associate-*r*72.7%
*-commutative72.7%
associate-*l*84.0%
Simplified84.0%
if -3.54999999999999978e186 < y < 1.55e21Initial program 98.9%
Taylor expanded in y around 0 87.2%
*-commutative87.2%
distribute-rgt-out--87.2%
*-lft-identity87.2%
Simplified87.2%
if 1.55e21 < y Initial program 96.6%
Taylor expanded in y around inf 83.1%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (* x (+ 1.0 (* z (+ y -1.0)))))
double code(double x, double y, double z) {
return x * (1.0 + (z * (y + -1.0)));
}
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 + (z * (y + (-1.0d0))))
end function
public static double code(double x, double y, double z) {
return x * (1.0 + (z * (y + -1.0)));
}
def code(x, y, z): return x * (1.0 + (z * (y + -1.0)))
function code(x, y, z) return Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))) end
function tmp = code(x, y, z) tmp = x * (1.0 + (z * (y + -1.0))); end
code[x_, y_, z_] := N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + z \cdot \left(y + -1\right)\right)
\end{array}
Initial program 97.7%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (+ x (* x (* z (+ y -1.0)))))
double code(double x, double y, double z) {
return x + (x * (z * (y + -1.0)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (x * (z * (y + (-1.0d0))))
end function
public static double code(double x, double y, double z) {
return x + (x * (z * (y + -1.0)));
}
def code(x, y, z): return x + (x * (z * (y + -1.0)))
function code(x, y, z) return Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))) end
function tmp = code(x, y, z) tmp = x + (x * (z * (y + -1.0))); end
code[x_, y_, z_] := N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + x \cdot \left(z \cdot \left(y + -1\right)\right)
\end{array}
Initial program 97.7%
sub-neg97.7%
distribute-rgt-in97.7%
*-un-lft-identity97.7%
distribute-rgt-neg-in97.7%
Applied egg-rr97.7%
Taylor expanded in y around 0 92.0%
+-commutative92.0%
associate-*r*92.0%
associate-*r*93.4%
distribute-rgt-out97.7%
distribute-rgt-in97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * -z;
} 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 = x * -z
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 = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(x * Float64(-z)); 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 = x * -z; 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[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 95.3%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 56.1%
neg-mul-156.1%
Simplified56.1%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 75.4%
Final simplification66.2%
(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 97.7%
Taylor expanded in z around 0 40.8%
Final simplification40.8%
(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 2023214
(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))))