
(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 5 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
(let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))))
(*
y_s
(if (or (<= t_0 -4e-116) (not (<= t_0 INFINITY)))
(* 0.5 (- y_m (* z (/ z y_m))))
(* 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 <= -4e-116) || !(t_0 <= ((double) INFINITY))) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = 0.5 * (y_m + (x * (x / y_m)));
}
return y_s * tmp;
}
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 <= -4e-116) || !(t_0 <= Double.POSITIVE_INFINITY)) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} 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 <= -4e-116) or not (t_0 <= math.inf): tmp = 0.5 * (y_m - (z * (z / y_m))) 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 <= -4e-116) || !(t_0 <= Inf)) tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); 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 <= -4e-116) || ~((t_0 <= Inf))) tmp = 0.5 * (y_m - (z * (z / y_m))); 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[Or[LessEqual[t$95$0, -4e-116], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $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)
\\
\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 -4 \cdot 10^{-116} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\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))) < -4e-116 or +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 67.5%
remove-double-neg67.5%
distribute-lft-neg-out67.5%
distribute-frac-neg267.5%
distribute-frac-neg67.5%
neg-mul-167.5%
distribute-lft-neg-out67.5%
*-commutative67.5%
distribute-lft-neg-in67.5%
times-frac67.5%
metadata-eval67.5%
metadata-eval67.5%
associate--l+67.5%
fma-define68.8%
Simplified68.8%
Taylor expanded in x around 0 76.1%
associate--l+76.1%
div-sub79.5%
Simplified79.5%
Taylor expanded in x around 0 58.9%
pow258.9%
Applied egg-rr58.9%
associate-/l*69.2%
Applied egg-rr69.2%
if -4e-116 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 77.6%
remove-double-neg77.6%
distribute-lft-neg-out77.6%
distribute-frac-neg277.6%
distribute-frac-neg77.6%
neg-mul-177.6%
distribute-lft-neg-out77.6%
*-commutative77.6%
distribute-lft-neg-in77.6%
times-frac77.6%
metadata-eval77.6%
metadata-eval77.6%
associate--l+77.6%
fma-define77.6%
Simplified77.6%
Taylor expanded in x around 0 89.0%
associate--l+89.0%
div-sub92.5%
Simplified92.5%
Taylor expanded in z around 0 66.7%
unpow266.7%
*-un-lft-identity66.7%
times-frac71.9%
Applied egg-rr71.9%
Final simplification70.4%
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 (<= z 6.2e+57)
(* 0.5 (+ y_m (* x (* x (/ 1.0 y_m)))))
(* 0.5 (- y_m (* z (/ z 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 (z <= 6.2e+57) {
tmp = 0.5 * (y_m + (x * (x * (1.0 / y_m))));
} else {
tmp = 0.5 * (y_m - (z * (z / 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 (z <= 6.2d+57) then
tmp = 0.5d0 * (y_m + (x * (x * (1.0d0 / y_m))))
else
tmp = 0.5d0 * (y_m - (z * (z / 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 (z <= 6.2e+57) {
tmp = 0.5 * (y_m + (x * (x * (1.0 / y_m))));
} else {
tmp = 0.5 * (y_m - (z * (z / 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 z <= 6.2e+57: tmp = 0.5 * (y_m + (x * (x * (1.0 / y_m)))) else: tmp = 0.5 * (y_m - (z * (z / 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 (z <= 6.2e+57) tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x * Float64(1.0 / y_m))))); else tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / 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 (z <= 6.2e+57) tmp = 0.5 * (y_m + (x * (x * (1.0 / y_m)))); else tmp = 0.5 * (y_m - (z * (z / 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[z, 6.2e+57], N[(0.5 * N[(y$95$m + N[(x * N[(x * N[(1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m - N[(z * N[(z / 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}\;z \leq 6.2 \cdot 10^{+57}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \left(x \cdot \frac{1}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if z < 6.20000000000000026e57Initial program 75.4%
remove-double-neg75.4%
distribute-lft-neg-out75.4%
distribute-frac-neg275.4%
distribute-frac-neg75.4%
neg-mul-175.4%
distribute-lft-neg-out75.4%
*-commutative75.4%
distribute-lft-neg-in75.4%
times-frac75.4%
metadata-eval75.4%
metadata-eval75.4%
associate--l+75.4%
fma-define75.4%
Simplified75.4%
Taylor expanded in x around 0 85.7%
associate--l+85.7%
div-sub88.7%
Simplified88.7%
Taylor expanded in z around 0 72.1%
div-inv72.1%
unpow272.1%
associate-*l*78.8%
Applied egg-rr78.8%
if 6.20000000000000026e57 < z Initial program 60.1%
remove-double-neg60.1%
distribute-lft-neg-out60.1%
distribute-frac-neg260.1%
distribute-frac-neg60.1%
neg-mul-160.1%
distribute-lft-neg-out60.1%
*-commutative60.1%
distribute-lft-neg-in60.1%
times-frac60.1%
metadata-eval60.1%
metadata-eval60.1%
associate--l+60.1%
fma-define63.5%
Simplified63.5%
Taylor expanded in x around 0 68.4%
associate--l+68.4%
div-sub73.5%
Simplified73.5%
Taylor expanded in x around 0 72.0%
pow272.0%
Applied egg-rr72.0%
associate-/l*90.0%
Applied egg-rr90.0%
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 (<= (* z z) 1e+112)
(* 0.5 (+ y_m (/ (* x x) y_m)))
(* 0.5 (- y_m (* z (/ z 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 ((z * z) <= 1e+112) {
tmp = 0.5 * (y_m + ((x * x) / y_m));
} else {
tmp = 0.5 * (y_m - (z * (z / 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 ((z * z) <= 1d+112) then
tmp = 0.5d0 * (y_m + ((x * x) / y_m))
else
tmp = 0.5d0 * (y_m - (z * (z / 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 ((z * z) <= 1e+112) {
tmp = 0.5 * (y_m + ((x * x) / y_m));
} else {
tmp = 0.5 * (y_m - (z * (z / 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 (z * z) <= 1e+112: tmp = 0.5 * (y_m + ((x * x) / y_m)) else: tmp = 0.5 * (y_m - (z * (z / 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(z * z) <= 1e+112) tmp = Float64(0.5 * Float64(y_m + Float64(Float64(x * x) / y_m))); else tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / 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 ((z * z) <= 1e+112) tmp = 0.5 * (y_m + ((x * x) / y_m)); else tmp = 0.5 * (y_m - (z * (z / 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[(z * z), $MachinePrecision], 1e+112], N[(0.5 * N[(y$95$m + N[(N[(x * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m - N[(z * N[(z / 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}\;z \cdot z \leq 10^{+112}:\\
\;\;\;\;0.5 \cdot \left(y\_m + \frac{x \cdot x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999993e111Initial program 76.2%
remove-double-neg76.2%
distribute-lft-neg-out76.2%
distribute-frac-neg276.2%
distribute-frac-neg76.2%
neg-mul-176.2%
distribute-lft-neg-out76.2%
*-commutative76.2%
distribute-lft-neg-in76.2%
times-frac76.2%
metadata-eval76.2%
metadata-eval76.2%
associate--l+76.2%
fma-define76.2%
Simplified76.2%
Taylor expanded in x around 0 90.9%
associate--l+90.9%
div-sub91.5%
Simplified91.5%
Taylor expanded in z around 0 82.2%
unpow282.2%
Applied egg-rr82.2%
if 9.9999999999999993e111 < (*.f64 z z) Initial program 64.9%
remove-double-neg64.9%
distribute-lft-neg-out64.9%
distribute-frac-neg264.9%
distribute-frac-neg64.9%
neg-mul-164.9%
distribute-lft-neg-out64.9%
*-commutative64.9%
distribute-lft-neg-in64.9%
times-frac64.9%
metadata-eval64.9%
metadata-eval64.9%
associate--l+64.9%
fma-define66.9%
Simplified66.9%
Taylor expanded in x around 0 67.0%
associate--l+67.0%
div-sub75.1%
Simplified75.1%
Taylor expanded in x around 0 72.0%
pow272.0%
Applied egg-rr72.0%
associate-/l*88.8%
Applied egg-rr88.8%
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 4.3e+202) (* 0.5 (+ y_m (/ (* x x) 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 <= 4.3e+202) {
tmp = 0.5 * (y_m + ((x * x) / 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 <= 4.3d+202) then
tmp = 0.5d0 * (y_m + ((x * x) / 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 <= 4.3e+202) {
tmp = 0.5 * (y_m + ((x * x) / 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 <= 4.3e+202: tmp = 0.5 * (y_m + ((x * x) / 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 <= 4.3e+202) tmp = Float64(0.5 * Float64(y_m + Float64(Float64(x * x) / 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 <= 4.3e+202) tmp = 0.5 * (y_m + ((x * x) / 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, 4.3e+202], N[(0.5 * N[(y$95$m + N[(N[(x * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $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 4.3 \cdot 10^{+202}:\\
\;\;\;\;0.5 \cdot \left(y\_m + \frac{x \cdot x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 4.3000000000000002e202Initial program 77.1%
remove-double-neg77.1%
distribute-lft-neg-out77.1%
distribute-frac-neg277.1%
distribute-frac-neg77.1%
neg-mul-177.1%
distribute-lft-neg-out77.1%
*-commutative77.1%
distribute-lft-neg-in77.1%
times-frac77.1%
metadata-eval77.1%
metadata-eval77.1%
associate--l+77.1%
fma-define78.0%
Simplified78.0%
Taylor expanded in x around 0 83.8%
associate--l+83.8%
div-sub87.6%
Simplified87.6%
Taylor expanded in z around 0 62.2%
unpow262.2%
Applied egg-rr62.2%
if 4.3000000000000002e202 < y Initial program 9.9%
remove-double-neg9.9%
distribute-lft-neg-out9.9%
distribute-frac-neg29.9%
distribute-frac-neg9.9%
neg-mul-19.9%
distribute-lft-neg-out9.9%
*-commutative9.9%
distribute-lft-neg-in9.9%
times-frac9.9%
metadata-eval9.9%
metadata-eval9.9%
associate--l+9.9%
fma-define9.9%
Simplified9.9%
Taylor expanded in y around inf 71.5%
Final simplification63.0%
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 71.9%
remove-double-neg71.9%
distribute-lft-neg-out71.9%
distribute-frac-neg271.9%
distribute-frac-neg71.9%
neg-mul-171.9%
distribute-lft-neg-out71.9%
*-commutative71.9%
distribute-lft-neg-in71.9%
times-frac71.9%
metadata-eval71.9%
metadata-eval71.9%
associate--l+71.9%
fma-define72.7%
Simplified72.7%
Taylor expanded in y around inf 36.5%
Final simplification36.5%
(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 2024180
(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)))