
(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 10 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 (+ (- y z) 1.0)) z) -1e+289)
(* x_m (+ (/ (+ y 1.0) z) -1.0))
(/ (fma x_m (- 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 * ((y - z) + 1.0)) / z) <= -1e+289) {
tmp = x_m * (((y + 1.0) / z) + -1.0);
} else {
tmp = fma(x_m, (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 (Float64(Float64(x_m * Float64(Float64(y - z) + 1.0)) / z) <= -1e+289) tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(fma(x_m, Float64(y - z), x_m) / z); 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[N[(N[(x$95$m * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], -1e+289], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * N[(y - z), $MachinePrecision] + x$95$m), $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}\;\frac{x_m \cdot \left(\left(y - z\right) + 1\right)}{z} \leq -1 \cdot 10^{+289}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x_m, y - z, x_m\right)}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -1.0000000000000001e289Initial program 74.8%
Taylor expanded in x around 0 74.8%
associate--l+74.8%
+-commutative74.8%
associate-*r/100.0%
+-commutative100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -1.0000000000000001e289 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 93.2%
distribute-lft-in93.2%
fma-def93.2%
*-rgt-identity93.2%
Simplified93.2%
Final simplification94.0%
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 (+ (- y z) 1.0)) z))) (* x_s (if (<= t_0 -1e+289) (* x_m (+ (/ (+ y 1.0) z) -1.0)) 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 = (x_m * ((y - z) + 1.0)) / z;
double tmp;
if (t_0 <= -1e+289) {
tmp = x_m * (((y + 1.0) / z) + -1.0);
} 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 = (x_m * ((y - z) + 1.0d0)) / z
if (t_0 <= (-1d+289)) then
tmp = x_m * (((y + 1.0d0) / z) + (-1.0d0))
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 = (x_m * ((y - z) + 1.0)) / z;
double tmp;
if (t_0 <= -1e+289) {
tmp = x_m * (((y + 1.0) / z) + -1.0);
} 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 = (x_m * ((y - z) + 1.0)) / z tmp = 0 if t_0 <= -1e+289: tmp = x_m * (((y + 1.0) / z) + -1.0) 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(Float64(x_m * Float64(Float64(y - z) + 1.0)) / z) tmp = 0.0 if (t_0 <= -1e+289) tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); 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 = (x_m * ((y - z) + 1.0)) / z; tmp = 0.0; if (t_0 <= -1e+289) tmp = x_m * (((y + 1.0) / z) + -1.0); 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[(N[(x$95$m * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -1e+289], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], 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 := \frac{x_m \cdot \left(\left(y - z\right) + 1\right)}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+289}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -1.0000000000000001e289Initial program 74.8%
Taylor expanded in x around 0 74.8%
associate--l+74.8%
+-commutative74.8%
associate-*r/100.0%
+-commutative100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -1.0000000000000001e289 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 93.2%
Final simplification94.0%
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 (+ -1.0 (/ y z)))))
(*
x_s
(if (<= y -7e+18)
t_0
(if (<= y 0.032)
(- (/ x_m z) x_m)
(if (<= y 5.1e+222) t_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 t_0 = x_m * (-1.0 + (y / z));
double tmp;
if (y <= -7e+18) {
tmp = t_0;
} else if (y <= 0.032) {
tmp = (x_m / z) - x_m;
} else if (y <= 5.1e+222) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x_m * ((-1.0d0) + (y / z))
if (y <= (-7d+18)) then
tmp = t_0
else if (y <= 0.032d0) then
tmp = (x_m / z) - x_m
else if (y <= 5.1d+222) then
tmp = t_0
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 t_0 = x_m * (-1.0 + (y / z));
double tmp;
if (y <= -7e+18) {
tmp = t_0;
} else if (y <= 0.032) {
tmp = (x_m / z) - x_m;
} else if (y <= 5.1e+222) {
tmp = t_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): t_0 = x_m * (-1.0 + (y / z)) tmp = 0 if y <= -7e+18: tmp = t_0 elif y <= 0.032: tmp = (x_m / z) - x_m elif y <= 5.1e+222: tmp = t_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) t_0 = Float64(x_m * Float64(-1.0 + Float64(y / z))) tmp = 0.0 if (y <= -7e+18) tmp = t_0; elseif (y <= 0.032) tmp = Float64(Float64(x_m / z) - x_m); elseif (y <= 5.1e+222) tmp = t_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) t_0 = x_m * (-1.0 + (y / z)); tmp = 0.0; if (y <= -7e+18) tmp = t_0; elseif (y <= 0.032) tmp = (x_m / z) - x_m; elseif (y <= 5.1e+222) tmp = t_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_] := Block[{t$95$0 = N[(x$95$m * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -7e+18], t$95$0, If[LessEqual[y, 0.032], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision], If[LessEqual[y, 5.1e+222], t$95$0, 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)
\\
\begin{array}{l}
t_0 := x_m \cdot \left(-1 + \frac{y}{z}\right)\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 0.032:\\
\;\;\;\;\frac{x_m}{z} - x_m\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+222}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\end{array}
\end{array}
\end{array}
if y < -7e18 or 0.032000000000000001 < y < 5.0999999999999999e222Initial program 89.6%
Taylor expanded in x around 0 89.6%
associate--l+89.6%
+-commutative89.6%
associate-*r/96.9%
+-commutative96.9%
associate--l+96.9%
div-sub96.9%
sub-neg96.9%
*-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in y around inf 95.7%
if -7e18 < y < 0.032000000000000001Initial program 91.7%
Taylor expanded in x around 0 91.7%
associate--l+91.7%
+-commutative91.7%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-in99.1%
associate-*l/99.2%
*-lft-identity99.2%
neg-mul-199.2%
unsub-neg99.2%
Simplified99.2%
if 5.0999999999999999e222 < y Initial program 93.2%
Taylor expanded in y around inf 92.9%
associate-/l*55.7%
associate-/r/93.2%
Simplified93.2%
Final simplification97.6%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.0)
(- x_m)
(if (<= z 2.2e-137)
(/ x_m z)
(if (<= z 5300000000000.0) (* 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 (z <= -1.0) {
tmp = -x_m;
} else if (z <= 2.2e-137) {
tmp = x_m / z;
} else if (z <= 5300000000000.0) {
tmp = y * (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)) then
tmp = -x_m
else if (z <= 2.2d-137) then
tmp = x_m / z
else if (z <= 5300000000000.0d0) then
tmp = y * (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) {
tmp = -x_m;
} else if (z <= 2.2e-137) {
tmp = x_m / z;
} else if (z <= 5300000000000.0) {
tmp = y * (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: tmp = -x_m elif z <= 2.2e-137: tmp = x_m / z elif z <= 5300000000000.0: tmp = y * (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) tmp = Float64(-x_m); elseif (z <= 2.2e-137) tmp = Float64(x_m / z); elseif (z <= 5300000000000.0) tmp = Float64(y * Float64(x_m / z)); else tmp = Float64(-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) tmp = -x_m; elseif (z <= 2.2e-137) tmp = x_m / z; elseif (z <= 5300000000000.0) tmp = y * (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[LessEqual[z, -1.0], (-x$95$m), If[LessEqual[z, 2.2e-137], N[(x$95$m / z), $MachinePrecision], If[LessEqual[z, 5300000000000.0], N[(y * N[(x$95$m / z), $MachinePrecision]), $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:\\
\;\;\;\;-x_m\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-137}:\\
\;\;\;\;\frac{x_m}{z}\\
\mathbf{elif}\;z \leq 5300000000000:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;-x_m\\
\end{array}
\end{array}
if z < -1 or 5.3e12 < z Initial program 80.8%
Taylor expanded in z around inf 80.9%
mul-1-neg80.9%
Simplified80.9%
if -1 < z < 2.2000000000000001e-137Initial program 99.9%
Taylor expanded in y around 0 67.3%
Taylor expanded in z around 0 65.7%
if 2.2000000000000001e-137 < z < 5.3e12Initial program 99.7%
Taylor expanded in y around inf 57.6%
associate-/l*51.1%
associate-/r/62.2%
Simplified62.2%
Final simplification72.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 (<= z -0.97) (not (<= z 1.0)))
(* x_m (+ -1.0 (/ y 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 ((z <= -0.97) || !(z <= 1.0)) {
tmp = x_m * (-1.0 + (y / z));
} else {
tmp = (x_m + (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 <= (-0.97d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x_m * ((-1.0d0) + (y / z))
else
tmp = (x_m + (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 <= -0.97) || !(z <= 1.0)) {
tmp = x_m * (-1.0 + (y / z));
} else {
tmp = (x_m + (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 <= -0.97) or not (z <= 1.0): tmp = x_m * (-1.0 + (y / z)) else: tmp = (x_m + (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 <= -0.97) || !(z <= 1.0)) tmp = Float64(x_m * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x_m + 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 ((z <= -0.97) || ~((z <= 1.0))) tmp = x_m * (-1.0 + (y / z)); else tmp = (x_m + (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[Or[LessEqual[z, -0.97], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x$95$m * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m + N[(x$95$m * y), $MachinePrecision]), $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}\;z \leq -0.97 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x_m \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m + x_m \cdot y}{z}\\
\end{array}
\end{array}
if z < -0.96999999999999997 or 1 < z Initial program 81.4%
Taylor expanded in x around 0 81.4%
associate--l+81.4%
+-commutative81.4%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.8%
if -0.96999999999999997 < z < 1Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 96.4%
Final simplification97.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y 2.2e+223) (* x_m (+ (/ (+ y 1.0) z) -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 (y <= 2.2e+223) {
tmp = x_m * (((y + 1.0) / z) + -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 (y <= 2.2d+223) then
tmp = x_m * (((y + 1.0d0) / z) + (-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 (y <= 2.2e+223) {
tmp = x_m * (((y + 1.0) / z) + -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 y <= 2.2e+223: tmp = x_m * (((y + 1.0) / z) + -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 (y <= 2.2e+223) tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -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 (y <= 2.2e+223) tmp = x_m * (((y + 1.0) / z) + -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[y, 2.2e+223], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $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 2.2 \cdot 10^{+223}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\end{array}
\end{array}
if y < 2.2e223Initial program 90.9%
Taylor expanded in x around 0 90.9%
associate--l+90.9%
+-commutative90.9%
associate-*r/98.7%
+-commutative98.7%
associate--l+98.7%
div-sub98.7%
sub-neg98.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
if 2.2e223 < y Initial program 93.2%
Taylor expanded in y around inf 92.9%
associate-/l*55.7%
associate-/r/93.2%
Simplified93.2%
Final simplification98.4%
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 -3.9e+62) (not (<= y 1.26e+32)))
(/ (* 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 <= -3.9e+62) || !(y <= 1.26e+32)) {
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 <= (-3.9d+62)) .or. (.not. (y <= 1.26d+32))) 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 <= -3.9e+62) || !(y <= 1.26e+32)) {
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 <= -3.9e+62) or not (y <= 1.26e+32): 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 <= -3.9e+62) || !(y <= 1.26e+32)) 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 <= -3.9e+62) || ~((y <= 1.26e+32))) 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, -3.9e+62], N[Not[LessEqual[y, 1.26e+32]], $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 -3.9 \cdot 10^{+62} \lor \neg \left(y \leq 1.26 \cdot 10^{+32}\right):\\
\;\;\;\;\frac{x_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\
\end{array}
\end{array}
if y < -3.9e62 or 1.26e32 < y Initial program 89.9%
Taylor expanded in y around inf 79.2%
if -3.9e62 < y < 1.26e32Initial program 91.8%
Taylor expanded in x around 0 91.7%
associate--l+91.8%
+-commutative91.8%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 96.3%
sub-neg96.3%
metadata-eval96.3%
distribute-rgt-in96.3%
associate-*l/96.4%
*-lft-identity96.4%
neg-mul-196.4%
unsub-neg96.4%
Simplified96.4%
Final simplification90.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -1.95e+62)
(* x_m (/ y z))
(if (<= y 4.8e+31) (- (/ x_m z) x_m) (* 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.95e+62) {
tmp = x_m * (y / z);
} else if (y <= 4.8e+31) {
tmp = (x_m / z) - x_m;
} 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.95d+62)) then
tmp = x_m * (y / z)
else if (y <= 4.8d+31) then
tmp = (x_m / z) - x_m
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.95e+62) {
tmp = x_m * (y / z);
} else if (y <= 4.8e+31) {
tmp = (x_m / z) - x_m;
} 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.95e+62: tmp = x_m * (y / z) elif y <= 4.8e+31: tmp = (x_m / z) - x_m 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.95e+62) tmp = Float64(x_m * Float64(y / z)); elseif (y <= 4.8e+31) tmp = Float64(Float64(x_m / z) - x_m); 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.95e+62) tmp = x_m * (y / z); elseif (y <= 4.8e+31) tmp = (x_m / z) - x_m; 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.95e+62], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+31], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $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.95 \cdot 10^{+62}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+31}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\end{array}
\end{array}
if y < -1.95e62Initial program 92.8%
Taylor expanded in y around inf 85.1%
associate-/l*82.8%
Simplified82.8%
clear-num82.9%
associate-/r/82.9%
clear-num82.9%
Applied egg-rr82.9%
if -1.95e62 < y < 4.79999999999999965e31Initial program 91.8%
Taylor expanded in x around 0 91.7%
associate--l+91.8%
+-commutative91.8%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 96.3%
sub-neg96.3%
metadata-eval96.3%
distribute-rgt-in96.3%
associate-*l/96.4%
*-lft-identity96.4%
neg-mul-196.4%
unsub-neg96.4%
Simplified96.4%
if 4.79999999999999965e31 < y Initial program 87.7%
Taylor expanded in y around inf 74.9%
associate-/l*63.2%
associate-/r/68.3%
Simplified68.3%
Final simplification88.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 345000.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 <= 345000.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 <= 345000.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 <= 345000.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 <= 345000.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 <= 345000.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 <= 345000.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, 345000.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 345000\right):\\
\;\;\;\;-x_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z}\\
\end{array}
\end{array}
if z < -1 or 345000 < z Initial program 81.1%
Taylor expanded in z around inf 79.7%
mul-1-neg79.7%
Simplified79.7%
if -1 < z < 345000Initial program 99.9%
Taylor expanded in y around 0 61.7%
Taylor expanded in z around 0 58.6%
Final simplification68.5%
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 91.1%
Taylor expanded in z around inf 39.2%
mul-1-neg39.2%
Simplified39.2%
Final simplification39.2%
(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 2023331
(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))