
(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 (* y_s (* 0.5 (+ y_m (* (/ (- x z) (sqrt y_m)) (/ (+ x z) (sqrt 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 - z) / sqrt(y_m)) * ((x + z) / sqrt(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 - z) / sqrt(y_m)) * ((x + z) / sqrt(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 - z) / Math.sqrt(y_m)) * ((x + z) / Math.sqrt(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 - z) / math.sqrt(y_m)) * ((x + z) / math.sqrt(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(Float64(Float64(x - z) / sqrt(y_m)) * Float64(Float64(x + z) / sqrt(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 - z) / sqrt(y_m)) * ((x + z) / sqrt(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[(N[(N[(x - z), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $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 + \frac{x - z}{\sqrt{y\_m}} \cdot \frac{x + z}{\sqrt{y\_m}}\right)\right)
\end{array}
Initial program 71.1%
remove-double-neg71.1%
distribute-lft-neg-out71.1%
distribute-frac-neg271.1%
distribute-frac-neg71.1%
neg-mul-171.1%
distribute-lft-neg-out71.1%
*-commutative71.1%
distribute-lft-neg-in71.1%
times-frac71.1%
metadata-eval71.1%
metadata-eval71.1%
associate--l+71.1%
fma-define72.2%
Simplified72.2%
Taylor expanded in x around 0 82.7%
associate--l+82.7%
div-sub85.4%
Simplified85.4%
add-cbrt-cube69.0%
pow369.0%
Applied egg-rr69.0%
rem-cbrt-cube85.4%
unpow285.4%
unpow285.4%
difference-of-squares89.4%
Applied egg-rr89.4%
*-commutative89.4%
add-sqr-sqrt44.5%
times-frac48.7%
Applied egg-rr48.7%
Final simplification48.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
(if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) 0.0)
(* 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 tmp;
if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) {
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.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)) <= 0.0d0) then
tmp = 0.5d0 * (y_m - (z * (z / y_m)))
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)) <= 0.0) {
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): tmp = 0 if ((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0: 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) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= 0.0) 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) tmp = 0.0; if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) 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_] := 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], 0.0], 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)
\\
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 0:\\
\;\;\;\;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}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 0.0Initial program 74.0%
remove-double-neg74.0%
distribute-lft-neg-out74.0%
distribute-frac-neg274.0%
distribute-frac-neg74.0%
neg-mul-174.0%
distribute-lft-neg-out74.0%
*-commutative74.0%
distribute-lft-neg-in74.0%
times-frac74.0%
metadata-eval74.0%
metadata-eval74.0%
associate--l+74.0%
fma-define74.0%
Simplified74.0%
Taylor expanded in x around 0 85.3%
associate--l+85.3%
div-sub90.3%
Simplified90.3%
add-cbrt-cube71.0%
pow371.0%
Applied egg-rr71.0%
rem-cbrt-cube90.3%
unpow290.3%
unpow290.3%
difference-of-squares90.3%
Applied egg-rr90.3%
Taylor expanded in x around 0 57.1%
+-commutative57.1%
distribute-lft-in54.6%
associate-+l+54.8%
*-commutative54.8%
associate-*l*54.8%
associate-*l/57.2%
associate-*r/59.6%
*-commutative59.6%
associate-*l*59.6%
*-commutative59.6%
associate-*r/61.2%
associate-*l/58.8%
*-commutative58.8%
mul-1-neg58.8%
distribute-frac-neg258.8%
unpow258.8%
associate-/l*61.6%
distribute-neg-frac261.6%
mul-1-neg61.6%
distribute-lft-in62.4%
+-commutative62.4%
Simplified66.6%
if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 68.4%
remove-double-neg68.4%
distribute-lft-neg-out68.4%
distribute-frac-neg268.4%
distribute-frac-neg68.4%
neg-mul-168.4%
distribute-lft-neg-out68.4%
*-commutative68.4%
distribute-lft-neg-in68.4%
times-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
associate--l+68.4%
fma-define70.6%
Simplified70.6%
Taylor expanded in x around 0 80.3%
associate--l+80.3%
div-sub81.1%
Simplified81.1%
add-cbrt-cube67.1%
pow367.1%
Applied egg-rr67.1%
rem-cbrt-cube81.1%
unpow281.1%
unpow281.1%
difference-of-squares88.6%
Applied egg-rr88.6%
Taylor expanded in z around 0 49.6%
distribute-rgt-in48.1%
associate-+l+48.1%
associate-*l*48.1%
*-commutative48.1%
associate-*r/48.9%
associate-*l/52.6%
associate-*l*52.6%
*-commutative52.6%
associate-*l/53.9%
associate-*r/54.0%
unpow254.0%
associate-/l*60.1%
distribute-lft-in61.6%
+-commutative61.6%
+-commutative61.6%
distribute-lft-in64.6%
associate-+l+64.6%
distribute-rgt1-in64.6%
metadata-eval64.6%
mul0-lft67.6%
Simplified67.6%
Final simplification67.1%
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 2.05e+176)
(* 0.5 (+ y_m (* x (/ x y_m))))
(* z (* z (/ -0.5 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 <= 2.05e+176) {
tmp = 0.5 * (y_m + (x * (x / y_m)));
} else {
tmp = z * (z * (-0.5 / 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 <= 2.05d+176) then
tmp = 0.5d0 * (y_m + (x * (x / y_m)))
else
tmp = z * (z * ((-0.5d0) / 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 <= 2.05e+176) {
tmp = 0.5 * (y_m + (x * (x / y_m)));
} else {
tmp = z * (z * (-0.5 / 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 <= 2.05e+176: tmp = 0.5 * (y_m + (x * (x / y_m))) else: tmp = z * (z * (-0.5 / 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 <= 2.05e+176) tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / y_m)))); else tmp = Float64(z * Float64(z * Float64(-0.5 / 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 <= 2.05e+176) tmp = 0.5 * (y_m + (x * (x / y_m))); else tmp = z * (z * (-0.5 / 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, 2.05e+176], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(z * N[(-0.5 / y$95$m), $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 2.05 \cdot 10^{+176}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\end{array}
\end{array}
if z < 2.05e176Initial program 72.2%
remove-double-neg72.2%
distribute-lft-neg-out72.2%
distribute-frac-neg272.2%
distribute-frac-neg72.2%
neg-mul-172.2%
distribute-lft-neg-out72.2%
*-commutative72.2%
distribute-lft-neg-in72.2%
times-frac72.2%
metadata-eval72.2%
metadata-eval72.2%
associate--l+72.2%
fma-define72.6%
Simplified72.6%
Taylor expanded in x around 0 84.4%
associate--l+84.4%
div-sub87.4%
Simplified87.4%
add-cbrt-cube69.4%
pow369.4%
Applied egg-rr69.4%
rem-cbrt-cube87.4%
unpow287.4%
unpow287.4%
difference-of-squares90.5%
Applied egg-rr90.5%
Taylor expanded in z around 0 55.6%
distribute-rgt-in54.8%
associate-+l+54.8%
associate-*l*54.8%
*-commutative54.8%
associate-*r/56.6%
associate-*l/58.7%
associate-*l*58.7%
*-commutative58.7%
associate-*l/60.7%
associate-*r/60.8%
unpow260.8%
associate-/l*67.4%
distribute-lft-in68.7%
+-commutative68.7%
+-commutative68.7%
distribute-lft-in71.3%
associate-+l+71.2%
distribute-rgt1-in71.2%
metadata-eval71.2%
mul0-lft73.8%
Simplified73.8%
if 2.05e176 < z Initial program 59.4%
Taylor expanded in z around inf 73.7%
associate-*r/73.7%
metadata-eval73.7%
distribute-lft-neg-in73.7%
*-commutative73.7%
distribute-neg-frac73.7%
associate-*r/73.7%
distribute-rgt-neg-in73.7%
distribute-neg-frac73.7%
metadata-eval73.7%
Simplified73.7%
add-cbrt-cube73.7%
pow373.7%
Applied egg-rr73.7%
rem-cbrt-cube73.7%
*-commutative73.7%
unpow273.7%
associate-*r*86.3%
Applied egg-rr86.3%
Final simplification74.9%
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 3e+38) (* z (* z (/ -0.5 y_m))) (* 0.5 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 (y_m <= 3e+38) {
tmp = z * (z * (-0.5 / y_m));
} else {
tmp = 0.5 * 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 (y_m <= 3d+38) then
tmp = z * (z * ((-0.5d0) / y_m))
else
tmp = 0.5d0 * 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 (y_m <= 3e+38) {
tmp = z * (z * (-0.5 / y_m));
} else {
tmp = 0.5 * 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 y_m <= 3e+38: tmp = z * (z * (-0.5 / y_m)) else: tmp = 0.5 * 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 (y_m <= 3e+38) tmp = Float64(z * Float64(z * Float64(-0.5 / y_m))); else tmp = Float64(0.5 * 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 (y_m <= 3e+38) tmp = z * (z * (-0.5 / y_m)); else tmp = 0.5 * 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[y$95$m, 3e+38], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y$95$m), $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 \cdot 10^{+38}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\_m\\
\end{array}
\end{array}
if y < 3.0000000000000001e38Initial program 76.8%
Taylor expanded in z around inf 35.5%
associate-*r/35.5%
metadata-eval35.5%
distribute-lft-neg-in35.5%
*-commutative35.5%
distribute-neg-frac35.5%
associate-*r/35.5%
distribute-rgt-neg-in35.5%
distribute-neg-frac35.5%
metadata-eval35.5%
Simplified35.5%
add-cbrt-cube28.2%
pow328.2%
Applied egg-rr28.2%
rem-cbrt-cube35.5%
*-commutative35.5%
unpow235.5%
associate-*r*37.7%
Applied egg-rr37.7%
if 3.0000000000000001e38 < y Initial program 48.1%
Taylor expanded in y around inf 68.6%
*-commutative68.6%
Simplified68.6%
Final simplification43.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 (* 0.5 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);
}
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)
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);
}
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)
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 * 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); 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 * y$95$m), $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 y\_m\right)
\end{array}
Initial program 71.1%
Taylor expanded in y around inf 36.9%
*-commutative36.9%
Simplified36.9%
Final simplification36.9%
(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 2024100
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))