
(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 9 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 (<= z 2.5e+57) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.5e+57) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (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 (z <= 2.5d+57) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.5e+57) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.5e+57: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.5e+57) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.5e+57) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.5e+57], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.5 \cdot 10^{+57}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 2.49999999999999986e57Initial program 99.0%
if 2.49999999999999986e57 < z Initial program 90.9%
Taylor expanded in z around inf 100.0%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* y (* z x))))
(if (<= z -2.4e+73)
t_0
(if (<= z -1.05e+51)
t_1
(if (<= z -0.0058)
t_0
(if (<= z 2.2e-65) x (if (<= z 4.5e+84) t_1 t_0)))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = y * (z * x);
double tmp;
if (z <= -2.4e+73) {
tmp = t_0;
} else if (z <= -1.05e+51) {
tmp = t_1;
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 2.2e-65) {
tmp = x;
} else if (z <= 4.5e+84) {
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 = y * (z * x)
if (z <= (-2.4d+73)) then
tmp = t_0
else if (z <= (-1.05d+51)) then
tmp = t_1
else if (z <= (-0.0058d0)) then
tmp = t_0
else if (z <= 2.2d-65) then
tmp = x
else if (z <= 4.5d+84) 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 = y * (z * x);
double tmp;
if (z <= -2.4e+73) {
tmp = t_0;
} else if (z <= -1.05e+51) {
tmp = t_1;
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 2.2e-65) {
tmp = x;
} else if (z <= 4.5e+84) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = y * (z * x) tmp = 0 if z <= -2.4e+73: tmp = t_0 elif z <= -1.05e+51: tmp = t_1 elif z <= -0.0058: tmp = t_0 elif z <= 2.2e-65: tmp = x elif z <= 4.5e+84: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(y * Float64(z * x)) tmp = 0.0 if (z <= -2.4e+73) tmp = t_0; elseif (z <= -1.05e+51) tmp = t_1; elseif (z <= -0.0058) tmp = t_0; elseif (z <= 2.2e-65) tmp = x; elseif (z <= 4.5e+84) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = y * (z * x); tmp = 0.0; if (z <= -2.4e+73) tmp = t_0; elseif (z <= -1.05e+51) tmp = t_1; elseif (z <= -0.0058) tmp = t_0; elseif (z <= 2.2e-65) tmp = x; elseif (z <= 4.5e+84) 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[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.4e+73], t$95$0, If[LessEqual[z, -1.05e+51], t$95$1, If[LessEqual[z, -0.0058], t$95$0, If[LessEqual[z, 2.2e-65], x, If[LessEqual[z, 4.5e+84], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{+51}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -0.0058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-65}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+84}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.40000000000000002e73 or -1.0500000000000001e51 < z < -0.0058 or 4.4999999999999997e84 < z Initial program 94.2%
Taylor expanded in z around inf 99.7%
Taylor expanded in y around 0 65.5%
mul-1-neg65.5%
Simplified65.5%
if -2.40000000000000002e73 < z < -1.0500000000000001e51 or 2.20000000000000021e-65 < z < 4.4999999999999997e84Initial program 100.0%
Taylor expanded in y around inf 65.9%
if -0.0058 < z < 2.20000000000000021e-65Initial program 99.9%
Taylor expanded in z around 0 79.5%
Final simplification71.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -1.02e+74)
t_0
(if (<= z -8e+50)
(* y (* z x))
(if (<= z -0.0058)
t_0
(if (<= z 5.3e-65) x (if (<= z 3.8e+85) (* z (* x y)) t_0)))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.02e+74) {
tmp = t_0;
} else if (z <= -8e+50) {
tmp = y * (z * x);
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 5.3e-65) {
tmp = x;
} else if (z <= 3.8e+85) {
tmp = z * (x * y);
} 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) :: tmp
t_0 = z * -x
if (z <= (-1.02d+74)) then
tmp = t_0
else if (z <= (-8d+50)) then
tmp = y * (z * x)
else if (z <= (-0.0058d0)) then
tmp = t_0
else if (z <= 5.3d-65) then
tmp = x
else if (z <= 3.8d+85) then
tmp = z * (x * y)
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 tmp;
if (z <= -1.02e+74) {
tmp = t_0;
} else if (z <= -8e+50) {
tmp = y * (z * x);
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 5.3e-65) {
tmp = x;
} else if (z <= 3.8e+85) {
tmp = z * (x * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -1.02e+74: tmp = t_0 elif z <= -8e+50: tmp = y * (z * x) elif z <= -0.0058: tmp = t_0 elif z <= 5.3e-65: tmp = x elif z <= 3.8e+85: tmp = z * (x * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -1.02e+74) tmp = t_0; elseif (z <= -8e+50) tmp = Float64(y * Float64(z * x)); elseif (z <= -0.0058) tmp = t_0; elseif (z <= 5.3e-65) tmp = x; elseif (z <= 3.8e+85) tmp = Float64(z * Float64(x * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -1.02e+74) tmp = t_0; elseif (z <= -8e+50) tmp = y * (z * x); elseif (z <= -0.0058) tmp = t_0; elseif (z <= 5.3e-65) tmp = x; elseif (z <= 3.8e+85) tmp = z * (x * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -1.02e+74], t$95$0, If[LessEqual[z, -8e+50], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -0.0058], t$95$0, If[LessEqual[z, 5.3e-65], x, If[LessEqual[z, 3.8e+85], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -1.02 \cdot 10^{+74}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -8 \cdot 10^{+50}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;z \leq -0.0058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{-65}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+85}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.02000000000000005e74 or -8.0000000000000006e50 < z < -0.0058 or 3.79999999999999992e85 < z Initial program 94.2%
Taylor expanded in z around inf 99.7%
Taylor expanded in y around 0 65.5%
mul-1-neg65.5%
Simplified65.5%
if -1.02000000000000005e74 < z < -8.0000000000000006e50Initial program 100.0%
Taylor expanded in y around inf 78.8%
if -0.0058 < z < 5.30000000000000037e-65Initial program 99.9%
Taylor expanded in z around 0 79.5%
if 5.30000000000000037e-65 < z < 3.79999999999999992e85Initial program 100.0%
Taylor expanded in y around inf 61.3%
associate-*r*61.5%
*-commutative61.5%
associate-*l*61.4%
Simplified61.4%
Final simplification71.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -2.1e+78)
t_0
(if (<= z -1.05e+51)
(* y (* z x))
(if (<= z -0.0058)
t_0
(if (<= z 5.3e-65) x (if (<= z 1.1e+86) (* x (* z y)) t_0)))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -2.1e+78) {
tmp = t_0;
} else if (z <= -1.05e+51) {
tmp = y * (z * x);
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 5.3e-65) {
tmp = x;
} else if (z <= 1.1e+86) {
tmp = x * (z * y);
} 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) :: tmp
t_0 = z * -x
if (z <= (-2.1d+78)) then
tmp = t_0
else if (z <= (-1.05d+51)) then
tmp = y * (z * x)
else if (z <= (-0.0058d0)) then
tmp = t_0
else if (z <= 5.3d-65) then
tmp = x
else if (z <= 1.1d+86) then
tmp = x * (z * y)
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 tmp;
if (z <= -2.1e+78) {
tmp = t_0;
} else if (z <= -1.05e+51) {
tmp = y * (z * x);
} else if (z <= -0.0058) {
tmp = t_0;
} else if (z <= 5.3e-65) {
tmp = x;
} else if (z <= 1.1e+86) {
tmp = x * (z * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -2.1e+78: tmp = t_0 elif z <= -1.05e+51: tmp = y * (z * x) elif z <= -0.0058: tmp = t_0 elif z <= 5.3e-65: tmp = x elif z <= 1.1e+86: tmp = x * (z * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -2.1e+78) tmp = t_0; elseif (z <= -1.05e+51) tmp = Float64(y * Float64(z * x)); elseif (z <= -0.0058) tmp = t_0; elseif (z <= 5.3e-65) tmp = x; elseif (z <= 1.1e+86) tmp = Float64(x * Float64(z * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -2.1e+78) tmp = t_0; elseif (z <= -1.05e+51) tmp = y * (z * x); elseif (z <= -0.0058) tmp = t_0; elseif (z <= 5.3e-65) tmp = x; elseif (z <= 1.1e+86) tmp = x * (z * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -2.1e+78], t$95$0, If[LessEqual[z, -1.05e+51], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -0.0058], t$95$0, If[LessEqual[z, 5.3e-65], x, If[LessEqual[z, 1.1e+86], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{+78}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{+51}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;z \leq -0.0058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{-65}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+86}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.1000000000000001e78 or -1.0500000000000001e51 < z < -0.0058 or 1.10000000000000002e86 < z Initial program 94.2%
Taylor expanded in z around inf 99.7%
Taylor expanded in y around 0 65.5%
mul-1-neg65.5%
Simplified65.5%
if -2.1000000000000001e78 < z < -1.0500000000000001e51Initial program 100.0%
Taylor expanded in y around inf 78.8%
if -0.0058 < z < 5.30000000000000037e-65Initial program 99.9%
Taylor expanded in z around 0 79.5%
if 5.30000000000000037e-65 < z < 1.10000000000000002e86Initial program 100.0%
distribute-rgt-out--100.0%
*-lft-identity100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
distribute-lft-neg-in100.0%
associate-*l*99.7%
fma-def99.7%
neg-sub099.7%
associate--r-99.7%
metadata-eval99.7%
+-commutative99.7%
*-commutative99.7%
Simplified99.7%
fma-udef99.7%
associate-*r*99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 79.3%
Taylor expanded in y around inf 61.3%
associate-*r*61.5%
Simplified61.5%
Final simplification71.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e-57) (not (<= z 13200000.0))) (* z (* x (+ y -1.0))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e-57) || !(z <= 13200000.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (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 ((z <= (-4.5d-57)) .or. (.not. (z <= 13200000.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e-57) || !(z <= 13200000.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e-57) or not (z <= 13200000.0): tmp = z * (x * (y + -1.0)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e-57) || !(z <= 13200000.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.5e-57) || ~((z <= 13200000.0))) tmp = z * (x * (y + -1.0)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e-57], N[Not[LessEqual[z, 13200000.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{-57} \lor \neg \left(z \leq 13200000\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -4.49999999999999973e-57 or 1.32e7 < z Initial program 95.4%
Taylor expanded in z around inf 97.7%
if -4.49999999999999973e-57 < z < 1.32e7Initial program 99.9%
Taylor expanded in y around 0 79.4%
*-commutative79.4%
distribute-rgt-out--79.4%
*-lft-identity79.4%
Simplified79.4%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.0058) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0058) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
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 <= (-0.0058d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x * (1.0d0 + (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0058) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.0058) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.0058) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 + Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.0058) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.0058], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0058 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -0.0058 or 1 < z Initial program 95.2%
Taylor expanded in z around inf 99.7%
if -0.0058 < z < 1Initial program 99.9%
distribute-rgt-out--99.9%
*-lft-identity99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
distribute-lft-neg-in99.9%
associate-*l*94.8%
fma-def94.8%
neg-sub094.8%
associate--r-94.8%
metadata-eval94.8%
+-commutative94.8%
*-commutative94.8%
Simplified94.8%
fma-udef94.8%
associate-*r*92.5%
Applied egg-rr92.5%
Taylor expanded in y around inf 93.3%
Taylor expanded in x around 0 98.4%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+48) (not (<= y 360000.0))) (* z (* x y)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+48) || !(y <= 360000.0)) {
tmp = z * (x * y);
} else {
tmp = x - (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 <= (-5.5d+48)) .or. (.not. (y <= 360000.0d0))) then
tmp = z * (x * y)
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+48) || !(y <= 360000.0)) {
tmp = z * (x * y);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+48) or not (y <= 360000.0): tmp = z * (x * y) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+48) || !(y <= 360000.0)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+48) || ~((y <= 360000.0))) tmp = z * (x * y); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+48], N[Not[LessEqual[y, 360000.0]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+48} \lor \neg \left(y \leq 360000\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -5.5000000000000002e48 or 3.6e5 < y Initial program 94.9%
Taylor expanded in y around inf 74.6%
associate-*r*74.7%
*-commutative74.7%
associate-*l*76.3%
Simplified76.3%
if -5.5000000000000002e48 < y < 3.6e5Initial program 99.3%
Taylor expanded in y around 0 97.7%
*-commutative97.7%
distribute-rgt-out--97.7%
*-lft-identity97.7%
Simplified97.7%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.0058) (not (<= z 340000000000.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0058) || !(z <= 340000000000.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 <= (-0.0058d0)) .or. (.not. (z <= 340000000000.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 <= -0.0058) || !(z <= 340000000000.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.0058) or not (z <= 340000000000.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.0058) || !(z <= 340000000000.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 <= -0.0058) || ~((z <= 340000000000.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.0058], N[Not[LessEqual[z, 340000000000.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0058 \lor \neg \left(z \leq 340000000000\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.0058 or 3.4e11 < z Initial program 95.2%
Taylor expanded in z around inf 99.7%
Taylor expanded in y around 0 60.6%
mul-1-neg60.6%
Simplified60.6%
if -0.0058 < z < 3.4e11Initial program 99.9%
Taylor expanded in z around 0 75.7%
Final simplification67.6%
(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.3%
Taylor expanded in z around 0 36.6%
Final simplification36.6%
(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 2023199
(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))))