
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\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)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\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 3.5e-192)
(* x_m (- (/ y z) -1.0))
(if (<= x_m 3.1e+14) (/ (* x_m (+ y z)) z) (fma 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 (x_m <= 3.5e-192) {
tmp = x_m * ((y / z) - -1.0);
} else if (x_m <= 3.1e+14) {
tmp = (x_m * (y + z)) / z;
} else {
tmp = fma(x_m, (y / 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 (x_m <= 3.5e-192) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); elseif (x_m <= 3.1e+14) tmp = Float64(Float64(x_m * Float64(y + z)) / z); else tmp = fma(x_m, Float64(y / z), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 3.5e-192], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 3.1e+14], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x$95$m * N[(y / 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}\;x\_m \leq 3.5 \cdot 10^{-192}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{elif}\;x\_m \leq 3.1 \cdot 10^{+14}:\\
\;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, \frac{y}{z}, x\_m\right)\\
\end{array}
\end{array}
if x < 3.50000000000000014e-192Initial program 82.9%
associate-/l*94.9%
remove-double-neg94.9%
distribute-frac-neg294.9%
neg-sub094.9%
remove-double-neg94.9%
unsub-neg94.9%
div-sub94.9%
*-inverses94.9%
metadata-eval94.9%
associate--r-94.9%
neg-sub094.9%
distribute-frac-neg294.9%
remove-double-neg94.9%
sub-neg94.9%
Simplified94.9%
if 3.50000000000000014e-192 < x < 3.1e14Initial program 97.4%
if 3.1e14 < x Initial program 74.8%
remove-double-neg74.8%
distribute-frac-neg274.8%
distribute-frac-neg74.8%
distribute-rgt-neg-in74.8%
distribute-neg-in74.8%
distribute-lft-out74.6%
*-commutative74.6%
cancel-sign-sub-inv74.6%
div-sub74.6%
associate-*r/76.4%
distribute-neg-frac76.4%
distribute-frac-neg276.4%
remove-double-neg76.4%
fma-neg76.4%
distribute-frac-neg76.4%
distribute-lft-neg-out76.4%
*-commutative76.4%
associate-/l*99.9%
*-inverses99.9%
*-rgt-identity99.9%
Simplified99.9%
Final simplification96.5%
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 -2.15e+148) (not (<= y 2e+50)))
(* (+ y z) (/ x_m z))
(* x_m (- (/ y 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) {
double tmp;
if ((y <= -2.15e+148) || !(y <= 2e+50)) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m * ((y / z) - -1.0);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.15d+148)) .or. (.not. (y <= 2d+50))) then
tmp = (y + z) * (x_m / z)
else
tmp = x_m * ((y / z) - (-1.0d0))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y <= -2.15e+148) || !(y <= 2e+50)) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m * ((y / z) - -1.0);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (y <= -2.15e+148) or not (y <= 2e+50): tmp = (y + z) * (x_m / z) else: tmp = x_m * ((y / z) - -1.0) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((y <= -2.15e+148) || !(y <= 2e+50)) tmp = Float64(Float64(y + z) * Float64(x_m / z)); else tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((y <= -2.15e+148) || ~((y <= 2e+50))) tmp = (y + z) * (x_m / z); else tmp = x_m * ((y / z) - -1.0); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -2.15e+148], N[Not[LessEqual[y, 2e+50]], $MachinePrecision]], N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(N[(y / 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 \begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+148} \lor \neg \left(y \leq 2 \cdot 10^{+50}\right):\\
\;\;\;\;\left(y + z\right) \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if y < -2.1500000000000001e148 or 2.0000000000000002e50 < y Initial program 85.7%
*-commutative85.7%
associate-/l*94.2%
Simplified94.2%
if -2.1500000000000001e148 < y < 2.0000000000000002e50Initial program 82.3%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Final simplification98.0%
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 -1.8e+148) (not (<= y 3.05e+57)))
(* (+ y z) (/ 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.8e+148) || !(y <= 3.05e+57)) {
tmp = (y + z) * (x_m / 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 ((y <= (-1.8d+148)) .or. (.not. (y <= 3.05d+57))) then
tmp = (y + z) * (x_m / 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 ((y <= -1.8e+148) || !(y <= 3.05e+57)) {
tmp = (y + z) * (x_m / 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 (y <= -1.8e+148) or not (y <= 3.05e+57): tmp = (y + z) * (x_m / 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 ((y <= -1.8e+148) || !(y <= 3.05e+57)) tmp = Float64(Float64(y + z) * Float64(x_m / z)); else tmp = Float64(x_m + 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 ((y <= -1.8e+148) || ~((y <= 3.05e+57))) tmp = (y + z) * (x_m / 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[y, -1.8e+148], N[Not[LessEqual[y, 3.05e+57]], $MachinePrecision]], N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * 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}\;y \leq -1.8 \cdot 10^{+148} \lor \neg \left(y \leq 3.05 \cdot 10^{+57}\right):\\
\;\;\;\;\left(y + z\right) \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -1.80000000000000003e148 or 3.04999999999999988e57 < y Initial program 85.7%
*-commutative85.7%
associate-/l*94.2%
Simplified94.2%
if -1.80000000000000003e148 < y < 3.04999999999999988e57Initial program 82.3%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Final simplification98.0%
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 8.5e-191)
(* x_m (- (/ y z) -1.0))
(if (<= x_m 200000000.0) (/ (* x_m (+ y z)) 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 (x_m <= 8.5e-191) {
tmp = x_m * ((y / z) - -1.0);
} else if (x_m <= 200000000.0) {
tmp = (x_m * (y + z)) / 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 (x_m <= 8.5d-191) then
tmp = x_m * ((y / z) - (-1.0d0))
else if (x_m <= 200000000.0d0) then
tmp = (x_m * (y + z)) / 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 (x_m <= 8.5e-191) {
tmp = x_m * ((y / z) - -1.0);
} else if (x_m <= 200000000.0) {
tmp = (x_m * (y + z)) / 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 x_m <= 8.5e-191: tmp = x_m * ((y / z) - -1.0) elif x_m <= 200000000.0: tmp = (x_m * (y + z)) / 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 (x_m <= 8.5e-191) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); elseif (x_m <= 200000000.0) tmp = Float64(Float64(x_m * Float64(y + z)) / z); else tmp = Float64(x_m + 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 (x_m <= 8.5e-191) tmp = x_m * ((y / z) - -1.0); elseif (x_m <= 200000000.0) tmp = (x_m * (y + z)) / 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[LessEqual[x$95$m, 8.5e-191], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 200000000.0], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x$95$m + N[(x$95$m * 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}\;x\_m \leq 8.5 \cdot 10^{-191}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{elif}\;x\_m \leq 200000000:\\
\;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 8.49999999999999954e-191Initial program 82.9%
associate-/l*94.9%
remove-double-neg94.9%
distribute-frac-neg294.9%
neg-sub094.9%
remove-double-neg94.9%
unsub-neg94.9%
div-sub94.9%
*-inverses94.9%
metadata-eval94.9%
associate--r-94.9%
neg-sub094.9%
distribute-frac-neg294.9%
remove-double-neg94.9%
sub-neg94.9%
Simplified94.9%
if 8.49999999999999954e-191 < x < 2e8Initial program 97.4%
if 2e8 < x Initial program 74.8%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Final simplification96.5%
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 -3e-5) (not (<= y 6.2e+79))) (* 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 <= -3e-5) || !(y <= 6.2e+79)) {
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 <= (-3d-5)) .or. (.not. (y <= 6.2d+79))) 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 <= -3e-5) || !(y <= 6.2e+79)) {
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 <= -3e-5) or not (y <= 6.2e+79): 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 <= -3e-5) || !(y <= 6.2e+79)) tmp = Float64(x_m * Float64(y / 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 <= -3e-5) || ~((y <= 6.2e+79))) 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[Or[LessEqual[y, -3e-5], N[Not[LessEqual[y, 6.2e+79]], $MachinePrecision]], N[(x$95$m * N[(y / 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}\;y \leq -3 \cdot 10^{-5} \lor \neg \left(y \leq 6.2 \cdot 10^{+79}\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -3.00000000000000008e-5 or 6.1999999999999998e79 < y Initial program 89.1%
associate-/l*89.2%
remove-double-neg89.2%
distribute-frac-neg289.2%
neg-sub089.2%
remove-double-neg89.2%
unsub-neg89.2%
div-sub89.2%
*-inverses89.2%
metadata-eval89.2%
associate--r-89.2%
neg-sub089.2%
distribute-frac-neg289.2%
remove-double-neg89.2%
sub-neg89.2%
Simplified89.2%
Taylor expanded in y around inf 77.7%
associate-*r/71.1%
Simplified71.1%
if -3.00000000000000008e-5 < y < 6.1999999999999998e79Initial program 79.0%
associate-/l*98.6%
remove-double-neg98.6%
distribute-frac-neg298.6%
neg-sub098.6%
remove-double-neg98.6%
unsub-neg98.6%
div-sub98.6%
*-inverses98.6%
metadata-eval98.6%
associate--r-98.6%
neg-sub098.6%
distribute-frac-neg298.6%
remove-double-neg98.6%
sub-neg98.6%
Simplified98.6%
Taylor expanded in y around 0 75.2%
Final simplification73.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 -2e-7) (not (<= y 6.2e+79))) (* 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 <= -2e-7) || !(y <= 6.2e+79)) {
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 ((y <= (-2d-7)) .or. (.not. (y <= 6.2d+79))) 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 ((y <= -2e-7) || !(y <= 6.2e+79)) {
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 (y <= -2e-7) or not (y <= 6.2e+79): 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 ((y <= -2e-7) || !(y <= 6.2e+79)) tmp = Float64(y * Float64(x_m / 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 <= -2e-7) || ~((y <= 6.2e+79))) 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[Or[LessEqual[y, -2e-7], N[Not[LessEqual[y, 6.2e+79]], $MachinePrecision]], 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}\;y \leq -2 \cdot 10^{-7} \lor \neg \left(y \leq 6.2 \cdot 10^{+79}\right):\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.9999999999999999e-7 or 6.1999999999999998e79 < y Initial program 89.1%
associate-/l*89.2%
remove-double-neg89.2%
distribute-frac-neg289.2%
neg-sub089.2%
remove-double-neg89.2%
unsub-neg89.2%
div-sub89.2%
*-inverses89.2%
metadata-eval89.2%
associate--r-89.2%
neg-sub089.2%
distribute-frac-neg289.2%
remove-double-neg89.2%
sub-neg89.2%
Simplified89.2%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
associate-/l*79.3%
Applied egg-rr79.3%
if -1.9999999999999999e-7 < y < 6.1999999999999998e79Initial program 79.0%
associate-/l*98.6%
remove-double-neg98.6%
distribute-frac-neg298.6%
neg-sub098.6%
remove-double-neg98.6%
unsub-neg98.6%
div-sub98.6%
*-inverses98.6%
metadata-eval98.6%
associate--r-98.6%
neg-sub098.6%
distribute-frac-neg298.6%
remove-double-neg98.6%
sub-neg98.6%
Simplified98.6%
Taylor expanded in y around 0 75.2%
Final simplification77.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.25e-6) (* y (/ x_m z)) (if (<= y 8e+79) 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 <= -1.25e-6) {
tmp = y * (x_m / z);
} else if (y <= 8e+79) {
tmp = x_m;
} else {
tmp = y / (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.25d-6)) then
tmp = y * (x_m / z)
else if (y <= 8d+79) then
tmp = x_m
else
tmp = y / (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.25e-6) {
tmp = y * (x_m / z);
} else if (y <= 8e+79) {
tmp = x_m;
} else {
tmp = y / (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.25e-6: tmp = y * (x_m / z) elif y <= 8e+79: tmp = x_m else: tmp = y / (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.25e-6) tmp = Float64(y * Float64(x_m / z)); elseif (y <= 8e+79) tmp = x_m; else tmp = Float64(y / Float64(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.25e-6) tmp = y * (x_m / z); elseif (y <= 8e+79) tmp = x_m; else tmp = y / (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[LessEqual[y, -1.25e-6], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+79], x$95$m, N[(y / N[(z / x$95$m), $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.25 \cdot 10^{-6}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+79}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\end{array}
\end{array}
if y < -1.2500000000000001e-6Initial program 91.7%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
neg-sub090.4%
remove-double-neg90.4%
unsub-neg90.4%
div-sub90.4%
*-inverses90.4%
metadata-eval90.4%
associate--r-90.4%
neg-sub090.4%
distribute-frac-neg290.4%
remove-double-neg90.4%
sub-neg90.4%
Simplified90.4%
Taylor expanded in y around inf 77.4%
*-commutative77.4%
associate-/l*77.4%
Applied egg-rr77.4%
if -1.2500000000000001e-6 < y < 7.99999999999999974e79Initial program 79.0%
associate-/l*98.6%
remove-double-neg98.6%
distribute-frac-neg298.6%
neg-sub098.6%
remove-double-neg98.6%
unsub-neg98.6%
div-sub98.6%
*-inverses98.6%
metadata-eval98.6%
associate--r-98.6%
neg-sub098.6%
distribute-frac-neg298.6%
remove-double-neg98.6%
sub-neg98.6%
Simplified98.6%
Taylor expanded in y around 0 75.2%
if 7.99999999999999974e79 < y Initial program 84.9%
associate-/l*87.2%
remove-double-neg87.2%
distribute-frac-neg287.2%
neg-sub087.2%
remove-double-neg87.2%
unsub-neg87.2%
div-sub87.2%
*-inverses87.2%
metadata-eval87.2%
associate--r-87.2%
neg-sub087.2%
distribute-frac-neg287.2%
remove-double-neg87.2%
sub-neg87.2%
Simplified87.2%
Taylor expanded in y around inf 78.0%
*-commutative78.0%
associate-/l*82.1%
Applied egg-rr82.1%
clear-num82.1%
un-div-inv82.3%
Applied egg-rr82.3%
Final simplification77.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 -0.48) (/ (* x_m y) z) (if (<= y 6.2e+79) 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 <= -0.48) {
tmp = (x_m * y) / z;
} else if (y <= 6.2e+79) {
tmp = x_m;
} else {
tmp = y / (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 <= (-0.48d0)) then
tmp = (x_m * y) / z
else if (y <= 6.2d+79) then
tmp = x_m
else
tmp = y / (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 <= -0.48) {
tmp = (x_m * y) / z;
} else if (y <= 6.2e+79) {
tmp = x_m;
} else {
tmp = y / (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 <= -0.48: tmp = (x_m * y) / z elif y <= 6.2e+79: tmp = x_m else: tmp = y / (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 <= -0.48) tmp = Float64(Float64(x_m * y) / z); elseif (y <= 6.2e+79) tmp = x_m; else tmp = Float64(y / Float64(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 <= -0.48) tmp = (x_m * y) / z; elseif (y <= 6.2e+79) tmp = x_m; else tmp = y / (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[LessEqual[y, -0.48], N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 6.2e+79], x$95$m, N[(y / N[(z / x$95$m), $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 -0.48:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+79}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\end{array}
\end{array}
if y < -0.47999999999999998Initial program 91.7%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
neg-sub090.4%
remove-double-neg90.4%
unsub-neg90.4%
div-sub90.4%
*-inverses90.4%
metadata-eval90.4%
associate--r-90.4%
neg-sub090.4%
distribute-frac-neg290.4%
remove-double-neg90.4%
sub-neg90.4%
Simplified90.4%
Taylor expanded in y around inf 77.4%
if -0.47999999999999998 < y < 6.1999999999999998e79Initial program 79.0%
associate-/l*98.6%
remove-double-neg98.6%
distribute-frac-neg298.6%
neg-sub098.6%
remove-double-neg98.6%
unsub-neg98.6%
div-sub98.6%
*-inverses98.6%
metadata-eval98.6%
associate--r-98.6%
neg-sub098.6%
distribute-frac-neg298.6%
remove-double-neg98.6%
sub-neg98.6%
Simplified98.6%
Taylor expanded in y around 0 75.2%
if 6.1999999999999998e79 < y Initial program 84.9%
associate-/l*87.2%
remove-double-neg87.2%
distribute-frac-neg287.2%
neg-sub087.2%
remove-double-neg87.2%
unsub-neg87.2%
div-sub87.2%
*-inverses87.2%
metadata-eval87.2%
associate--r-87.2%
neg-sub087.2%
distribute-frac-neg287.2%
remove-double-neg87.2%
sub-neg87.2%
Simplified87.2%
Taylor expanded in y around inf 78.0%
*-commutative78.0%
associate-/l*82.1%
Applied egg-rr82.1%
clear-num82.1%
un-div-inv82.3%
Applied egg-rr82.3%
Final simplification77.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 (- (/ y 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 / 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 / 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 / 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 / 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(y / 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 / 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[(y / 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}{z} - -1\right)\right)
\end{array}
Initial program 83.4%
associate-/l*94.4%
remove-double-neg94.4%
distribute-frac-neg294.4%
neg-sub094.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.4%
*-inverses94.4%
metadata-eval94.4%
associate--r-94.4%
neg-sub094.4%
distribute-frac-neg294.4%
remove-double-neg94.4%
sub-neg94.4%
Simplified94.4%
Final simplification94.4%
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 83.4%
associate-/l*94.4%
remove-double-neg94.4%
distribute-frac-neg294.4%
neg-sub094.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.4%
*-inverses94.4%
metadata-eval94.4%
associate--r-94.4%
neg-sub094.4%
distribute-frac-neg294.4%
remove-double-neg94.4%
sub-neg94.4%
Simplified94.4%
Taylor expanded in y around 0 50.3%
Final simplification50.3%
(FPCore (x y z) :precision binary64 (/ x (/ z (+ y z))))
double code(double x, double y, double z) {
return x / (z / (y + z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / (z / (y + z))
end function
public static double code(double x, double y, double z) {
return x / (z / (y + z));
}
def code(x, y, z): return x / (z / (y + z))
function code(x, y, z) return Float64(x / Float64(z / Float64(y + z))) end
function tmp = code(x, y, z) tmp = x / (z / (y + z)); end
code[x_, y_, z_] := N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{y + z}}
\end{array}
herbie shell --seed 2024055
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:alt
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))