
(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 13 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 -1.0) (* (* z x) (+ y -1.0)) (if (<= z 1.0) (* x (+ 1.0 (* y z))) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = z * ((y * x) - 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)) then
tmp = (z * x) * (y + (-1.0d0))
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (y * z))
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = (z * x) * (y + -1.0) elif z <= 1.0: tmp = x * (1.0 + (y * z)) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = (z * x) * (y + -1.0); elseif (z <= 1.0) tmp = x * (1.0 + (y * z)); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -1Initial program 94.9%
*-commutative94.9%
flip--52.8%
associate-*l/51.5%
metadata-eval51.5%
pow251.5%
+-commutative51.5%
fma-def51.5%
Applied egg-rr51.5%
Taylor expanded in z around inf 91.5%
associate-*r*91.5%
*-commutative91.5%
neg-mul-191.5%
distribute-lft-neg-in91.5%
distribute-rgt-neg-in91.5%
neg-sub091.5%
*-commutative91.5%
sub-neg91.5%
distribute-rgt-in91.5%
fma-def91.5%
distribute-lft-neg-in91.5%
fma-neg91.5%
*-lft-identity91.5%
associate-+l-91.5%
neg-sub091.5%
neg-mul-191.5%
distribute-rgt-out91.5%
+-commutative91.5%
associate-*r*96.6%
Simplified96.6%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around inf 99.3%
mul-1-neg99.3%
distribute-lft-neg-out99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in z around 0 99.2%
*-commutative99.2%
*-commutative99.2%
distribute-rgt1-in99.3%
Applied egg-rr99.3%
if 1 < z Initial program 91.4%
Taylor expanded in z around inf 91.4%
*-commutative91.4%
associate-*l*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
distribute-rgt-in99.9%
neg-mul-199.9%
Applied egg-rr99.9%
Final simplification98.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -1.0)
t_0
(if (<= z 2.4e-63) x (if (<= z 2.75e+104) (* x (* y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 2.4e-63) {
tmp = x;
} else if (z <= 2.75e+104) {
tmp = x * (y * z);
} 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.0d0)) then
tmp = t_0
else if (z <= 2.4d-63) then
tmp = x
else if (z <= 2.75d+104) then
tmp = x * (y * z)
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.0) {
tmp = t_0;
} else if (z <= 2.4e-63) {
tmp = x;
} else if (z <= 2.75e+104) {
tmp = x * (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 2.4e-63: tmp = x elif z <= 2.75e+104: tmp = x * (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 2.4e-63) tmp = x; elseif (z <= 2.75e+104) tmp = Float64(x * Float64(y * z)); 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.0) tmp = t_0; elseif (z <= 2.4e-63) tmp = x; elseif (z <= 2.75e+104) tmp = x * (y * z); 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.0], t$95$0, If[LessEqual[z, 2.4e-63], x, If[LessEqual[z, 2.75e+104], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-63}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+104}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 2.75000000000000008e104 < z Initial program 92.3%
Taylor expanded in z around inf 90.2%
Taylor expanded in y around 0 57.6%
mul-1-neg57.6%
*-commutative57.6%
distribute-rgt-neg-in57.6%
Simplified57.6%
if -1 < z < 2.4000000000000001e-63Initial program 100.0%
Taylor expanded in z around 0 82.8%
if 2.4000000000000001e-63 < z < 2.75000000000000008e104Initial program 99.8%
Taylor expanded in y around inf 59.3%
*-commutative59.3%
Simplified59.3%
Final simplification67.8%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -5e+73) (* (* z x) (+ y -1.0)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -5e+73) {
tmp = (z * x) * (y + -1.0);
} 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) <= (-5d+73)) then
tmp = (z * x) * (y + (-1.0d0))
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) <= -5e+73) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -5e+73: tmp = (z * x) * (y + -1.0) 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) <= -5e+73) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); 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) <= -5e+73) tmp = (z * x) * (y + -1.0); 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], -5e+73], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $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 -5 \cdot 10^{+73}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -4.99999999999999976e73Initial program 91.2%
*-commutative91.2%
flip--51.0%
associate-*l/48.1%
metadata-eval48.1%
pow248.1%
+-commutative48.1%
fma-def48.1%
Applied egg-rr48.1%
Taylor expanded in z around inf 91.2%
associate-*r*91.2%
*-commutative91.2%
neg-mul-191.2%
distribute-lft-neg-in91.2%
distribute-rgt-neg-in91.2%
neg-sub091.2%
*-commutative91.2%
sub-neg91.2%
distribute-rgt-in91.2%
fma-def91.2%
distribute-lft-neg-in91.2%
fma-neg91.2%
*-lft-identity91.2%
associate-+l-91.2%
neg-sub091.2%
neg-mul-191.2%
distribute-rgt-out91.2%
+-commutative91.2%
associate-*r*99.9%
Simplified99.9%
if -4.99999999999999976e73 < (*.f64 (-.f64 1 y) z) Initial program 97.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -220000.0) (not (<= z 2.2e-64))) (* x (* z (+ y -1.0))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -220000.0) || !(z <= 2.2e-64)) {
tmp = x * (z * (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 <= (-220000.0d0)) .or. (.not. (z <= 2.2d-64))) then
tmp = x * (z * (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 <= -220000.0) || !(z <= 2.2e-64)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -220000.0) or not (z <= 2.2e-64): tmp = x * (z * (y + -1.0)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -220000.0) || !(z <= 2.2e-64)) tmp = Float64(x * Float64(z * 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 <= -220000.0) || ~((z <= 2.2e-64))) tmp = x * (z * (y + -1.0)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -220000.0], N[Not[LessEqual[z, 2.2e-64]], $MachinePrecision]], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -220000 \lor \neg \left(z \leq 2.2 \cdot 10^{-64}\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -2.2e5 or 2.2e-64 < z Initial program 93.6%
Taylor expanded in z around inf 89.6%
if -2.2e5 < z < 2.2e-64Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
unsub-neg82.6%
Simplified82.6%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -210000.0) (not (<= z 1.08e-5))) (* z (* x (+ y -1.0))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -210000.0) || !(z <= 1.08e-5)) {
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 <= (-210000.0d0)) .or. (.not. (z <= 1.08d-5))) 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 <= -210000.0) || !(z <= 1.08e-5)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -210000.0) or not (z <= 1.08e-5): tmp = z * (x * (y + -1.0)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -210000.0) || !(z <= 1.08e-5)) 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 <= -210000.0) || ~((z <= 1.08e-5))) tmp = z * (x * (y + -1.0)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -210000.0], N[Not[LessEqual[z, 1.08e-5]], $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 -210000 \lor \neg \left(z \leq 1.08 \cdot 10^{-5}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -2.1e5 or 1.07999999999999999e-5 < z Initial program 93.1%
Taylor expanded in z around inf 92.6%
*-commutative92.6%
associate-*l*99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
Simplified99.4%
if -2.1e5 < z < 1.07999999999999999e-5Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -170000.0) (* x (* z (+ y -1.0))) (if (<= z 6.5e-56) (- x (* z x)) (* x (- (* y z) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -170000.0) {
tmp = x * (z * (y + -1.0));
} else if (z <= 6.5e-56) {
tmp = x - (z * x);
} else {
tmp = x * ((y * z) - 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 <= (-170000.0d0)) then
tmp = x * (z * (y + (-1.0d0)))
else if (z <= 6.5d-56) then
tmp = x - (z * x)
else
tmp = x * ((y * z) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -170000.0) {
tmp = x * (z * (y + -1.0));
} else if (z <= 6.5e-56) {
tmp = x - (z * x);
} else {
tmp = x * ((y * z) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -170000.0: tmp = x * (z * (y + -1.0)) elif z <= 6.5e-56: tmp = x - (z * x) else: tmp = x * ((y * z) - z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -170000.0) tmp = Float64(x * Float64(z * Float64(y + -1.0))); elseif (z <= 6.5e-56) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(Float64(y * z) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -170000.0) tmp = x * (z * (y + -1.0)); elseif (z <= 6.5e-56) tmp = x - (z * x); else tmp = x * ((y * z) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -170000.0], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e-56], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -170000:\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-56}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z - z\right)\\
\end{array}
\end{array}
if z < -1.7e5Initial program 94.6%
Taylor expanded in z around inf 93.7%
if -1.7e5 < z < 6.4999999999999997e-56Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
unsub-neg82.6%
Simplified82.6%
if 6.4999999999999997e-56 < z Initial program 92.7%
Taylor expanded in z around inf 85.9%
sub-neg85.9%
distribute-rgt-in85.9%
*-commutative85.9%
metadata-eval85.9%
neg-mul-185.9%
Applied egg-rr85.9%
unsub-neg85.9%
Applied egg-rr85.9%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (<= z -130000.0) (* (* z x) (+ y -1.0)) (if (<= z 1.35e-6) (- x (* z x)) (* z (* x (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -130000.0) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.35e-6) {
tmp = x - (z * x);
} 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 <= (-130000.0d0)) then
tmp = (z * x) * (y + (-1.0d0))
else if (z <= 1.35d-6) then
tmp = x - (z * x)
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 <= -130000.0) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.35e-6) {
tmp = x - (z * x);
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -130000.0: tmp = (z * x) * (y + -1.0) elif z <= 1.35e-6: tmp = x - (z * x) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -130000.0) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); elseif (z <= 1.35e-6) tmp = Float64(x - Float64(z * x)); 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 <= -130000.0) tmp = (z * x) * (y + -1.0); elseif (z <= 1.35e-6) tmp = x - (z * x); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -130000.0], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.35e-6], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -130000:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -1.3e5Initial program 94.6%
*-commutative94.6%
flip--50.2%
associate-*l/48.9%
metadata-eval48.9%
pow248.9%
+-commutative48.9%
fma-def48.9%
Applied egg-rr48.9%
Taylor expanded in z around inf 93.7%
associate-*r*93.7%
*-commutative93.7%
neg-mul-193.7%
distribute-lft-neg-in93.7%
distribute-rgt-neg-in93.7%
neg-sub093.7%
*-commutative93.7%
sub-neg93.7%
distribute-rgt-in93.7%
fma-def93.7%
distribute-lft-neg-in93.7%
fma-neg93.7%
*-lft-identity93.7%
associate-+l-93.7%
neg-sub093.7%
neg-mul-193.7%
distribute-rgt-out93.7%
+-commutative93.7%
associate-*r*99.0%
Simplified99.0%
if -1.3e5 < z < 1.34999999999999999e-6Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
if 1.34999999999999999e-6 < z Initial program 91.5%
Taylor expanded in z around inf 91.5%
*-commutative91.5%
associate-*l*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.15) (* (* z x) (+ y -1.0)) (if (<= z 1.0) (* x (+ 1.0 (* y z))) (* z (* x (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} 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 <= (-1.15d0)) then
tmp = (z * x) * (y + (-1.0d0))
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (y * z))
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 <= -1.15) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.15: tmp = (z * x) * (y + -1.0) elif z <= 1.0: tmp = x * (1.0 + (y * z)) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.15) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(y * z))); 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 <= -1.15) tmp = (z * x) * (y + -1.0); elseif (z <= 1.0) tmp = x * (1.0 + (y * z)); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.15], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -1.1499999999999999Initial program 94.9%
*-commutative94.9%
flip--52.8%
associate-*l/51.5%
metadata-eval51.5%
pow251.5%
+-commutative51.5%
fma-def51.5%
Applied egg-rr51.5%
Taylor expanded in z around inf 91.5%
associate-*r*91.5%
*-commutative91.5%
neg-mul-191.5%
distribute-lft-neg-in91.5%
distribute-rgt-neg-in91.5%
neg-sub091.5%
*-commutative91.5%
sub-neg91.5%
distribute-rgt-in91.5%
fma-def91.5%
distribute-lft-neg-in91.5%
fma-neg91.5%
*-lft-identity91.5%
associate-+l-91.5%
neg-sub091.5%
neg-mul-191.5%
distribute-rgt-out91.5%
+-commutative91.5%
associate-*r*96.6%
Simplified96.6%
if -1.1499999999999999 < z < 1Initial program 99.9%
Taylor expanded in y around inf 99.3%
mul-1-neg99.3%
distribute-lft-neg-out99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in z around 0 99.2%
*-commutative99.2%
*-commutative99.2%
distribute-rgt1-in99.3%
Applied egg-rr99.3%
if 1 < z Initial program 91.4%
Taylor expanded in z around inf 91.4%
*-commutative91.4%
associate-*l*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.9e+84) (not (<= y 7.5e+15))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.9e+84) || !(y <= 7.5e+15)) {
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+84)) .or. (.not. (y <= 7.5d+15))) 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+84) || !(y <= 7.5e+15)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.9e+84) or not (y <= 7.5e+15): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.9e+84) || !(y <= 7.5e+15)) 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+84) || ~((y <= 7.5e+15))) 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+84], N[Not[LessEqual[y, 7.5e+15]], $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^{+84} \lor \neg \left(y \leq 7.5 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.89999999999999989e84 or 7.5e15 < y Initial program 92.4%
Taylor expanded in y around inf 72.5%
*-commutative72.5%
Simplified72.5%
if -2.89999999999999989e84 < y < 7.5e15Initial program 98.7%
Taylor expanded in y around 0 92.1%
Final simplification84.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.5e+83) (* x (* y z)) (if (<= y 15500000000.0) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.5e+83) {
tmp = x * (y * z);
} else if (y <= 15500000000.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 <= (-2.5d+83)) then
tmp = x * (y * z)
else if (y <= 15500000000.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 <= -2.5e+83) {
tmp = x * (y * z);
} else if (y <= 15500000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.5e+83: tmp = x * (y * z) elif y <= 15500000000.0: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.5e+83) tmp = Float64(x * Float64(y * z)); elseif (y <= 15500000000.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 <= -2.5e+83) tmp = x * (y * z); elseif (y <= 15500000000.0) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.5e+83], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 15500000000.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 -2.5 \cdot 10^{+83}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 15500000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -2.50000000000000014e83Initial program 95.2%
Taylor expanded in y around inf 82.2%
*-commutative82.2%
Simplified82.2%
if -2.50000000000000014e83 < y < 1.55e10Initial program 99.9%
Taylor expanded in y around 0 93.3%
if 1.55e10 < y Initial program 87.9%
Taylor expanded in y around inf 63.1%
*-commutative63.1%
associate-*l*73.0%
*-commutative73.0%
Simplified73.0%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (<= y -1e+85) (* x (* y z)) (if (<= y 15000000000.0) (- x (* z x)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+85) {
tmp = x * (y * z);
} else if (y <= 15000000000.0) {
tmp = x - (z * x);
} 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 <= (-1d+85)) then
tmp = x * (y * z)
else if (y <= 15000000000.0d0) then
tmp = x - (z * x)
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 <= -1e+85) {
tmp = x * (y * z);
} else if (y <= 15000000000.0) {
tmp = x - (z * x);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+85: tmp = x * (y * z) elif y <= 15000000000.0: tmp = x - (z * x) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+85) tmp = Float64(x * Float64(y * z)); elseif (y <= 15000000000.0) tmp = Float64(x - Float64(z * x)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e+85) tmp = x * (y * z); elseif (y <= 15000000000.0) tmp = x - (z * x); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+85], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 15000000000.0], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+85}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 15000000000:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -1e85Initial program 95.2%
Taylor expanded in y around inf 82.2%
*-commutative82.2%
Simplified82.2%
if -1e85 < y < 1.5e10Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 93.3%
mul-1-neg93.3%
unsub-neg93.3%
Simplified93.3%
if 1.5e10 < y Initial program 87.9%
Taylor expanded in y around inf 63.1%
*-commutative63.1%
associate-*l*73.0%
*-commutative73.0%
Simplified73.0%
Final simplification86.6%
(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 93.2%
Taylor expanded in z around inf 91.5%
Taylor expanded in y around 0 54.5%
mul-1-neg54.5%
*-commutative54.5%
distribute-rgt-neg-in54.5%
Simplified54.5%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 78.0%
Final simplification65.0%
(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 96.2%
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 2024040
(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))))