
(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 8 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 (<= y_m 2.4e+44)
(* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
(* 0.5 (- (+ y_m (/ x (/ y_m x))) (* 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 (y_m <= 2.4e+44) {
tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
} else {
tmp = 0.5 * ((y_m + (x / (y_m / x))) - (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 (y_m <= 2.4e+44) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m)); else tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x / Float64(y_m / x))) - Float64(z * Float64(z / y_m)))); end return Float64(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, 2.4e+44], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 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}\;y\_m \leq 2.4 \cdot 10^{+44}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x}{\frac{y\_m}{x}}\right) - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 2.40000000000000013e44Initial program 80.1%
remove-double-neg80.1%
distribute-lft-neg-out80.1%
distribute-frac-neg280.1%
distribute-frac-neg80.1%
neg-mul-180.1%
distribute-lft-neg-out80.1%
*-commutative80.1%
distribute-lft-neg-in80.1%
times-frac80.1%
metadata-eval80.1%
metadata-eval80.1%
associate--l+80.1%
fma-define82.1%
Simplified82.1%
if 2.40000000000000013e44 < y Initial program 27.8%
remove-double-neg27.8%
distribute-lft-neg-out27.8%
distribute-frac-neg227.8%
distribute-frac-neg27.8%
neg-mul-127.8%
distribute-lft-neg-out27.8%
*-commutative27.8%
distribute-lft-neg-in27.8%
times-frac27.8%
metadata-eval27.8%
metadata-eval27.8%
associate--l+27.8%
fma-define27.8%
Simplified27.8%
Taylor expanded in x around 0 74.6%
unpow274.6%
*-un-lft-identity74.6%
times-frac83.8%
Applied egg-rr83.8%
unpow283.8%
*-un-lft-identity83.8%
times-frac99.9%
Applied egg-rr99.9%
/-rgt-identity99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification85.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 (/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))))
(*
y_s
(if (<= t_0 0.0)
(* 0.5 (+ y_m (/ 1.0 (* (/ -1.0 z) (/ y_m z)))))
(if (<= t_0 INFINITY)
(* 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 t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (y_m + (1.0 / ((-1.0 / z) * (y_m / z))));
} else if (t_0 <= ((double) INFINITY)) {
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.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 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (y_m + (1.0 / ((-1.0 / z) * (y_m / z))));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
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): t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0) tmp = 0 if t_0 <= 0.0: tmp = 0.5 * (y_m + (1.0 / ((-1.0 / z) * (y_m / z)))) elif t_0 <= math.inf: 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) t_0 = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.5 * Float64(y_m + Float64(1.0 / Float64(Float64(-1.0 / z) * Float64(y_m / z))))); elseif (t_0 <= Inf) tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(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) t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.5 * (y_m + (1.0 / ((-1.0 / z) * (y_m / z)))); elseif (t_0 <= Inf) 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_] := Block[{t$95$0 = N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(y$95$m + N[(1.0 / N[(N[(-1.0 / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $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)
\\
\begin{array}{l}
t_0 := \frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(y\_m + \frac{1}{\frac{-1}{z} \cdot \frac{y\_m}{z}}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{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))) < 0.0Initial program 78.3%
remove-double-neg78.3%
distribute-lft-neg-out78.3%
distribute-frac-neg278.3%
distribute-frac-neg78.3%
neg-mul-178.3%
distribute-lft-neg-out78.3%
*-commutative78.3%
distribute-lft-neg-in78.3%
times-frac78.3%
metadata-eval78.3%
metadata-eval78.3%
associate--l+78.3%
fma-define78.3%
Simplified78.3%
Taylor expanded in x around 0 86.4%
associate--l+86.4%
div-sub91.4%
Simplified91.4%
clear-num91.4%
inv-pow91.4%
Applied egg-rr91.4%
unpow-191.4%
Simplified91.4%
Taylor expanded in x around 0 62.1%
neg-mul-162.1%
distribute-neg-frac62.1%
Simplified62.1%
neg-mul-162.1%
unpow262.1%
times-frac66.0%
Applied egg-rr66.0%
if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 72.3%
remove-double-neg72.3%
distribute-lft-neg-out72.3%
distribute-frac-neg272.3%
distribute-frac-neg72.3%
neg-mul-172.3%
distribute-lft-neg-out72.3%
*-commutative72.3%
distribute-lft-neg-in72.3%
times-frac72.3%
metadata-eval72.3%
metadata-eval72.3%
associate--l+72.3%
fma-define72.3%
Simplified72.3%
Taylor expanded in x around 0 87.3%
associate--l+87.3%
div-sub92.5%
Simplified92.5%
Taylor expanded in z around 0 59.0%
+-commutative59.0%
unpow259.0%
associate-*r/64.6%
fma-define64.6%
Simplified64.6%
fma-undefine64.6%
Applied egg-rr64.6%
if +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 0.0%
remove-double-neg0.0%
distribute-lft-neg-out0.0%
distribute-frac-neg20.0%
distribute-frac-neg0.0%
neg-mul-10.0%
distribute-lft-neg-out0.0%
*-commutative0.0%
distribute-lft-neg-in0.0%
times-frac0.0%
metadata-eval0.0%
metadata-eval0.0%
associate--l+0.0%
fma-define20.0%
Simplified20.0%
Taylor expanded in x around 0 10.9%
associate--l+10.9%
div-sub10.9%
Simplified10.9%
clear-num10.9%
inv-pow10.9%
Applied egg-rr10.9%
unpow-110.9%
Simplified10.9%
Taylor expanded in x around 0 46.3%
neg-mul-146.3%
distribute-neg-frac46.3%
Simplified46.3%
clear-num46.3%
distribute-frac-neg246.3%
unpow246.3%
*-un-lft-identity46.3%
frac-times85.0%
/-rgt-identity85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
Applied egg-rr85.0%
Final simplification66.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 2.45e+29)
(/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))
(* 0.5 (- (+ y_m (/ x (/ y_m x))) (* 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 (y_m <= 2.45e+29) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * ((y_m + (x / (y_m / x))) - (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 (y_m <= 2.45d+29) then
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
else
tmp = 0.5d0 * ((y_m + (x / (y_m / x))) - (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 (y_m <= 2.45e+29) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * ((y_m + (x / (y_m / x))) - (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 y_m <= 2.45e+29: tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0) else: tmp = 0.5 * ((y_m + (x / (y_m / x))) - (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 (y_m <= 2.45e+29) tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0)); else tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x / Float64(y_m / x))) - 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 (y_m <= 2.45e+29) tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0); else tmp = 0.5 * ((y_m + (x / (y_m / x))) - (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[y$95$m, 2.45e+29], N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 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}\;y\_m \leq 2.45 \cdot 10^{+29}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x}{\frac{y\_m}{x}}\right) - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 2.4500000000000001e29Initial program 80.1%
if 2.4500000000000001e29 < y Initial program 32.4%
remove-double-neg32.4%
distribute-lft-neg-out32.4%
distribute-frac-neg232.4%
distribute-frac-neg32.4%
neg-mul-132.4%
distribute-lft-neg-out32.4%
*-commutative32.4%
distribute-lft-neg-in32.4%
times-frac32.4%
metadata-eval32.4%
metadata-eval32.4%
associate--l+32.4%
fma-define34.1%
Simplified34.1%
Taylor expanded in x around 0 75.0%
unpow275.0%
*-un-lft-identity75.0%
times-frac83.5%
Applied egg-rr83.5%
unpow283.5%
*-un-lft-identity83.5%
times-frac98.1%
Applied egg-rr98.1%
/-rgt-identity98.1%
clear-num98.2%
un-div-inv98.2%
Applied egg-rr98.2%
Final simplification84.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.45e+39)
(* 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 <= 2.45e+39) {
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 <= 2.45d+39) 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 <= 2.45e+39) {
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 <= 2.45e+39: 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 (z <= 2.45e+39) tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(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 <= 2.45e+39) 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[z, 2.45e+39], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $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 2.45 \cdot 10^{+39}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if z < 2.44999999999999994e39Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-frac-neg270.7%
distribute-frac-neg70.7%
neg-mul-170.7%
distribute-lft-neg-out70.7%
*-commutative70.7%
distribute-lft-neg-in70.7%
times-frac70.7%
metadata-eval70.7%
metadata-eval70.7%
associate--l+70.7%
fma-define71.8%
Simplified71.8%
Taylor expanded in x around 0 84.5%
associate--l+84.5%
div-sub88.1%
Simplified88.1%
Taylor expanded in z around 0 66.3%
+-commutative66.3%
unpow266.3%
associate-*r/71.1%
fma-define71.1%
Simplified71.1%
fma-undefine71.1%
Applied egg-rr71.1%
if 2.44999999999999994e39 < z Initial program 65.6%
remove-double-neg65.6%
distribute-lft-neg-out65.6%
distribute-frac-neg265.6%
distribute-frac-neg65.6%
neg-mul-165.6%
distribute-lft-neg-out65.6%
*-commutative65.6%
distribute-lft-neg-in65.6%
times-frac65.6%
metadata-eval65.6%
metadata-eval65.6%
associate--l+65.6%
fma-define68.8%
Simplified68.8%
Taylor expanded in x around 0 69.9%
associate--l+69.9%
div-sub77.9%
Simplified77.9%
clear-num78.0%
inv-pow78.0%
Applied egg-rr78.0%
unpow-178.0%
Simplified78.0%
Taylor expanded in x around 0 73.6%
neg-mul-173.6%
distribute-neg-frac73.6%
Simplified73.6%
clear-num73.6%
distribute-frac-neg273.6%
unpow273.6%
*-un-lft-identity73.6%
frac-times87.5%
/-rgt-identity87.5%
*-commutative87.5%
distribute-rgt-neg-in87.5%
Applied egg-rr87.5%
Final simplification75.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 (<= y_m 9.6e+129) (* 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 <= 9.6e+129) {
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 <= 9.6d+129) 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 <= 9.6e+129) {
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 <= 9.6e+129: 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 <= 9.6e+129) tmp = Float64(x * Float64(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 <= 9.6e+129) 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, 9.6e+129], N[(x * N[(x * N[(0.5 / 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 9.6 \cdot 10^{+129}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 9.5999999999999995e129Initial program 79.3%
remove-double-neg79.3%
distribute-lft-neg-out79.3%
distribute-frac-neg279.3%
distribute-frac-neg79.3%
neg-mul-179.3%
distribute-lft-neg-out79.3%
*-commutative79.3%
distribute-lft-neg-in79.3%
times-frac79.3%
metadata-eval79.3%
metadata-eval79.3%
associate--l+79.3%
fma-define81.1%
Simplified81.1%
Taylor expanded in x around inf 34.9%
*-commutative34.9%
associate-*l/34.9%
associate-*r/34.9%
Simplified34.9%
add-sqr-sqrt15.5%
pow215.5%
sqrt-prod15.2%
sqrt-pow116.6%
metadata-eval16.6%
pow116.6%
Applied egg-rr16.6%
unpow216.6%
swap-sqr15.2%
add-sqr-sqrt34.9%
*-commutative34.9%
associate-*r*36.7%
Applied egg-rr36.7%
if 9.5999999999999995e129 < y Initial program 13.3%
remove-double-neg13.3%
distribute-lft-neg-out13.3%
distribute-frac-neg213.3%
distribute-frac-neg13.3%
neg-mul-113.3%
distribute-lft-neg-out13.3%
*-commutative13.3%
distribute-lft-neg-in13.3%
times-frac13.3%
metadata-eval13.3%
metadata-eval13.3%
associate--l+13.3%
fma-define13.3%
Simplified13.3%
Taylor expanded in y around inf 84.9%
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 (if (<= y_m 9.6e+129) (* (* 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 <= 9.6e+129) {
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 <= 9.6d+129) 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 <= 9.6e+129) {
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 <= 9.6e+129: 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 <= 9.6e+129) 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 <= 9.6e+129) 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, 9.6e+129], 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 9.6 \cdot 10^{+129}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 9.5999999999999995e129Initial program 79.3%
remove-double-neg79.3%
distribute-lft-neg-out79.3%
distribute-frac-neg279.3%
distribute-frac-neg79.3%
neg-mul-179.3%
distribute-lft-neg-out79.3%
*-commutative79.3%
distribute-lft-neg-in79.3%
times-frac79.3%
metadata-eval79.3%
metadata-eval79.3%
associate--l+79.3%
fma-define81.1%
Simplified81.1%
Taylor expanded in x around inf 34.9%
*-commutative34.9%
associate-*l/34.9%
associate-*r/34.9%
Simplified34.9%
unpow234.9%
Applied egg-rr34.9%
if 9.5999999999999995e129 < y Initial program 13.3%
remove-double-neg13.3%
distribute-lft-neg-out13.3%
distribute-frac-neg213.3%
distribute-frac-neg13.3%
neg-mul-113.3%
distribute-lft-neg-out13.3%
*-commutative13.3%
distribute-lft-neg-in13.3%
times-frac13.3%
metadata-eval13.3%
metadata-eval13.3%
associate--l+13.3%
fma-define13.3%
Simplified13.3%
Taylor expanded in y around inf 84.9%
Final simplification42.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 (* 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 69.5%
remove-double-neg69.5%
distribute-lft-neg-out69.5%
distribute-frac-neg269.5%
distribute-frac-neg69.5%
neg-mul-169.5%
distribute-lft-neg-out69.5%
*-commutative69.5%
distribute-lft-neg-in69.5%
times-frac69.5%
metadata-eval69.5%
metadata-eval69.5%
associate--l+69.5%
fma-define71.0%
Simplified71.0%
Taylor expanded in x around 0 80.9%
associate--l+80.9%
div-sub85.6%
Simplified85.6%
Taylor expanded in z around 0 56.4%
+-commutative56.4%
unpow256.4%
associate-*r/61.1%
fma-define61.1%
Simplified61.1%
fma-undefine61.1%
Applied egg-rr61.1%
Final simplification61.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 (* 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 69.5%
remove-double-neg69.5%
distribute-lft-neg-out69.5%
distribute-frac-neg269.5%
distribute-frac-neg69.5%
neg-mul-169.5%
distribute-lft-neg-out69.5%
*-commutative69.5%
distribute-lft-neg-in69.5%
times-frac69.5%
metadata-eval69.5%
metadata-eval69.5%
associate--l+69.5%
fma-define71.0%
Simplified71.0%
Taylor expanded in y around inf 31.0%
Final simplification31.0%
(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 2024191
(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)))