
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) -2e-104)
(* 0.5 (+ y_m (/ -1.0 (/ y_m (pow z 2.0)))))
(* 0.5 (+ y_m (* x (/ x y_m)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -2e-104) {
tmp = 0.5 * (y_m + (-1.0 / (y_m / pow(z, 2.0))));
} else {
tmp = 0.5 * (y_m + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)) <= (-2d-104)) then
tmp = 0.5d0 * (y_m + ((-1.0d0) / (y_m / (z ** 2.0d0))))
else
tmp = 0.5d0 * (y_m + (x * (x / y_m)))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -2e-104) {
tmp = 0.5 * (y_m + (-1.0 / (y_m / Math.pow(z, 2.0))));
} else {
tmp = 0.5 * (y_m + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if ((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -2e-104: tmp = 0.5 * (y_m + (-1.0 / (y_m / math.pow(z, 2.0)))) else: tmp = 0.5 * (y_m + (x * (x / y_m))) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= -2e-104) tmp = Float64(0.5 * Float64(y_m + Float64(-1.0 / Float64(y_m / (z ^ 2.0))))); else tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m)))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -2e-104) tmp = 0.5 * (y_m + (-1.0 / (y_m / (z ^ 2.0)))); else tmp = 0.5 * (y_m + (x * (x / y_m))); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], -2e-104], N[(0.5 * N[(y$95$m + N[(-1.0 / N[(y$95$m / N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq -2 \cdot 10^{-104}:\\
\;\;\;\;0.5 \cdot \left(y\_m + \frac{-1}{\frac{y\_m}{{z}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -1.99999999999999985e-104Initial program 79.5%
remove-double-neg79.5%
distribute-lft-neg-out79.5%
distribute-frac-neg279.5%
distribute-frac-neg79.5%
neg-mul-179.5%
distribute-lft-neg-out79.5%
*-commutative79.5%
distribute-lft-neg-in79.5%
times-frac79.5%
metadata-eval79.5%
metadata-eval79.5%
associate--l+79.5%
fma-define79.5%
Simplified79.5%
Taylor expanded in x around 0 87.8%
associate--l+87.8%
div-sub93.7%
Simplified93.7%
clear-num93.6%
inv-pow93.6%
Applied egg-rr93.6%
unpow-193.6%
Simplified93.6%
Taylor expanded in x around 0 65.3%
associate-*r/65.3%
neg-mul-165.3%
Simplified65.3%
if -1.99999999999999985e-104 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 54.8%
remove-double-neg54.8%
distribute-lft-neg-out54.8%
distribute-frac-neg254.8%
distribute-frac-neg54.8%
neg-mul-154.8%
distribute-lft-neg-out54.8%
*-commutative54.8%
distribute-lft-neg-in54.8%
times-frac54.8%
metadata-eval54.8%
metadata-eval54.8%
associate--l+54.8%
fma-define57.0%
Simplified57.0%
Taylor expanded in z around 0 40.2%
associate-*r/40.1%
rem-square-sqrt40.1%
unpow240.1%
unpow240.1%
hypot-undefine40.1%
unpow240.1%
unpow240.1%
hypot-undefine40.2%
unpow240.2%
associate-*r/40.2%
*-commutative40.2%
metadata-eval40.2%
times-frac40.2%
associate-/l*40.1%
Simplified40.1%
Taylor expanded in x around 0 63.7%
distribute-lft-in63.7%
*-commutative63.7%
Simplified63.7%
pow263.7%
associate-/l*69.7%
Applied egg-rr69.7%
Final simplification67.7%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)))) (* y_s (if (<= t_0 -2e-104) t_0 (* 0.5 (+ y_m (* x (/ x y_m))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= -2e-104) {
tmp = t_0;
} else {
tmp = 0.5 * (y_m + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
if (t_0 <= (-2d-104)) then
tmp = t_0
else
tmp = 0.5d0 * (y_m + (x * (x / y_m)))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= -2e-104) {
tmp = t_0;
} else {
tmp = 0.5 * (y_m + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0) tmp = 0 if t_0 <= -2e-104: tmp = t_0 else: tmp = 0.5 * (y_m + (x * (x / y_m))) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) tmp = 0.0 if (t_0 <= -2e-104) tmp = t_0; else tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m)))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0); tmp = 0.0; if (t_0 <= -2e-104) tmp = t_0; else tmp = 0.5 * (y_m + (x * (x / y_m))); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, -2e-104], t$95$0, N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -1.99999999999999985e-104Initial program 79.5%
if -1.99999999999999985e-104 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 54.8%
remove-double-neg54.8%
distribute-lft-neg-out54.8%
distribute-frac-neg254.8%
distribute-frac-neg54.8%
neg-mul-154.8%
distribute-lft-neg-out54.8%
*-commutative54.8%
distribute-lft-neg-in54.8%
times-frac54.8%
metadata-eval54.8%
metadata-eval54.8%
associate--l+54.8%
fma-define57.0%
Simplified57.0%
Taylor expanded in z around 0 40.2%
associate-*r/40.1%
rem-square-sqrt40.1%
unpow240.1%
unpow240.1%
hypot-undefine40.1%
unpow240.1%
unpow240.1%
hypot-undefine40.2%
unpow240.2%
associate-*r/40.2%
*-commutative40.2%
metadata-eval40.2%
times-frac40.2%
associate-/l*40.1%
Simplified40.1%
Taylor expanded in x around 0 63.7%
distribute-lft-in63.7%
*-commutative63.7%
Simplified63.7%
pow263.7%
associate-/l*69.7%
Applied egg-rr69.7%
Final simplification74.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 3.2e+29) (* (* x x) (/ 0.5 y_m)) (+ (+ 1.0 (* y_m 0.5)) -1.0))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 3.2e+29) {
tmp = (x * x) * (0.5 / y_m);
} else {
tmp = (1.0 + (y_m * 0.5)) + -1.0;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 3.2d+29) then
tmp = (x * x) * (0.5d0 / y_m)
else
tmp = (1.0d0 + (y_m * 0.5d0)) + (-1.0d0)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 3.2e+29) {
tmp = (x * x) * (0.5 / y_m);
} else {
tmp = (1.0 + (y_m * 0.5)) + -1.0;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 3.2e+29: tmp = (x * x) * (0.5 / y_m) else: tmp = (1.0 + (y_m * 0.5)) + -1.0 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 3.2e+29) tmp = Float64(Float64(x * x) * Float64(0.5 / y_m)); else tmp = Float64(Float64(1.0 + Float64(y_m * 0.5)) + -1.0); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 3.2e+29) tmp = (x * x) * (0.5 / y_m); else tmp = (1.0 + (y_m * 0.5)) + -1.0; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 3.2e+29], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 3.2 \cdot 10^{+29}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + y\_m \cdot 0.5\right) + -1\\
\end{array}
\end{array}
if y < 3.19999999999999987e29Initial program 76.5%
remove-double-neg76.5%
distribute-lft-neg-out76.5%
distribute-frac-neg276.5%
distribute-frac-neg76.5%
neg-mul-176.5%
distribute-lft-neg-out76.5%
*-commutative76.5%
distribute-lft-neg-in76.5%
times-frac76.5%
metadata-eval76.5%
metadata-eval76.5%
associate--l+76.5%
fma-define78.1%
Simplified78.1%
Taylor expanded in x around inf 33.4%
*-commutative33.4%
associate-*l/33.4%
associate-*r/33.4%
Simplified33.4%
pow233.4%
Applied egg-rr33.4%
if 3.19999999999999987e29 < y Initial program 37.9%
remove-double-neg37.9%
distribute-lft-neg-out37.9%
distribute-frac-neg237.9%
distribute-frac-neg37.9%
neg-mul-137.9%
distribute-lft-neg-out37.9%
*-commutative37.9%
distribute-lft-neg-in37.9%
times-frac37.9%
metadata-eval37.9%
metadata-eval37.9%
associate--l+37.9%
fma-define37.9%
Simplified37.9%
Taylor expanded in y around inf 72.2%
*-commutative72.2%
Simplified72.2%
expm1-log1p-u65.0%
expm1-undefine65.0%
Applied egg-rr65.0%
expm1-define65.0%
Simplified65.0%
expm1-undefine65.0%
log1p-undefine65.0%
rem-exp-log72.2%
Applied egg-rr72.2%
Final simplification43.6%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 3.2e+29) (* (* x x) (/ 0.5 y_m)) (* y_m 0.5))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 3.2e+29) {
tmp = (x * x) * (0.5 / y_m);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 3.2d+29) then
tmp = (x * x) * (0.5d0 / y_m)
else
tmp = y_m * 0.5d0
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 3.2e+29) {
tmp = (x * x) * (0.5 / y_m);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 3.2e+29: tmp = (x * x) * (0.5 / y_m) else: tmp = y_m * 0.5 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 3.2e+29) tmp = Float64(Float64(x * x) * Float64(0.5 / y_m)); else tmp = Float64(y_m * 0.5); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 3.2e+29) tmp = (x * x) * (0.5 / y_m); else tmp = y_m * 0.5; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 3.2e+29], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 3.2 \cdot 10^{+29}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 3.19999999999999987e29Initial program 76.5%
remove-double-neg76.5%
distribute-lft-neg-out76.5%
distribute-frac-neg276.5%
distribute-frac-neg76.5%
neg-mul-176.5%
distribute-lft-neg-out76.5%
*-commutative76.5%
distribute-lft-neg-in76.5%
times-frac76.5%
metadata-eval76.5%
metadata-eval76.5%
associate--l+76.5%
fma-define78.1%
Simplified78.1%
Taylor expanded in x around inf 33.4%
*-commutative33.4%
associate-*l/33.4%
associate-*r/33.4%
Simplified33.4%
pow233.4%
Applied egg-rr33.4%
if 3.19999999999999987e29 < y Initial program 37.9%
remove-double-neg37.9%
distribute-lft-neg-out37.9%
distribute-frac-neg237.9%
distribute-frac-neg37.9%
neg-mul-137.9%
distribute-lft-neg-out37.9%
*-commutative37.9%
distribute-lft-neg-in37.9%
times-frac37.9%
metadata-eval37.9%
metadata-eval37.9%
associate--l+37.9%
fma-define37.9%
Simplified37.9%
Taylor expanded in y around inf 72.2%
*-commutative72.2%
Simplified72.2%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* 0.5 (+ y_m (* x (/ x y_m))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (0.5 * (y_m + (x * (x / y_m))));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (0.5d0 * (y_m + (x * (x / y_m))))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (0.5 * (y_m + (x * (x / y_m))));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (0.5 * (y_m + (x * (x / y_m))))
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m))))) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (0.5 * (y_m + (x * (x / y_m)))); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\right)
\end{array}
Initial program 66.4%
remove-double-neg66.4%
distribute-lft-neg-out66.4%
distribute-frac-neg266.4%
distribute-frac-neg66.4%
neg-mul-166.4%
distribute-lft-neg-out66.4%
*-commutative66.4%
distribute-lft-neg-in66.4%
times-frac66.4%
metadata-eval66.4%
metadata-eval66.4%
associate--l+66.4%
fma-define67.6%
Simplified67.6%
Taylor expanded in z around 0 44.3%
associate-*r/44.2%
rem-square-sqrt44.2%
unpow244.2%
unpow244.2%
hypot-undefine44.2%
unpow244.2%
unpow244.2%
hypot-undefine44.2%
unpow244.2%
associate-*r/44.2%
*-commutative44.2%
metadata-eval44.2%
times-frac44.2%
associate-/l*44.2%
Simplified44.2%
Taylor expanded in x around 0 63.4%
distribute-lft-in63.4%
*-commutative63.4%
Simplified63.4%
pow263.4%
associate-/l*68.7%
Applied egg-rr68.7%
Final simplification68.7%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (y_m * 0.5d0)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (y_m * 0.5)
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(y_m * 0.5)) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (y_m * 0.5); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Initial program 66.4%
remove-double-neg66.4%
distribute-lft-neg-out66.4%
distribute-frac-neg266.4%
distribute-frac-neg66.4%
neg-mul-166.4%
distribute-lft-neg-out66.4%
*-commutative66.4%
distribute-lft-neg-in66.4%
times-frac66.4%
metadata-eval66.4%
metadata-eval66.4%
associate--l+66.4%
fma-define67.6%
Simplified67.6%
Taylor expanded in y around inf 39.7%
*-commutative39.7%
Simplified39.7%
(FPCore (x y z) :precision binary64 (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x))))
double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * 0.5d0) - (((0.5d0 / y) * (z + x)) * (z - x))
end function
public static double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
def code(x, y, z): return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x))
function code(x, y, z) return Float64(Float64(y * 0.5) - Float64(Float64(Float64(0.5 / y) * Float64(z + x)) * Float64(z - x))) end
function tmp = code(x, y, z) tmp = (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x)); end
code[x_, y_, z_] := N[(N[(y * 0.5), $MachinePrecision] - N[(N[(N[(0.5 / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)
\end{array}
herbie shell --seed 2024116
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))