
(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 (<= (- 1.0 y) -1e+95) (+ x (* (* x z) y)) (+ x (* x (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1e+95) {
tmp = x + ((x * z) * y);
} else {
tmp = x + (x * (z * (-1.0 + 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 ((1.0d0 - y) <= (-1d+95)) then
tmp = x + ((x * z) * y)
else
tmp = x + (x * (z * ((-1.0d0) + y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1e+95) {
tmp = x + ((x * z) * y);
} else {
tmp = x + (x * (z * (-1.0 + y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - y) <= -1e+95: tmp = x + ((x * z) * y) else: tmp = x + (x * (z * (-1.0 + y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(1.0 - y) <= -1e+95) tmp = Float64(x + Float64(Float64(x * z) * y)); else tmp = Float64(x + Float64(x * Float64(z * Float64(-1.0 + y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((1.0 - y) <= -1e+95) tmp = x + ((x * z) * y); else tmp = x + (x * (z * (-1.0 + y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], -1e+95], N[(x + N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -1 \cdot 10^{+95}:\\
\;\;\;\;x + \left(x \cdot z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -1.00000000000000002e95Initial program 83.5%
Taylor expanded in z around 0 83.5%
Taylor expanded in y around 0 73.0%
associate-*r*74.2%
*-commutative74.2%
associate-*r*87.6%
distribute-rgt-in98.1%
Simplified98.1%
Taylor expanded in y around inf 83.5%
associate-*r*84.8%
*-commutative84.8%
associate-*r*98.1%
Simplified98.1%
if -1.00000000000000002e95 < (-.f64 #s(literal 1 binary64) y) Initial program 99.4%
Taylor expanded in z around 0 99.4%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -5.2e+196)
t_0
(if (<= z -3.7e+155)
(* x (* z y))
(if (or (<= z -1.0) (not (<= z 1.0))) t_0 x)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -5.2e+196) {
tmp = t_0;
} else if (z <= -3.7e+155) {
tmp = x * (z * y);
} else if ((z <= -1.0) || !(z <= 1.0)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = z * -x
if (z <= (-5.2d+196)) then
tmp = t_0
else if (z <= (-3.7d+155)) then
tmp = x * (z * y)
else if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = t_0
else
tmp = x
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 <= -5.2e+196) {
tmp = t_0;
} else if (z <= -3.7e+155) {
tmp = x * (z * y);
} else if ((z <= -1.0) || !(z <= 1.0)) {
tmp = t_0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -5.2e+196: tmp = t_0 elif z <= -3.7e+155: tmp = x * (z * y) elif (z <= -1.0) or not (z <= 1.0): tmp = t_0 else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -5.2e+196) tmp = t_0; elseif (z <= -3.7e+155) tmp = Float64(x * Float64(z * y)); elseif ((z <= -1.0) || !(z <= 1.0)) tmp = t_0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -5.2e+196) tmp = t_0; elseif (z <= -3.7e+155) tmp = x * (z * y); elseif ((z <= -1.0) || ~((z <= 1.0))) tmp = t_0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -5.2e+196], t$95$0, If[LessEqual[z, -3.7e+155], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], t$95$0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+196}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{+155}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.20000000000000024e196 or -3.6999999999999998e155 < z < -1 or 1 < z Initial program 92.0%
Taylor expanded in z around inf 91.0%
associate-*r*98.9%
*-commutative98.9%
associate-*r*98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in y around 0 56.9%
neg-mul-156.9%
Simplified56.9%
if -5.20000000000000024e196 < z < -3.6999999999999998e155Initial program 86.3%
Taylor expanded in y around inf 86.3%
*-commutative86.3%
Simplified86.3%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 80.3%
Final simplification69.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e-25) (not (<= z 48000000000.0))) (* z (* x (+ -1.0 y))) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e-25) || !(z <= 48000000000.0)) {
tmp = z * (x * (-1.0 + y));
} 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 ((z <= (-6.5d-25)) .or. (.not. (z <= 48000000000.0d0))) then
tmp = z * (x * ((-1.0d0) + y))
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 ((z <= -6.5e-25) || !(z <= 48000000000.0)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e-25) or not (z <= 48000000000.0): tmp = z * (x * (-1.0 + y)) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e-25) || !(z <= 48000000000.0)) tmp = Float64(z * Float64(x * Float64(-1.0 + y))); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e-25) || ~((z <= 48000000000.0))) tmp = z * (x * (-1.0 + y)); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e-25], N[Not[LessEqual[z, 48000000000.0]], $MachinePrecision]], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{-25} \lor \neg \left(z \leq 48000000000\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if z < -6.5e-25 or 4.8e10 < z Initial program 91.9%
Taylor expanded in z around inf 89.7%
associate-*r*97.7%
*-commutative97.7%
associate-*r*97.7%
sub-neg97.7%
metadata-eval97.7%
Simplified97.7%
if -6.5e-25 < z < 4.8e10Initial program 99.9%
Taylor expanded in y around 0 82.7%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.85e-22) (* z (- (* x y) x)) (if (<= z 48000000000.0) (* x (- 1.0 z)) (* z (* x (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.85e-22) {
tmp = z * ((x * y) - x);
} else if (z <= 48000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * (-1.0 + 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 <= (-1.85d-22)) then
tmp = z * ((x * y) - x)
else if (z <= 48000000000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = z * (x * ((-1.0d0) + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.85e-22) {
tmp = z * ((x * y) - x);
} else if (z <= 48000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * (-1.0 + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.85e-22: tmp = z * ((x * y) - x) elif z <= 48000000000.0: tmp = x * (1.0 - z) else: tmp = z * (x * (-1.0 + y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.85e-22) tmp = Float64(z * Float64(Float64(x * y) - x)); elseif (z <= 48000000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(x * Float64(-1.0 + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.85e-22) tmp = z * ((x * y) - x); elseif (z <= 48000000000.0) tmp = x * (1.0 - z); else tmp = z * (x * (-1.0 + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.85e-22], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 48000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{-22}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{elif}\;z \leq 48000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if z < -1.85e-22Initial program 90.5%
Taylor expanded in z around inf 87.2%
associate-*r*96.5%
*-commutative96.5%
associate-*r*96.5%
sub-neg96.5%
metadata-eval96.5%
Simplified96.5%
distribute-lft-in96.5%
*-commutative96.5%
mul-1-neg96.5%
Applied egg-rr96.5%
Taylor expanded in z around 0 96.5%
if -1.85e-22 < z < 4.8e10Initial program 99.9%
Taylor expanded in y around 0 82.7%
if 4.8e10 < z Initial program 94.1%
Taylor expanded in z around inf 93.8%
associate-*r*99.6%
*-commutative99.6%
associate-*r*99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.05) (* z (- (* x y) x)) (if (<= z 1.0) (* x (+ 1.0 (* z y))) (* z (* x (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = z * ((x * y) - x);
} else if (z <= 1.0) {
tmp = x * (1.0 + (z * y));
} else {
tmp = z * (x * (-1.0 + 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 <= (-1.05d0)) then
tmp = z * ((x * y) - x)
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (z * y))
else
tmp = z * (x * ((-1.0d0) + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = z * ((x * y) - x);
} else if (z <= 1.0) {
tmp = x * (1.0 + (z * y));
} else {
tmp = z * (x * (-1.0 + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05: tmp = z * ((x * y) - x) elif z <= 1.0: tmp = x * (1.0 + (z * y)) else: tmp = z * (x * (-1.0 + y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05) tmp = Float64(z * Float64(Float64(x * y) - x)); elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(z * y))); else tmp = Float64(z * Float64(x * Float64(-1.0 + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05) tmp = z * ((x * y) - x); elseif (z <= 1.0) tmp = x * (1.0 + (z * y)); else tmp = z * (x * (-1.0 + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004Initial program 89.9%
Taylor expanded in z around inf 88.9%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
distribute-lft-in98.9%
*-commutative98.9%
mul-1-neg98.9%
Applied egg-rr98.9%
Taylor expanded in z around 0 98.9%
if -1.05000000000000004 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 99.9%
associate-*r*91.3%
*-commutative91.3%
associate-*r*97.8%
distribute-rgt-in97.8%
Simplified97.8%
Taylor expanded in y around inf 98.5%
associate-*r*89.9%
*-commutative89.9%
associate-*r*96.3%
Simplified96.3%
*-commutative96.3%
associate-*r*98.5%
*-commutative98.5%
distribute-rgt1-in98.5%
Applied egg-rr98.5%
if 1 < z Initial program 94.3%
Taylor expanded in z around inf 93.4%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.1%
sub-neg99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= (- 1.0 y) -1e+95) (+ x (* (* x z) y)) (* x (+ 1.0 (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1e+95) {
tmp = x + ((x * z) * y);
} else {
tmp = x * (1.0 + (z * (-1.0 + 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 ((1.0d0 - y) <= (-1d+95)) then
tmp = x + ((x * z) * y)
else
tmp = x * (1.0d0 + (z * ((-1.0d0) + y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1e+95) {
tmp = x + ((x * z) * y);
} else {
tmp = x * (1.0 + (z * (-1.0 + y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - y) <= -1e+95: tmp = x + ((x * z) * y) else: tmp = x * (1.0 + (z * (-1.0 + y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(1.0 - y) <= -1e+95) tmp = Float64(x + Float64(Float64(x * z) * y)); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(-1.0 + y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((1.0 - y) <= -1e+95) tmp = x + ((x * z) * y); else tmp = x * (1.0 + (z * (-1.0 + y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], -1e+95], N[(x + N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -1 \cdot 10^{+95}:\\
\;\;\;\;x + \left(x \cdot z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -1.00000000000000002e95Initial program 83.5%
Taylor expanded in z around 0 83.5%
Taylor expanded in y around 0 73.0%
associate-*r*74.2%
*-commutative74.2%
associate-*r*87.6%
distribute-rgt-in98.1%
Simplified98.1%
Taylor expanded in y around inf 83.5%
associate-*r*84.8%
*-commutative84.8%
associate-*r*98.1%
Simplified98.1%
if -1.00000000000000002e95 < (-.f64 #s(literal 1 binary64) y) Initial program 99.4%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.15e+165) (not (<= y 17000000.0))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.15e+165) || !(y <= 17000000.0)) {
tmp = x * (z * y);
} 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 <= (-3.15d+165)) .or. (.not. (y <= 17000000.0d0))) then
tmp = x * (z * y)
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 <= -3.15e+165) || !(y <= 17000000.0)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.15e+165) or not (y <= 17000000.0): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.15e+165) || !(y <= 17000000.0)) tmp = Float64(x * Float64(z * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.15e+165) || ~((y <= 17000000.0))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.15e+165], N[Not[LessEqual[y, 17000000.0]], $MachinePrecision]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.15 \cdot 10^{+165} \lor \neg \left(y \leq 17000000\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.1500000000000001e165 or 1.7e7 < y Initial program 89.1%
Taylor expanded in y around inf 66.6%
*-commutative66.6%
Simplified66.6%
if -3.1500000000000001e165 < y < 1.7e7Initial program 99.9%
Taylor expanded in y around 0 93.7%
Final simplification83.7%
(FPCore (x y z) :precision binary64 (if (<= y -2.3e+160) (* x (* z y)) (if (<= y 7500000.0) (* x (- 1.0 z)) (* (* x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e+160) {
tmp = x * (z * y);
} else if (y <= 7500000.0) {
tmp = x * (1.0 - z);
} else {
tmp = (x * 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 (y <= (-2.3d+160)) then
tmp = x * (z * y)
else if (y <= 7500000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = (x * z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e+160) {
tmp = x * (z * y);
} else if (y <= 7500000.0) {
tmp = x * (1.0 - z);
} else {
tmp = (x * z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.3e+160: tmp = x * (z * y) elif y <= 7500000.0: tmp = x * (1.0 - z) else: tmp = (x * z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.3e+160) tmp = Float64(x * Float64(z * y)); elseif (y <= 7500000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(x * z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.3e+160) tmp = x * (z * y); elseif (y <= 7500000.0) tmp = x * (1.0 - z); else tmp = (x * z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.3e+160], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7500000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+160}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq 7500000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if y < -2.29999999999999987e160Initial program 95.0%
Taylor expanded in y around inf 89.3%
*-commutative89.3%
Simplified89.3%
if -2.29999999999999987e160 < y < 7.5e6Initial program 99.9%
Taylor expanded in y around 0 93.7%
if 7.5e6 < y Initial program 87.5%
Taylor expanded in z around 0 87.5%
Taylor expanded in y around inf 85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
fma-define85.2%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in y around inf 71.6%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.5e+160) (* z (* x y)) (if (<= y 3050000.0) (* x (- 1.0 z)) (* (* x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+160) {
tmp = z * (x * y);
} else if (y <= 3050000.0) {
tmp = x * (1.0 - z);
} else {
tmp = (x * 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 (y <= (-1.5d+160)) then
tmp = z * (x * y)
else if (y <= 3050000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = (x * z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+160) {
tmp = z * (x * y);
} else if (y <= 3050000.0) {
tmp = x * (1.0 - z);
} else {
tmp = (x * z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.5e+160: tmp = z * (x * y) elif y <= 3050000.0: tmp = x * (1.0 - z) else: tmp = (x * z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.5e+160) tmp = Float64(z * Float64(x * y)); elseif (y <= 3050000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(x * z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.5e+160) tmp = z * (x * y); elseif (y <= 3050000.0) tmp = x * (1.0 - z); else tmp = (x * z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.5e+160], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3050000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+160}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 3050000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if y < -1.4999999999999999e160Initial program 95.0%
Taylor expanded in y around inf 89.3%
associate-*r*90.7%
*-commutative90.7%
Simplified90.7%
if -1.4999999999999999e160 < y < 3.05e6Initial program 99.9%
Taylor expanded in y around 0 93.7%
if 3.05e6 < y Initial program 87.5%
Taylor expanded in z around 0 87.5%
Taylor expanded in y around inf 85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
fma-define85.2%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in y around inf 71.6%
Final simplification87.0%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e+165) (* z (* x y)) (if (<= y 16000000.0) (- x (* x z)) (* (* x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+165) {
tmp = z * (x * y);
} else if (y <= 16000000.0) {
tmp = x - (x * z);
} else {
tmp = (x * 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 (y <= (-2.1d+165)) then
tmp = z * (x * y)
else if (y <= 16000000.0d0) then
tmp = x - (x * z)
else
tmp = (x * z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+165) {
tmp = z * (x * y);
} else if (y <= 16000000.0) {
tmp = x - (x * z);
} else {
tmp = (x * z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e+165: tmp = z * (x * y) elif y <= 16000000.0: tmp = x - (x * z) else: tmp = (x * z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e+165) tmp = Float64(z * Float64(x * y)); elseif (y <= 16000000.0) tmp = Float64(x - Float64(x * z)); else tmp = Float64(Float64(x * z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.1e+165) tmp = z * (x * y); elseif (y <= 16000000.0) tmp = x - (x * z); else tmp = (x * z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e+165], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 16000000.0], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+165}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 16000000:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if y < -2.1000000000000001e165Initial program 95.0%
Taylor expanded in y around inf 89.3%
associate-*r*90.7%
*-commutative90.7%
Simplified90.7%
if -2.1000000000000001e165 < y < 1.6e7Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 98.7%
associate-*r*97.6%
*-commutative97.6%
associate-*r*95.6%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in y around 0 93.7%
mul-1-neg93.7%
sub-neg93.7%
Simplified93.7%
if 1.6e7 < y Initial program 87.5%
Taylor expanded in z around 0 87.5%
Taylor expanded in y around inf 85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
fma-define85.2%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in y around inf 71.6%
Final simplification87.0%
(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.7%
Taylor expanded in z around inf 90.7%
associate-*r*98.9%
*-commutative98.9%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in y around 0 53.9%
neg-mul-153.9%
Simplified53.9%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 80.3%
Final simplification67.5%
(FPCore (x y z) :precision binary64 (+ x (* (* x z) (+ -1.0 y))))
double code(double x, double y, double z) {
return x + ((x * z) * (-1.0 + y));
}
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) * ((-1.0d0) + y))
end function
public static double code(double x, double y, double z) {
return x + ((x * z) * (-1.0 + y));
}
def code(x, y, z): return x + ((x * z) * (-1.0 + y))
function code(x, y, z) return Float64(x + Float64(Float64(x * z) * Float64(-1.0 + y))) end
function tmp = code(x, y, z) tmp = x + ((x * z) * (-1.0 + y)); end
code[x_, y_, z_] := N[(x + N[(N[(x * z), $MachinePrecision] * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot z\right) \cdot \left(-1 + y\right)
\end{array}
Initial program 95.9%
Taylor expanded in z around 0 95.9%
Taylor expanded in y around 0 91.6%
associate-*r*91.2%
*-commutative91.2%
associate-*r*92.5%
distribute-rgt-in98.8%
Simplified98.8%
Final simplification98.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.9%
Taylor expanded in z around 0 43.1%
Final simplification43.1%
(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 2024115
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(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))))