
(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 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 2e-37)
(/ (* x_m (+ (- y z) 1.0)) z)
(* x_m (/ (+ y (- 1.0 z)) 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 <= 2e-37) {
tmp = (x_m * ((y - z) + 1.0)) / z;
} else {
tmp = x_m * ((y + (1.0 - z)) / 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 <= 2d-37) then
tmp = (x_m * ((y - z) + 1.0d0)) / z
else
tmp = x_m * ((y + (1.0d0 - z)) / 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 <= 2e-37) {
tmp = (x_m * ((y - z) + 1.0)) / z;
} else {
tmp = x_m * ((y + (1.0 - z)) / 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 <= 2e-37: tmp = (x_m * ((y - z) + 1.0)) / z else: tmp = x_m * ((y + (1.0 - z)) / 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 <= 2e-37) tmp = Float64(Float64(x_m * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(x_m * Float64(Float64(y + Float64(1.0 - z)) / 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 <= 2e-37) tmp = (x_m * ((y - z) + 1.0)) / z; else tmp = x_m * ((y + (1.0 - z)) / 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, 2e-37], N[(N[(x$95$m * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x$95$m * N[(N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / 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 2 \cdot 10^{-37}:\\
\;\;\;\;\frac{x_m \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m \cdot \frac{y + \left(1 - z\right)}{z}\\
\end{array}
\end{array}
if x < 2.00000000000000013e-37Initial program 93.3%
if 2.00000000000000013e-37 < x Initial program 79.1%
Taylor expanded in x around 0 79.1%
associate--l+79.1%
+-commutative79.1%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Final simplification95.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (- (/ x_m z) x_m)) (t_1 (/ (* x_m y) z)))
(*
x_s
(if (<= y -720000000000.0)
t_1
(if (<= y 1580000.0)
t_0
(if (<= y 3.2e+84)
(/ x_m (/ z (+ y 1.0)))
(if (<= y 5e+139) t_0 (if (<= y 4e+229) (* y (/ x_m z)) 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) - x_m;
double t_1 = (x_m * y) / z;
double tmp;
if (y <= -720000000000.0) {
tmp = t_1;
} else if (y <= 1580000.0) {
tmp = t_0;
} else if (y <= 3.2e+84) {
tmp = x_m / (z / (y + 1.0));
} else if (y <= 5e+139) {
tmp = t_0;
} else if (y <= 4e+229) {
tmp = y * (x_m / z);
} 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) - x_m
t_1 = (x_m * y) / z
if (y <= (-720000000000.0d0)) then
tmp = t_1
else if (y <= 1580000.0d0) then
tmp = t_0
else if (y <= 3.2d+84) then
tmp = x_m / (z / (y + 1.0d0))
else if (y <= 5d+139) then
tmp = t_0
else if (y <= 4d+229) then
tmp = y * (x_m / z)
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) - x_m;
double t_1 = (x_m * y) / z;
double tmp;
if (y <= -720000000000.0) {
tmp = t_1;
} else if (y <= 1580000.0) {
tmp = t_0;
} else if (y <= 3.2e+84) {
tmp = x_m / (z / (y + 1.0));
} else if (y <= 5e+139) {
tmp = t_0;
} else if (y <= 4e+229) {
tmp = y * (x_m / z);
} 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) - x_m t_1 = (x_m * y) / z tmp = 0 if y <= -720000000000.0: tmp = t_1 elif y <= 1580000.0: tmp = t_0 elif y <= 3.2e+84: tmp = x_m / (z / (y + 1.0)) elif y <= 5e+139: tmp = t_0 elif y <= 4e+229: tmp = y * (x_m / z) 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(Float64(x_m / z) - x_m) t_1 = Float64(Float64(x_m * y) / z) tmp = 0.0 if (y <= -720000000000.0) tmp = t_1; elseif (y <= 1580000.0) tmp = t_0; elseif (y <= 3.2e+84) tmp = Float64(x_m / Float64(z / Float64(y + 1.0))); elseif (y <= 5e+139) tmp = t_0; elseif (y <= 4e+229) tmp = Float64(y * Float64(x_m / z)); 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) - x_m; t_1 = (x_m * y) / z; tmp = 0.0; if (y <= -720000000000.0) tmp = t_1; elseif (y <= 1580000.0) tmp = t_0; elseif (y <= 3.2e+84) tmp = x_m / (z / (y + 1.0)); elseif (y <= 5e+139) tmp = t_0; elseif (y <= 4e+229) tmp = y * (x_m / z); 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[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -720000000000.0], t$95$1, If[LessEqual[y, 1580000.0], t$95$0, If[LessEqual[y, 3.2e+84], N[(x$95$m / N[(z / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+139], t$95$0, If[LessEqual[y, 4e+229], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], 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 := \frac{x_m}{z} - x_m\\
t_1 := \frac{x_m \cdot y}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -720000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1580000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+84}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y + 1}}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+229}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
\end{array}
if y < -7.2e11 or 4e229 < y Initial program 92.8%
Taylor expanded in y around inf 84.4%
if -7.2e11 < y < 1.58e6 or 3.2000000000000001e84 < y < 5.0000000000000003e139Initial program 87.3%
Taylor expanded in x around 0 87.3%
associate--l+87.3%
+-commutative87.3%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 85.8%
associate-*l/87.5%
sub-neg87.5%
distribute-rgt-in81.8%
*-lft-identity81.8%
distribute-lft-neg-out81.8%
unsub-neg81.8%
*-commutative81.8%
associate-*l/85.9%
associate-/l*98.6%
*-inverses98.6%
/-rgt-identity98.6%
Simplified98.6%
if 1.58e6 < y < 3.2000000000000001e84Initial program 94.6%
Taylor expanded in z around 0 73.7%
associate-/l*72.3%
Simplified72.3%
if 5.0000000000000003e139 < y < 4e229Initial program 84.7%
Taylor expanded in y around inf 79.7%
associate-/l*69.8%
associate-/r/84.7%
Simplified84.7%
Final simplification91.3%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (* y (/ x_m z))))
(*
x_s
(if (<= y -1.0)
t_0
(if (<= y 1.55e-90) (/ x_m z) (if (<= y 15500.0) (- x_m) t_0))))))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 = y * (x_m / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.55e-90) {
tmp = x_m / z;
} else if (y <= 15500.0) {
tmp = -x_m;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y * (x_m / z)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 1.55d-90) then
tmp = x_m / z
else if (y <= 15500.0d0) then
tmp = -x_m
else
tmp = t_0
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 = y * (x_m / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.55e-90) {
tmp = x_m / z;
} else if (y <= 15500.0) {
tmp = -x_m;
} else {
tmp = t_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): t_0 = y * (x_m / z) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 1.55e-90: tmp = x_m / z elif y <= 15500.0: tmp = -x_m else: tmp = t_0 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(y * Float64(x_m / z)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.55e-90) tmp = Float64(x_m / z); elseif (y <= 15500.0) tmp = Float64(-x_m); else tmp = t_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) t_0 = y * (x_m / z); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 1.55e-90) tmp = x_m / z; elseif (y <= 15500.0) tmp = -x_m; else tmp = t_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_] := Block[{t$95$0 = N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.55e-90], N[(x$95$m / z), $MachinePrecision], If[LessEqual[y, 15500.0], (-x$95$m), t$95$0]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := y \cdot \frac{x_m}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-90}:\\
\;\;\;\;\frac{x_m}{z}\\
\mathbf{elif}\;y \leq 15500:\\
\;\;\;\;-x_m\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
\end{array}
if y < -1 or 15500 < y Initial program 89.8%
Taylor expanded in y around inf 76.9%
associate-/l*71.8%
associate-/r/76.0%
Simplified76.0%
if -1 < y < 1.5500000000000001e-90Initial program 87.9%
Taylor expanded in y around 0 87.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 63.5%
if 1.5500000000000001e-90 < y < 15500Initial program 94.3%
Taylor expanded in z around inf 67.3%
mul-1-neg67.3%
Simplified67.3%
Final simplification70.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= y -265000000000.0) (not (<= y 3050000.0)))
(* y (/ x_m 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 <= -265000000000.0) || !(y <= 3050000.0)) {
tmp = y * (x_m / 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 <= (-265000000000.0d0)) .or. (.not. (y <= 3050000.0d0))) then
tmp = y * (x_m / 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 <= -265000000000.0) || !(y <= 3050000.0)) {
tmp = y * (x_m / 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 <= -265000000000.0) or not (y <= 3050000.0): tmp = y * (x_m / 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 <= -265000000000.0) || !(y <= 3050000.0)) tmp = Float64(y * Float64(x_m / 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 <= -265000000000.0) || ~((y <= 3050000.0))) tmp = y * (x_m / 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, -265000000000.0], N[Not[LessEqual[y, 3050000.0]], $MachinePrecision]], N[(y * N[(x$95$m / 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 -265000000000 \lor \neg \left(y \leq 3050000\right):\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\
\end{array}
\end{array}
if y < -2.65e11 or 3.05e6 < y Initial program 90.2%
Taylor expanded in y around inf 78.4%
associate-/l*73.2%
associate-/r/77.5%
Simplified77.5%
if -2.65e11 < y < 3.05e6Initial program 88.5%
Taylor expanded in x around 0 88.5%
associate--l+88.5%
+-commutative88.5%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 88.4%
associate-*l/89.4%
sub-neg89.4%
distribute-rgt-in84.1%
*-lft-identity84.1%
distribute-lft-neg-out84.1%
unsub-neg84.1%
*-commutative84.1%
associate-*l/88.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
Simplified99.9%
Final simplification88.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= y -255000000000.0) (not (<= y 2750000.0)))
(/ (* 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 <= -255000000000.0) || !(y <= 2750000.0)) {
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 <= (-255000000000.0d0)) .or. (.not. (y <= 2750000.0d0))) 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 <= -255000000000.0) || !(y <= 2750000.0)) {
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 <= -255000000000.0) or not (y <= 2750000.0): 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 <= -255000000000.0) || !(y <= 2750000.0)) tmp = Float64(Float64(x_m * 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 <= -255000000000.0) || ~((y <= 2750000.0))) 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, -255000000000.0], N[Not[LessEqual[y, 2750000.0]], $MachinePrecision]], N[(N[(x$95$m * y), $MachinePrecision] / z), $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 -255000000000 \lor \neg \left(y \leq 2750000\right):\\
\;\;\;\;\frac{x_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\
\end{array}
\end{array}
if y < -2.55e11 or 2.75e6 < y Initial program 90.2%
Taylor expanded in y around inf 78.4%
if -2.55e11 < y < 2.75e6Initial program 88.5%
Taylor expanded in x around 0 88.5%
associate--l+88.5%
+-commutative88.5%
associate-*r/99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around 0 88.4%
associate-*l/89.4%
sub-neg89.4%
distribute-rgt-in84.1%
*-lft-identity84.1%
distribute-lft-neg-out84.1%
unsub-neg84.1%
*-commutative84.1%
associate-*l/88.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
Simplified99.9%
Final simplification89.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -1.0) (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 <= -1.0) || !(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 <= (-1.0d0)) .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 <= -1.0) || !(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 <= -1.0) 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 <= -1.0) || !(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 <= -1.0) || ~((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, -1.0], 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 -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 74.0%
Taylor expanded in z around inf 72.2%
mul-1-neg72.2%
Simplified72.2%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around 0 57.6%
associate-/l*57.6%
Simplified57.6%
Taylor expanded in z around 0 57.2%
Final simplification63.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (* x_m (/ (+ y (- 1.0 z)) z))))
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)) / z));
}
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)) / z))
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)) / z));
}
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)) / z))
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(y + Float64(1.0 - z)) / z))) 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)) / z)); 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[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / z), $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 \frac{y + \left(1 - z\right)}{z}\right)
\end{array}
Initial program 89.3%
Taylor expanded in x around 0 89.3%
associate--l+89.3%
+-commutative89.3%
associate-*r/95.0%
associate-+l-95.0%
Simplified95.0%
Final simplification95.0%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 89.3%
Taylor expanded in z around inf 31.7%
mul-1-neg31.7%
Simplified31.7%
Final simplification31.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 89.3%
Taylor expanded in z around inf 22.9%
associate-*r*22.9%
mul-1-neg22.9%
Simplified22.9%
div-inv22.8%
associate-*l*31.6%
div-inv31.7%
*-inverses31.7%
*-commutative31.7%
*-un-lft-identity31.7%
neg-sub031.7%
sub-neg31.7%
add-sqr-sqrt14.6%
sqrt-unprod16.0%
sqr-neg16.0%
sqrt-unprod1.6%
add-sqr-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Final simplification3.1%
(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 2024011
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(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))