
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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 * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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 * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\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 5e+16)
(/ (+ (* x_m y) (* x_m (- 1.0 z))) z)
(* (+ 1.0 (- y z)) (/ 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 (x_m <= 5e+16) {
tmp = ((x_m * y) + (x_m * (1.0 - z))) / z;
} else {
tmp = (1.0 + (y - z)) * (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 (x_m <= 5d+16) then
tmp = ((x_m * y) + (x_m * (1.0d0 - z))) / z
else
tmp = (1.0d0 + (y - z)) * (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 (x_m <= 5e+16) {
tmp = ((x_m * y) + (x_m * (1.0 - z))) / z;
} else {
tmp = (1.0 + (y - z)) * (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 x_m <= 5e+16: tmp = ((x_m * y) + (x_m * (1.0 - z))) / z else: tmp = (1.0 + (y - z)) * (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 (x_m <= 5e+16) tmp = Float64(Float64(Float64(x_m * y) + Float64(x_m * Float64(1.0 - z))) / z); else tmp = Float64(Float64(1.0 + Float64(y - z)) * 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 (x_m <= 5e+16) tmp = ((x_m * y) + (x_m * (1.0 - z))) / z; else tmp = (1.0 + (y - z)) * (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[x$95$m, 5e+16], N[(N[(N[(x$95$m * y), $MachinePrecision] + N[(x$95$m * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision] * 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}\;x\_m \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m \cdot y + x\_m \cdot \left(1 - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(y - z\right)\right) \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if x < 5e16Initial program 93.3%
Taylor expanded in y around 0 93.3%
if 5e16 < x Initial program 72.3%
*-commutative72.3%
associate-/l*99.8%
+-commutative99.8%
Applied egg-rr99.8%
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 -3.4e-10)
(- x_m)
(if (<= z 1.0)
(/ x_m z)
(if (or (<= z 1.1e+155) (not (<= z 2.3e+174)))
(- x_m)
(* x_m (/ y 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 <= -3.4e-10) {
tmp = -x_m;
} else if (z <= 1.0) {
tmp = x_m / z;
} else if ((z <= 1.1e+155) || !(z <= 2.3e+174)) {
tmp = -x_m;
} else {
tmp = x_m * (y / 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 <= (-3.4d-10)) then
tmp = -x_m
else if (z <= 1.0d0) then
tmp = x_m / z
else if ((z <= 1.1d+155) .or. (.not. (z <= 2.3d+174))) then
tmp = -x_m
else
tmp = x_m * (y / 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 <= -3.4e-10) {
tmp = -x_m;
} else if (z <= 1.0) {
tmp = x_m / z;
} else if ((z <= 1.1e+155) || !(z <= 2.3e+174)) {
tmp = -x_m;
} else {
tmp = x_m * (y / 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 <= -3.4e-10: tmp = -x_m elif z <= 1.0: tmp = x_m / z elif (z <= 1.1e+155) or not (z <= 2.3e+174): tmp = -x_m else: tmp = x_m * (y / 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 (z <= -3.4e-10) tmp = Float64(-x_m); elseif (z <= 1.0) tmp = Float64(x_m / z); elseif ((z <= 1.1e+155) || !(z <= 2.3e+174)) tmp = Float64(-x_m); else tmp = Float64(x_m * Float64(y / 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 <= -3.4e-10) tmp = -x_m; elseif (z <= 1.0) tmp = x_m / z; elseif ((z <= 1.1e+155) || ~((z <= 2.3e+174))) tmp = -x_m; else tmp = x_m * (y / 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[z, -3.4e-10], (-x$95$m), If[LessEqual[z, 1.0], N[(x$95$m / z), $MachinePrecision], If[Or[LessEqual[z, 1.1e+155], N[Not[LessEqual[z, 2.3e+174]], $MachinePrecision]], (-x$95$m), N[(x$95$m * N[(y / 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 \leq -3.4 \cdot 10^{-10}:\\
\;\;\;\;-x\_m\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x\_m}{z}\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+155} \lor \neg \left(z \leq 2.3 \cdot 10^{+174}\right):\\
\;\;\;\;-x\_m\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if z < -3.40000000000000015e-10 or 1 < z < 1.1000000000000001e155 or 2.2999999999999998e174 < z Initial program 75.2%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 76.9%
neg-mul-176.9%
Simplified76.9%
if -3.40000000000000015e-10 < z < 1Initial program 99.9%
associate-/l*95.3%
+-commutative95.3%
associate-+r-95.3%
div-sub95.3%
*-inverses95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
Simplified95.3%
Taylor expanded in y around 0 65.1%
sub-neg65.1%
metadata-eval65.1%
distribute-rgt-in65.1%
associate-*l/65.3%
*-lft-identity65.3%
neg-mul-165.3%
unsub-neg65.3%
Simplified65.3%
Taylor expanded in z around 0 63.6%
if 1.1000000000000001e155 < z < 2.2999999999999998e174Initial program 76.2%
associate-/l*99.2%
+-commutative99.2%
associate-+r-99.2%
div-sub99.4%
*-inverses99.4%
sub-neg99.4%
metadata-eval99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in y around inf 61.1%
associate-/l*83.9%
Simplified83.9%
Final simplification70.6%
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.05e+54) (not (<= y 1.4e+92)))
(/ x_m (/ z y))
(- (/ 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 ((y <= -1.05e+54) || !(y <= 1.4e+92)) {
tmp = x_m / (z / y);
} else {
tmp = (x_m / z) - 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 ((y <= (-1.05d+54)) .or. (.not. (y <= 1.4d+92))) then
tmp = x_m / (z / y)
else
tmp = (x_m / z) - 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 ((y <= -1.05e+54) || !(y <= 1.4e+92)) {
tmp = x_m / (z / y);
} else {
tmp = (x_m / z) - 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 (y <= -1.05e+54) or not (y <= 1.4e+92): tmp = x_m / (z / y) else: tmp = (x_m / z) - 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 ((y <= -1.05e+54) || !(y <= 1.4e+92)) tmp = Float64(x_m / Float64(z / y)); else tmp = Float64(Float64(x_m / z) - 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 ((y <= -1.05e+54) || ~((y <= 1.4e+92))) tmp = x_m / (z / y); else tmp = (x_m / z) - 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[y, -1.05e+54], N[Not[LessEqual[y, 1.4e+92]], $MachinePrecision]], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $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}\;y \leq -1.05 \cdot 10^{+54} \lor \neg \left(y \leq 1.4 \cdot 10^{+92}\right):\\
\;\;\;\;\frac{x\_m}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{z} - x\_m\\
\end{array}
\end{array}
if y < -1.04999999999999993e54 or 1.4e92 < y Initial program 89.3%
*-commutative89.3%
associate-/l*82.7%
+-commutative82.7%
Applied egg-rr82.7%
clear-num82.6%
un-div-inv82.6%
associate-+r-82.6%
Applied egg-rr82.6%
Taylor expanded in y around inf 78.6%
associate-*l/78.4%
associate-/r/80.5%
Simplified80.5%
if -1.04999999999999993e54 < y < 1.4e92Initial program 86.5%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 94.2%
sub-neg94.2%
metadata-eval94.2%
distribute-rgt-in94.3%
associate-*l/94.4%
*-lft-identity94.4%
neg-mul-194.4%
unsub-neg94.4%
Simplified94.4%
Final simplification89.6%
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.22e+54) (not (<= y 1.5e+92)))
(* x_m (/ y z))
(- (/ 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 ((y <= -1.22e+54) || !(y <= 1.5e+92)) {
tmp = x_m * (y / z);
} else {
tmp = (x_m / z) - 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 ((y <= (-1.22d+54)) .or. (.not. (y <= 1.5d+92))) then
tmp = x_m * (y / z)
else
tmp = (x_m / z) - 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 ((y <= -1.22e+54) || !(y <= 1.5e+92)) {
tmp = x_m * (y / z);
} else {
tmp = (x_m / z) - 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 (y <= -1.22e+54) or not (y <= 1.5e+92): tmp = x_m * (y / z) else: tmp = (x_m / z) - 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 ((y <= -1.22e+54) || !(y <= 1.5e+92)) tmp = Float64(x_m * Float64(y / z)); else tmp = Float64(Float64(x_m / z) - 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 ((y <= -1.22e+54) || ~((y <= 1.5e+92))) tmp = x_m * (y / z); else tmp = (x_m / z) - 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[y, -1.22e+54], N[Not[LessEqual[y, 1.5e+92]], $MachinePrecision]], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $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}\;y \leq -1.22 \cdot 10^{+54} \lor \neg \left(y \leq 1.5 \cdot 10^{+92}\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{z} - x\_m\\
\end{array}
\end{array}
if y < -1.22e54 or 1.50000000000000007e92 < y Initial program 89.3%
associate-/l*93.3%
+-commutative93.3%
associate-+r-93.3%
div-sub93.3%
*-inverses93.3%
sub-neg93.3%
metadata-eval93.3%
+-commutative93.3%
Simplified93.3%
Taylor expanded in y around inf 78.6%
associate-/l*80.4%
Simplified80.4%
if -1.22e54 < y < 1.50000000000000007e92Initial program 86.5%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 94.2%
sub-neg94.2%
metadata-eval94.2%
distribute-rgt-in94.3%
associate-*l/94.4%
*-lft-identity94.4%
neg-mul-194.4%
unsub-neg94.4%
Simplified94.4%
Final simplification89.6%
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.35e+54)
(/ x_m (/ z y))
(if (<= y 1.4e+92) (- (/ x_m z) x_m) (/ (* x_m y) 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.35e+54) {
tmp = x_m / (z / y);
} else if (y <= 1.4e+92) {
tmp = (x_m / z) - x_m;
} else {
tmp = (x_m * y) / 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.35d+54)) then
tmp = x_m / (z / y)
else if (y <= 1.4d+92) then
tmp = (x_m / z) - x_m
else
tmp = (x_m * y) / 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.35e+54) {
tmp = x_m / (z / y);
} else if (y <= 1.4e+92) {
tmp = (x_m / z) - x_m;
} else {
tmp = (x_m * y) / 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.35e+54: tmp = x_m / (z / y) elif y <= 1.4e+92: tmp = (x_m / z) - x_m else: tmp = (x_m * y) / 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.35e+54) tmp = Float64(x_m / Float64(z / y)); elseif (y <= 1.4e+92) tmp = Float64(Float64(x_m / z) - x_m); else tmp = Float64(Float64(x_m * y) / 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.35e+54) tmp = x_m / (z / y); elseif (y <= 1.4e+92) tmp = (x_m / z) - x_m; else tmp = (x_m * y) / 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.35e+54], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+92], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision], N[(N[(x$95$m * y), $MachinePrecision] / z), $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.35 \cdot 10^{+54}:\\
\;\;\;\;\frac{x\_m}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+92}:\\
\;\;\;\;\frac{x\_m}{z} - x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\end{array}
\end{array}
if y < -1.35000000000000005e54Initial program 89.1%
*-commutative89.1%
associate-/l*83.3%
+-commutative83.3%
Applied egg-rr83.3%
clear-num83.2%
un-div-inv83.1%
associate-+r-83.1%
Applied egg-rr83.1%
Taylor expanded in y around inf 80.0%
associate-*l/79.5%
associate-/r/85.2%
Simplified85.2%
if -1.35000000000000005e54 < y < 1.4e92Initial program 86.5%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 94.2%
sub-neg94.2%
metadata-eval94.2%
distribute-rgt-in94.3%
associate-*l/94.4%
*-lft-identity94.4%
neg-mul-194.4%
unsub-neg94.4%
Simplified94.4%
if 1.4e92 < y Initial program 89.6%
associate-/l*89.4%
+-commutative89.4%
associate-+r-89.4%
div-sub89.4%
*-inverses89.4%
sub-neg89.4%
metadata-eval89.4%
+-commutative89.4%
Simplified89.4%
Taylor expanded in y around inf 76.6%
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 (+ 1.0 (- y z)))) (* x_s (if (<= x_m 5e+16) (/ (* x_m t_0) z) (* t_0 (/ 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 t_0 = 1.0 + (y - z);
double tmp;
if (x_m <= 5e+16) {
tmp = (x_m * t_0) / z;
} else {
tmp = t_0 * (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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (y - z)
if (x_m <= 5d+16) then
tmp = (x_m * t_0) / z
else
tmp = t_0 * (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 t_0 = 1.0 + (y - z);
double tmp;
if (x_m <= 5e+16) {
tmp = (x_m * t_0) / z;
} else {
tmp = t_0 * (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): t_0 = 1.0 + (y - z) tmp = 0 if x_m <= 5e+16: tmp = (x_m * t_0) / z else: tmp = t_0 * (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) t_0 = Float64(1.0 + Float64(y - z)) tmp = 0.0 if (x_m <= 5e+16) tmp = Float64(Float64(x_m * t_0) / z); else tmp = Float64(t_0 * 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) t_0 = 1.0 + (y - z); tmp = 0.0; if (x_m <= 5e+16) tmp = (x_m * t_0) / z; else tmp = t_0 * (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_] := Block[{t$95$0 = N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[x$95$m, 5e+16], N[(N[(x$95$m * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(t$95$0 * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := 1 + \left(y - z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
\end{array}
if x < 5e16Initial program 93.3%
if 5e16 < x Initial program 72.3%
*-commutative72.3%
associate-/l*99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification95.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 -3.4e-10) (not (<= z 1.0))) (- x_m) (/ 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 <= -3.4e-10) || !(z <= 1.0)) {
tmp = -x_m;
} else {
tmp = 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 <= (-3.4d-10)) .or. (.not. (z <= 1.0d0))) then
tmp = -x_m
else
tmp = 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 <= -3.4e-10) || !(z <= 1.0)) {
tmp = -x_m;
} else {
tmp = 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 <= -3.4e-10) or not (z <= 1.0): tmp = -x_m else: tmp = 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 ((z <= -3.4e-10) || !(z <= 1.0)) tmp = Float64(-x_m); else tmp = 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 <= -3.4e-10) || ~((z <= 1.0))) tmp = -x_m; else tmp = 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[Or[LessEqual[z, -3.4e-10], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x$95$m), N[(x$95$m / z), $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 -3.4 \cdot 10^{-10} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{z}\\
\end{array}
\end{array}
if z < -3.40000000000000015e-10 or 1 < z Initial program 75.3%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 73.2%
neg-mul-173.2%
Simplified73.2%
if -3.40000000000000015e-10 < z < 1Initial program 99.9%
associate-/l*95.3%
+-commutative95.3%
associate-+r-95.3%
div-sub95.3%
*-inverses95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
Simplified95.3%
Taylor expanded in y around 0 65.1%
sub-neg65.1%
metadata-eval65.1%
distribute-rgt-in65.1%
associate-*l/65.3%
*-lft-identity65.3%
neg-mul-165.3%
unsub-neg65.3%
Simplified65.3%
Taylor expanded in z around 0 63.6%
Final simplification68.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 (* x_m (+ (/ (+ y 1.0) z) -1.0))))
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 * (((y + 1.0) / z) + -1.0));
}
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 * (((y + 1.0d0) / z) + (-1.0d0)))
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 * (((y + 1.0) / z) + -1.0));
}
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 * (((y + 1.0) / z) + -1.0))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0))) 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 * (((y + 1.0) / z) + -1.0)); 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 * N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(\frac{y + 1}{z} + -1\right)\right)
\end{array}
Initial program 87.5%
associate-/l*97.6%
+-commutative97.6%
associate-+r-97.6%
div-sub97.6%
*-inverses97.6%
sub-neg97.6%
metadata-eval97.6%
+-commutative97.6%
Simplified97.6%
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 * Float64(-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 \left(-x\_m\right)
\end{array}
Initial program 87.5%
associate-/l*97.6%
+-commutative97.6%
associate-+r-97.6%
div-sub97.6%
*-inverses97.6%
sub-neg97.6%
metadata-eval97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in z around inf 38.4%
neg-mul-138.4%
Simplified38.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / 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 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024100
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))