
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
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)) y))) (* x_s (if (<= t_0 -5e+47) t_0 (/ x_m (/ y (- 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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -5e+47) {
tmp = t_0;
} else {
tmp = x_m / (y / (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) :: t_0
real(8) :: tmp
t_0 = (x_m * (y - z)) / y
if (t_0 <= (-5d+47)) then
tmp = t_0
else
tmp = x_m / (y / (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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -5e+47) {
tmp = t_0;
} else {
tmp = x_m / (y / (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): t_0 = (x_m * (y - z)) / y tmp = 0 if t_0 <= -5e+47: tmp = t_0 else: tmp = x_m / (y / (y - 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(Float64(x_m * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= -5e+47) tmp = t_0; else tmp = Float64(x_m / Float64(y / 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) t_0 = (x_m * (y - z)) / y; tmp = 0.0; if (t_0 <= -5e+47) tmp = t_0; else tmp = x_m / (y / (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_] := Block[{t$95$0 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -5e+47], t$95$0, N[(x$95$m / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $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(y - z\right)}{y}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{\frac{y}{y - z}}\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -5.00000000000000022e47Initial program 73.1%
if -5.00000000000000022e47 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 83.4%
associate-*l/85.2%
Simplified85.2%
associate-/r/95.9%
Applied egg-rr95.9%
Final simplification88.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -6.2e+14)
x_m
(if (or (<= y 5.8e-110) (and (not (<= y 1.6e-79)) (<= y 1.6e+39)))
(* x_m (/ (- z) y))
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 <= -6.2e+14) {
tmp = x_m;
} else if ((y <= 5.8e-110) || (!(y <= 1.6e-79) && (y <= 1.6e+39))) {
tmp = x_m * (-z / y);
} 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 (y <= (-6.2d+14)) then
tmp = x_m
else if ((y <= 5.8d-110) .or. (.not. (y <= 1.6d-79)) .and. (y <= 1.6d+39)) then
tmp = x_m * (-z / y)
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 (y <= -6.2e+14) {
tmp = x_m;
} else if ((y <= 5.8e-110) || (!(y <= 1.6e-79) && (y <= 1.6e+39))) {
tmp = x_m * (-z / y);
} 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 y <= -6.2e+14: tmp = x_m elif (y <= 5.8e-110) or (not (y <= 1.6e-79) and (y <= 1.6e+39)): tmp = x_m * (-z / y) 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 (y <= -6.2e+14) tmp = x_m; elseif ((y <= 5.8e-110) || (!(y <= 1.6e-79) && (y <= 1.6e+39))) tmp = Float64(x_m * Float64(Float64(-z) / y)); 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 (y <= -6.2e+14) tmp = x_m; elseif ((y <= 5.8e-110) || (~((y <= 1.6e-79)) && (y <= 1.6e+39))) tmp = x_m * (-z / y); 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[y, -6.2e+14], x$95$m, If[Or[LessEqual[y, 5.8e-110], And[N[Not[LessEqual[y, 1.6e-79]], $MachinePrecision], LessEqual[y, 1.6e+39]]], N[(x$95$m * N[((-z) / y), $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}\;y \leq -6.2 \cdot 10^{+14}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-110} \lor \neg \left(y \leq 1.6 \cdot 10^{-79}\right) \land y \leq 1.6 \cdot 10^{+39}:\\
\;\;\;\;x\_m \cdot \frac{-z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -6.2e14 or 5.8000000000000005e-110 < y < 1.59999999999999994e-79 or 1.59999999999999996e39 < y Initial program 64.4%
*-commutative64.4%
associate-*l/99.9%
*-commutative99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 84.5%
if -6.2e14 < y < 5.8000000000000005e-110 or 1.59999999999999994e-79 < y < 1.59999999999999996e39Initial program 93.1%
associate-*l/92.4%
Simplified92.4%
associate-/r/92.0%
Applied egg-rr92.0%
Taylor expanded in y around 0 76.6%
mul-1-neg76.6%
associate-*r/71.9%
distribute-lft-neg-in71.9%
Simplified71.9%
Final simplification77.7%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -3.5e+14)
x_m
(if (or (<= y 1.02e-109) (and (not (<= y 3.8e-79)) (<= y 4e+38)))
(* (/ x_m y) (- 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.5e+14) {
tmp = x_m;
} else if ((y <= 1.02e-109) || (!(y <= 3.8e-79) && (y <= 4e+38))) {
tmp = (x_m / y) * -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 (y <= (-3.5d+14)) then
tmp = x_m
else if ((y <= 1.02d-109) .or. (.not. (y <= 3.8d-79)) .and. (y <= 4d+38)) then
tmp = (x_m / y) * -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 (y <= -3.5e+14) {
tmp = x_m;
} else if ((y <= 1.02e-109) || (!(y <= 3.8e-79) && (y <= 4e+38))) {
tmp = (x_m / y) * -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 y <= -3.5e+14: tmp = x_m elif (y <= 1.02e-109) or (not (y <= 3.8e-79) and (y <= 4e+38)): tmp = (x_m / y) * -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 (y <= -3.5e+14) tmp = x_m; elseif ((y <= 1.02e-109) || (!(y <= 3.8e-79) && (y <= 4e+38))) tmp = Float64(Float64(x_m / y) * 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 (y <= -3.5e+14) tmp = x_m; elseif ((y <= 1.02e-109) || (~((y <= 3.8e-79)) && (y <= 4e+38))) tmp = (x_m / y) * -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[y, -3.5e+14], x$95$m, If[Or[LessEqual[y, 1.02e-109], And[N[Not[LessEqual[y, 3.8e-79]], $MachinePrecision], LessEqual[y, 4e+38]]], N[(N[(x$95$m / y), $MachinePrecision] * (-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}\;y \leq -3.5 \cdot 10^{+14}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{-109} \lor \neg \left(y \leq 3.8 \cdot 10^{-79}\right) \land y \leq 4 \cdot 10^{+38}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -3.5e14 or 1.02e-109 < y < 3.8000000000000001e-79 or 3.99999999999999991e38 < y Initial program 64.4%
*-commutative64.4%
associate-*l/99.9%
*-commutative99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 84.5%
if -3.5e14 < y < 1.02e-109 or 3.8000000000000001e-79 < y < 3.99999999999999991e38Initial program 93.1%
*-commutative93.1%
associate-*l/90.9%
*-commutative90.9%
div-sub90.9%
*-inverses90.9%
Simplified90.9%
Taylor expanded in z around inf 76.6%
mul-1-neg76.6%
associate-*l/75.9%
distribute-rgt-neg-out75.9%
*-commutative75.9%
Simplified75.9%
Final simplification79.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -7.5e+14)
x_m
(if (<= y 1.02e-109)
(/ (- z) (/ y x_m))
(if (<= y 6.6e-80) x_m (if (<= y 9.5e+36) (* (/ x_m y) (- 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 <= -7.5e+14) {
tmp = x_m;
} else if (y <= 1.02e-109) {
tmp = -z / (y / x_m);
} else if (y <= 6.6e-80) {
tmp = x_m;
} else if (y <= 9.5e+36) {
tmp = (x_m / y) * -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 (y <= (-7.5d+14)) then
tmp = x_m
else if (y <= 1.02d-109) then
tmp = -z / (y / x_m)
else if (y <= 6.6d-80) then
tmp = x_m
else if (y <= 9.5d+36) then
tmp = (x_m / y) * -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 (y <= -7.5e+14) {
tmp = x_m;
} else if (y <= 1.02e-109) {
tmp = -z / (y / x_m);
} else if (y <= 6.6e-80) {
tmp = x_m;
} else if (y <= 9.5e+36) {
tmp = (x_m / y) * -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 y <= -7.5e+14: tmp = x_m elif y <= 1.02e-109: tmp = -z / (y / x_m) elif y <= 6.6e-80: tmp = x_m elif y <= 9.5e+36: tmp = (x_m / y) * -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 (y <= -7.5e+14) tmp = x_m; elseif (y <= 1.02e-109) tmp = Float64(Float64(-z) / Float64(y / x_m)); elseif (y <= 6.6e-80) tmp = x_m; elseif (y <= 9.5e+36) tmp = Float64(Float64(x_m / y) * 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 (y <= -7.5e+14) tmp = x_m; elseif (y <= 1.02e-109) tmp = -z / (y / x_m); elseif (y <= 6.6e-80) tmp = x_m; elseif (y <= 9.5e+36) tmp = (x_m / y) * -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[y, -7.5e+14], x$95$m, If[LessEqual[y, 1.02e-109], N[((-z) / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.6e-80], x$95$m, If[LessEqual[y, 9.5e+36], N[(N[(x$95$m / y), $MachinePrecision] * (-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}\;y \leq -7.5 \cdot 10^{+14}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\frac{-z}{\frac{y}{x\_m}}\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{-80}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+36}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -7.5e14 or 1.02e-109 < y < 6.5999999999999999e-80 or 9.49999999999999974e36 < y Initial program 64.4%
*-commutative64.4%
associate-*l/99.9%
*-commutative99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 84.5%
if -7.5e14 < y < 1.02e-109Initial program 91.8%
associate-*l/90.6%
Simplified90.6%
associate-/r/91.0%
Applied egg-rr91.0%
Taylor expanded in y around 0 79.6%
mul-1-neg79.6%
*-commutative79.6%
associate-/l*79.5%
distribute-neg-frac79.5%
Simplified79.5%
if 6.5999999999999999e-80 < y < 9.49999999999999974e36Initial program 98.4%
*-commutative98.4%
associate-*l/96.0%
*-commutative96.0%
div-sub96.0%
*-inverses96.0%
Simplified96.0%
Taylor expanded in z around inf 64.0%
mul-1-neg64.0%
associate-*l/64.2%
distribute-rgt-neg-out64.2%
*-commutative64.2%
Simplified64.2%
Final simplification80.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -6.5e+16)
x_m
(if (<= y 6e-110)
(/ (* x_m (- z)) y)
(if (<= y 4.5e-80) x_m (if (<= y 1e+37) (* (/ x_m y) (- 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 <= -6.5e+16) {
tmp = x_m;
} else if (y <= 6e-110) {
tmp = (x_m * -z) / y;
} else if (y <= 4.5e-80) {
tmp = x_m;
} else if (y <= 1e+37) {
tmp = (x_m / y) * -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 (y <= (-6.5d+16)) then
tmp = x_m
else if (y <= 6d-110) then
tmp = (x_m * -z) / y
else if (y <= 4.5d-80) then
tmp = x_m
else if (y <= 1d+37) then
tmp = (x_m / y) * -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 (y <= -6.5e+16) {
tmp = x_m;
} else if (y <= 6e-110) {
tmp = (x_m * -z) / y;
} else if (y <= 4.5e-80) {
tmp = x_m;
} else if (y <= 1e+37) {
tmp = (x_m / y) * -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 y <= -6.5e+16: tmp = x_m elif y <= 6e-110: tmp = (x_m * -z) / y elif y <= 4.5e-80: tmp = x_m elif y <= 1e+37: tmp = (x_m / y) * -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 (y <= -6.5e+16) tmp = x_m; elseif (y <= 6e-110) tmp = Float64(Float64(x_m * Float64(-z)) / y); elseif (y <= 4.5e-80) tmp = x_m; elseif (y <= 1e+37) tmp = Float64(Float64(x_m / y) * 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 (y <= -6.5e+16) tmp = x_m; elseif (y <= 6e-110) tmp = (x_m * -z) / y; elseif (y <= 4.5e-80) tmp = x_m; elseif (y <= 1e+37) tmp = (x_m / y) * -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[y, -6.5e+16], x$95$m, If[LessEqual[y, 6e-110], N[(N[(x$95$m * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 4.5e-80], x$95$m, If[LessEqual[y, 1e+37], N[(N[(x$95$m / y), $MachinePrecision] * (-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}\;y \leq -6.5 \cdot 10^{+16}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-110}:\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-80}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 10^{+37}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -6.5e16 or 5.99999999999999972e-110 < y < 4.5000000000000003e-80 or 9.99999999999999954e36 < y Initial program 64.4%
*-commutative64.4%
associate-*l/99.9%
*-commutative99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 84.5%
if -6.5e16 < y < 5.99999999999999972e-110Initial program 91.8%
Taylor expanded in y around 0 79.6%
associate-*r*79.6%
neg-mul-179.6%
*-commutative79.6%
Simplified79.6%
if 4.5000000000000003e-80 < y < 9.99999999999999954e36Initial program 98.4%
*-commutative98.4%
associate-*l/96.0%
*-commutative96.0%
div-sub96.0%
*-inverses96.0%
Simplified96.0%
Taylor expanded in z around inf 64.0%
mul-1-neg64.0%
associate-*l/64.2%
distribute-rgt-neg-out64.2%
*-commutative64.2%
Simplified64.2%
Final simplification80.2%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -5.5e+184) (* (- y z) (/ x_m y)) (* 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 <= -5.5e+184) {
tmp = (y - z) * (x_m / y);
} 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 <= (-5.5d+184)) then
tmp = (y - z) * (x_m / y)
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 <= -5.5e+184) {
tmp = (y - z) * (x_m / y);
} 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 <= -5.5e+184: tmp = (y - z) * (x_m / y) 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 <= -5.5e+184) tmp = Float64(Float64(y - z) * Float64(x_m / y)); 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 <= -5.5e+184) tmp = (y - z) * (x_m / y); 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[LessEqual[z, -5.5e+184], N[(N[(y - z), $MachinePrecision] * N[(x$95$m / y), $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 -5.5 \cdot 10^{+184}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < -5.5000000000000002e184Initial program 81.3%
associate-*l/95.1%
Simplified95.1%
if -5.5000000000000002e184 < z Initial program 79.8%
*-commutative79.8%
associate-*l/97.0%
*-commutative97.0%
div-sub97.0%
*-inverses97.0%
Simplified97.0%
Final simplification96.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -5.5e+182) (* (- y z) (/ x_m y)) (/ x_m (/ y (- 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 <= -5.5e+182) {
tmp = (y - z) * (x_m / y);
} else {
tmp = x_m / (y / (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 <= (-5.5d+182)) then
tmp = (y - z) * (x_m / y)
else
tmp = x_m / (y / (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 <= -5.5e+182) {
tmp = (y - z) * (x_m / y);
} else {
tmp = x_m / (y / (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 <= -5.5e+182: tmp = (y - z) * (x_m / y) else: tmp = x_m / (y / (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 <= -5.5e+182) tmp = Float64(Float64(y - z) * Float64(x_m / y)); else tmp = Float64(x_m / Float64(y / 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 <= -5.5e+182) tmp = (y - z) * (x_m / y); else tmp = x_m / (y / (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, -5.5e+182], N[(N[(y - z), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision], N[(x$95$m / N[(y / N[(y - z), $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 -5.5 \cdot 10^{+182}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{\frac{y}{y - z}}\\
\end{array}
\end{array}
if z < -5.49999999999999977e182Initial program 81.3%
associate-*l/95.1%
Simplified95.1%
if -5.49999999999999977e182 < z Initial program 79.8%
associate-*l/87.4%
Simplified87.4%
associate-/r/97.7%
Applied egg-rr97.7%
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 (* 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) {
return x_s * (x_m * (1.0 - (z / y)));
}
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 * (1.0d0 - (z / y)))
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 * (1.0 - (z / y)));
}
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 * (1.0 - (z / y)))
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(1.0 - Float64(z / y)))) 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 * (1.0 - (z / y))); 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[(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 \left(x\_m \cdot \left(1 - \frac{z}{y}\right)\right)
\end{array}
Initial program 79.9%
*-commutative79.9%
associate-*l/95.1%
*-commutative95.1%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Final simplification95.1%
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 79.9%
*-commutative79.9%
associate-*l/95.1%
*-commutative95.1%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Taylor expanded in z around 0 49.6%
Final simplification49.6%
(FPCore (x y z) :precision binary64 (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z < (-2.060202331921739d+104)) then
tmp = x - ((z * x) / y)
else if (z < 1.6939766013828526d+213) then
tmp = x / (y / (y - z))
else
tmp = (y - z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -2.060202331921739e+104: tmp = x - ((z * x) / y) elif z < 1.6939766013828526e+213: tmp = x / (y / (y - z)) else: tmp = (y - z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (z < -2.060202331921739e+104) tmp = Float64(x - Float64(Float64(z * x) / y)); elseif (z < 1.6939766013828526e+213) tmp = Float64(x / Float64(y / Float64(y - z))); else tmp = Float64(Float64(y - z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -2.060202331921739e+104) tmp = x - ((z * x) / y); elseif (z < 1.6939766013828526e+213) tmp = x / (y / (y - z)); else tmp = (y - z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}
\end{array}
herbie shell --seed 2024041
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))