
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.2e-179)
(* z (+ (/ x_m z) (* x_m (+ y -1.0))))
(fma (* x_m z) (+ y -1.0) x_m))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.2e-179) {
tmp = z * ((x_m / z) + (x_m * (y + -1.0)));
} else {
tmp = fma((x_m * z), (y + -1.0), x_m);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.2e-179) tmp = Float64(z * Float64(Float64(x_m / z) + Float64(x_m * Float64(y + -1.0)))); else tmp = fma(Float64(x_m * z), Float64(y + -1.0), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.2e-179], N[(z * N[(N[(x$95$m / z), $MachinePrecision] + N[(x$95$m * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision] + x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.2 \cdot 10^{-179}:\\
\;\;\;\;z \cdot \left(\frac{x\_m}{z} + x\_m \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m \cdot z, y + -1, x\_m\right)\\
\end{array}
\end{array}
if x < 1.2e-179Initial program 93.1%
Taylor expanded in z around inf 87.4%
if 1.2e-179 < x Initial program 97.2%
Taylor expanded in z around 0 97.2%
+-commutative97.2%
associate-*r*99.9%
fma-define99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification92.5%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (* x_m (* z y))) (t_1 (* x_m (- z))))
(*
x_s
(if (<= z -1.4e+38)
t_1
(if (<= z -1.35e-19)
t_0
(if (<= z -2.4e-78)
x_m
(if (<= z -1.2e-92) t_0 (if (<= z 1.0) x_m t_1))))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double t_0 = x_m * (z * y);
double t_1 = x_m * -z;
double tmp;
if (z <= -1.4e+38) {
tmp = t_1;
} else if (z <= -1.35e-19) {
tmp = t_0;
} else if (z <= -2.4e-78) {
tmp = x_m;
} else if (z <= -1.2e-92) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x_m;
} else {
tmp = t_1;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x_m * (z * y)
t_1 = x_m * -z
if (z <= (-1.4d+38)) then
tmp = t_1
else if (z <= (-1.35d-19)) then
tmp = t_0
else if (z <= (-2.4d-78)) then
tmp = x_m
else if (z <= (-1.2d-92)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x_m
else
tmp = t_1
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double t_0 = x_m * (z * y);
double t_1 = x_m * -z;
double tmp;
if (z <= -1.4e+38) {
tmp = t_1;
} else if (z <= -1.35e-19) {
tmp = t_0;
} else if (z <= -2.4e-78) {
tmp = x_m;
} else if (z <= -1.2e-92) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x_m;
} else {
tmp = t_1;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): t_0 = x_m * (z * y) t_1 = x_m * -z tmp = 0 if z <= -1.4e+38: tmp = t_1 elif z <= -1.35e-19: tmp = t_0 elif z <= -2.4e-78: tmp = x_m elif z <= -1.2e-92: tmp = t_0 elif z <= 1.0: tmp = x_m else: tmp = t_1 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) t_0 = Float64(x_m * Float64(z * y)) t_1 = Float64(x_m * Float64(-z)) tmp = 0.0 if (z <= -1.4e+38) tmp = t_1; elseif (z <= -1.35e-19) tmp = t_0; elseif (z <= -2.4e-78) tmp = x_m; elseif (z <= -1.2e-92) tmp = t_0; elseif (z <= 1.0) tmp = x_m; else tmp = t_1; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) t_0 = x_m * (z * y); t_1 = x_m * -z; tmp = 0.0; if (z <= -1.4e+38) tmp = t_1; elseif (z <= -1.35e-19) tmp = t_0; elseif (z <= -2.4e-78) tmp = x_m; elseif (z <= -1.2e-92) tmp = t_0; elseif (z <= 1.0) tmp = x_m; else tmp = t_1; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := Block[{t$95$0 = N[(x$95$m * N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$95$m * (-z)), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -1.4e+38], t$95$1, If[LessEqual[z, -1.35e-19], t$95$0, If[LessEqual[z, -2.4e-78], x$95$m, If[LessEqual[z, -1.2e-92], t$95$0, If[LessEqual[z, 1.0], x$95$m, t$95$1]]]]]), $MachinePrecision]]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := x\_m \cdot \left(z \cdot y\right)\\
t_1 := x\_m \cdot \left(-z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{-78}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq -1.2 \cdot 10^{-92}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if z < -1.4e38 or 1 < z Initial program 88.6%
Taylor expanded in y around 0 58.8%
sub-neg58.8%
distribute-rgt-in58.8%
*-un-lft-identity58.8%
Applied egg-rr58.8%
Taylor expanded in z around inf 58.2%
associate-*r*58.2%
mul-1-neg58.2%
Simplified58.2%
if -1.4e38 < z < -1.35e-19 or -2.4e-78 < z < -1.2000000000000001e-92Initial program 95.3%
Taylor expanded in y around inf 64.3%
*-commutative64.3%
Simplified64.3%
if -1.35e-19 < z < -2.4e-78 or -1.2000000000000001e-92 < z < 1Initial program 99.9%
Taylor expanded in z around 0 84.7%
Final simplification71.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* z (- 1.0 y)) 1e+305)
(* x_m (+ 1.0 (* z (+ y -1.0))))
(* y (* x_m z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * (1.0 - y)) <= 1e+305) {
tmp = x_m * (1.0 + (z * (y + -1.0)));
} else {
tmp = y * (x_m * z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * (1.0d0 - y)) <= 1d+305) then
tmp = x_m * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = y * (x_m * z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * (1.0 - y)) <= 1e+305) {
tmp = x_m * (1.0 + (z * (y + -1.0)));
} else {
tmp = y * (x_m * z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (z * (1.0 - y)) <= 1e+305: tmp = x_m * (1.0 + (z * (y + -1.0))) else: tmp = y * (x_m * z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(z * Float64(1.0 - y)) <= 1e+305) tmp = Float64(x_m * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(y * Float64(x_m * z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((z * (1.0 - y)) <= 1e+305) tmp = x_m * (1.0 + (z * (y + -1.0))); else tmp = y * (x_m * z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 1e+305], N[(x$95$m * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x$95$m * z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot \left(1 - y\right) \leq 10^{+305}:\\
\;\;\;\;x\_m \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x\_m \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.9999999999999994e304Initial program 99.1%
if 9.9999999999999994e304 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 48.9%
Taylor expanded in y around inf 90.7%
Taylor expanded in y around inf 99.8%
Final simplification99.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.05) (not (<= z 1.0)))
(* z (* x_m (+ y -1.0)))
(* x_m (+ 1.0 (* z y))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = z * (x_m * (y + -1.0));
} else {
tmp = x_m * (1.0 + (z * y));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.05d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x_m * (y + (-1.0d0)))
else
tmp = x_m * (1.0d0 + (z * y))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = z * (x_m * (y + -1.0));
} else {
tmp = x_m * (1.0 + (z * y));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.05) or not (z <= 1.0): tmp = z * (x_m * (y + -1.0)) else: tmp = x_m * (1.0 + (z * y)) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.05) || !(z <= 1.0)) tmp = Float64(z * Float64(x_m * Float64(y + -1.0))); else tmp = Float64(x_m * Float64(1.0 + Float64(z * y))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((z <= -1.05) || ~((z <= 1.0))) tmp = z * (x_m * (y + -1.0)); else tmp = x_m * (1.0 + (z * y)); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.05], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x$95$m * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.05 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x\_m \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 1 < z Initial program 88.9%
Taylor expanded in z around inf 87.0%
*-commutative87.0%
associate-*r*97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
if -1.05000000000000004 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.7%
*-commutative98.7%
Simplified98.7%
*-commutative98.7%
distribute-rgt1-in98.7%
Applied egg-rr98.7%
Final simplification98.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.35e-60)
(* z (+ (/ x_m z) (* x_m (+ y -1.0))))
(* x_m (+ 1.0 (* z (+ y -1.0)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.35e-60) {
tmp = z * ((x_m / z) + (x_m * (y + -1.0)));
} else {
tmp = x_m * (1.0 + (z * (y + -1.0)));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1.35d-60) then
tmp = z * ((x_m / z) + (x_m * (y + (-1.0d0))))
else
tmp = x_m * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.35e-60) {
tmp = z * ((x_m / z) + (x_m * (y + -1.0)));
} else {
tmp = x_m * (1.0 + (z * (y + -1.0)));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1.35e-60: tmp = z * ((x_m / z) + (x_m * (y + -1.0))) else: tmp = x_m * (1.0 + (z * (y + -1.0))) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.35e-60) tmp = Float64(z * Float64(Float64(x_m / z) + Float64(x_m * Float64(y + -1.0)))); else tmp = Float64(x_m * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1.35e-60) tmp = z * ((x_m / z) + (x_m * (y + -1.0))); else tmp = x_m * (1.0 + (z * (y + -1.0))); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.35e-60], N[(z * N[(N[(x$95$m / z), $MachinePrecision] + N[(x$95$m * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.35 \cdot 10^{-60}:\\
\;\;\;\;z \cdot \left(\frac{x\_m}{z} + x\_m \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if x < 1.35e-60Initial program 92.7%
Taylor expanded in z around inf 89.4%
if 1.35e-60 < x Initial program 99.9%
Final simplification92.5%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= y -1.9e+142) (not (<= y 1.42e+16)))
(* x_m (* z y))
(* x_m (- 1.0 z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y <= -1.9e+142) || !(y <= 1.42e+16)) {
tmp = x_m * (z * y);
} else {
tmp = x_m * (1.0 - z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.9d+142)) .or. (.not. (y <= 1.42d+16))) then
tmp = x_m * (z * y)
else
tmp = x_m * (1.0d0 - z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y <= -1.9e+142) || !(y <= 1.42e+16)) {
tmp = x_m * (z * y);
} else {
tmp = x_m * (1.0 - z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (y <= -1.9e+142) or not (y <= 1.42e+16): tmp = x_m * (z * y) else: tmp = x_m * (1.0 - z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((y <= -1.9e+142) || !(y <= 1.42e+16)) tmp = Float64(x_m * Float64(z * y)); else tmp = Float64(x_m * Float64(1.0 - z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((y <= -1.9e+142) || ~((y <= 1.42e+16))) tmp = x_m * (z * y); else tmp = x_m * (1.0 - z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -1.9e+142], N[Not[LessEqual[y, 1.42e+16]], $MachinePrecision]], N[(x$95$m * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+142} \lor \neg \left(y \leq 1.42 \cdot 10^{+16}\right):\\
\;\;\;\;x\_m \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.89999999999999995e142 or 1.42e16 < y Initial program 85.9%
Taylor expanded in y around inf 72.0%
*-commutative72.0%
Simplified72.0%
if -1.89999999999999995e142 < y < 1.42e16Initial program 99.4%
Taylor expanded in y around 0 94.8%
Final simplification86.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= y -7e+75) (not (<= y 1.25e+16)))
(* y (* x_m z))
(* x_m (- 1.0 z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y <= -7e+75) || !(y <= 1.25e+16)) {
tmp = y * (x_m * z);
} else {
tmp = x_m * (1.0 - z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-7d+75)) .or. (.not. (y <= 1.25d+16))) then
tmp = y * (x_m * z)
else
tmp = x_m * (1.0d0 - z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y <= -7e+75) || !(y <= 1.25e+16)) {
tmp = y * (x_m * z);
} else {
tmp = x_m * (1.0 - z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (y <= -7e+75) or not (y <= 1.25e+16): tmp = y * (x_m * z) else: tmp = x_m * (1.0 - z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((y <= -7e+75) || !(y <= 1.25e+16)) tmp = Float64(y * Float64(x_m * z)); else tmp = Float64(x_m * Float64(1.0 - z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((y <= -7e+75) || ~((y <= 1.25e+16))) tmp = y * (x_m * z); else tmp = x_m * (1.0 - z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -7e+75], N[Not[LessEqual[y, 1.25e+16]], $MachinePrecision]], N[(y * N[(x$95$m * z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+75} \lor \neg \left(y \leq 1.25 \cdot 10^{+16}\right):\\
\;\;\;\;y \cdot \left(x\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -6.9999999999999997e75 or 1.25e16 < y Initial program 85.9%
Taylor expanded in y around inf 84.6%
Taylor expanded in y around inf 80.3%
if -6.9999999999999997e75 < y < 1.25e16Initial program 100.0%
Taylor expanded in y around 0 96.3%
Final simplification90.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -1.45e+78)
(* z (* x_m y))
(if (<= y 1.42e+16) (* x_m (- 1.0 z)) (* y (* x_m z))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -1.45e+78) {
tmp = z * (x_m * y);
} else if (y <= 1.42e+16) {
tmp = x_m * (1.0 - z);
} else {
tmp = y * (x_m * z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.45d+78)) then
tmp = z * (x_m * y)
else if (y <= 1.42d+16) then
tmp = x_m * (1.0d0 - z)
else
tmp = y * (x_m * z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -1.45e+78) {
tmp = z * (x_m * y);
} else if (y <= 1.42e+16) {
tmp = x_m * (1.0 - z);
} else {
tmp = y * (x_m * z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if y <= -1.45e+78: tmp = z * (x_m * y) elif y <= 1.42e+16: tmp = x_m * (1.0 - z) else: tmp = y * (x_m * z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -1.45e+78) tmp = Float64(z * Float64(x_m * y)); elseif (y <= 1.42e+16) tmp = Float64(x_m * Float64(1.0 - z)); else tmp = Float64(y * Float64(x_m * z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (y <= -1.45e+78) tmp = z * (x_m * y); elseif (y <= 1.42e+16) tmp = x_m * (1.0 - z); else tmp = y * (x_m * z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -1.45e+78], N[(z * N[(x$95$m * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.42e+16], N[(x$95$m * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x$95$m * z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+78}:\\
\;\;\;\;z \cdot \left(x\_m \cdot y\right)\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+16}:\\
\;\;\;\;x\_m \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x\_m \cdot z\right)\\
\end{array}
\end{array}
if y < -1.45000000000000008e78Initial program 87.0%
Taylor expanded in z around 0 87.0%
Taylor expanded in y around inf 87.0%
*-commutative87.0%
Simplified87.0%
+-commutative87.0%
associate-*r*93.3%
fma-define93.4%
Applied egg-rr93.4%
Taylor expanded in z around inf 71.6%
associate-*r*78.0%
*-commutative78.0%
Simplified78.0%
if -1.45000000000000008e78 < y < 1.42e16Initial program 100.0%
Taylor expanded in y around 0 96.3%
if 1.42e16 < y Initial program 85.0%
Taylor expanded in y around inf 84.5%
Taylor expanded in y around inf 82.5%
Final simplification90.4%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -1.0) (not (<= z 1.0))) (* x_m (- z)) x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x_m * -z;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x_m * -z
else
tmp = x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x_m * -z;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x_m * -z else: tmp = x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(x_m * Float64(-z)); else tmp = x_m; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = x_m * -z; else tmp = x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x$95$m * (-z)), $MachinePrecision], x$95$m]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x\_m \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 88.9%
Taylor expanded in y around 0 57.2%
sub-neg57.2%
distribute-rgt-in57.2%
*-un-lft-identity57.2%
Applied egg-rr57.2%
Taylor expanded in z around inf 55.5%
associate-*r*55.5%
mul-1-neg55.5%
Simplified55.5%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 79.0%
Final simplification68.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * x_m
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * x_m
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * x_m) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * x_m; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot x\_m
\end{array}
Initial program 94.8%
Taylor expanded in z around 0 44.0%
Final simplification44.0%
(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 2024066
(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))))