
(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 9 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 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 7.6e+86)
(/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
(* 0.5 (+ (- y_m (/ z (/ y_m z))) (* 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 (y_m <= 7.6e+86) {
tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
} else {
tmp = 0.5 * ((y_m - (z / (y_m / z))) + (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 (y_m <= 7.6e+86) tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0)); else tmp = Float64(0.5 * Float64(Float64(y_m - Float64(z / Float64(y_m / z))) + Float64(x * Float64(x / 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, 7.6e+86], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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}\;y\_m \leq 7.6 \cdot 10^{+86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y\_m - z, y\_m + z, x \cdot x\right)}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m - \frac{z}{\frac{y\_m}{z}}\right) + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if y < 7.59999999999999956e86Initial program 74.7%
associate--l+74.7%
+-commutative74.7%
sqr-neg74.7%
difference-of-squares76.3%
fma-def78.2%
sub-neg78.2%
sub-neg78.2%
remove-double-neg78.2%
Simplified78.2%
if 7.59999999999999956e86 < y Initial program 31.2%
Taylor expanded in x around 0 31.2%
fma-def31.2%
div-sub31.2%
unpow231.2%
associate-/l*61.3%
*-inverses61.3%
/-rgt-identity61.3%
fma-def61.3%
distribute-lft-out61.3%
Simplified61.3%
unpow261.3%
*-un-lft-identity61.3%
times-frac84.3%
Applied egg-rr84.3%
unpow284.3%
*-un-lft-identity84.3%
times-frac99.9%
Applied egg-rr99.9%
/-rgt-identity99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification82.0%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (/ (/ x y_m) (/ 2.0 x)))
(t_1 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))
(*
y_s
(if (<= x 1.02e+42)
t_1
(if (<= x 1.5e+87)
t_0
(if (<= x 3.15e+131)
t_1
(if (<= x 1e+158)
(/ (* x 0.5) (/ y_m x))
(if (<= x 2.2e+207) t_1 t_0))))))))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 / y_m) / (2.0 / x);
double t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
double tmp;
if (x <= 1.02e+42) {
tmp = t_1;
} else if (x <= 1.5e+87) {
tmp = t_0;
} else if (x <= 3.15e+131) {
tmp = t_1;
} else if (x <= 1e+158) {
tmp = (x * 0.5) / (y_m / x);
} else if (x <= 2.2e+207) {
tmp = t_1;
} else {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / y_m) / (2.0d0 / x)
t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
if (x <= 1.02d+42) then
tmp = t_1
else if (x <= 1.5d+87) then
tmp = t_0
else if (x <= 3.15d+131) then
tmp = t_1
else if (x <= 1d+158) then
tmp = (x * 0.5d0) / (y_m / x)
else if (x <= 2.2d+207) then
tmp = t_1
else
tmp = t_0
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 / y_m) / (2.0 / x);
double t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
double tmp;
if (x <= 1.02e+42) {
tmp = t_1;
} else if (x <= 1.5e+87) {
tmp = t_0;
} else if (x <= 3.15e+131) {
tmp = t_1;
} else if (x <= 1e+158) {
tmp = (x * 0.5) / (y_m / x);
} else if (x <= 2.2e+207) {
tmp = t_1;
} else {
tmp = t_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): t_0 = (x / y_m) / (2.0 / x) t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0) tmp = 0 if x <= 1.02e+42: tmp = t_1 elif x <= 1.5e+87: tmp = t_0 elif x <= 3.15e+131: tmp = t_1 elif x <= 1e+158: tmp = (x * 0.5) / (y_m / x) elif x <= 2.2e+207: tmp = t_1 else: tmp = t_0 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(x / y_m) / Float64(2.0 / x)) t_1 = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0)) tmp = 0.0 if (x <= 1.02e+42) tmp = t_1; elseif (x <= 1.5e+87) tmp = t_0; elseif (x <= 3.15e+131) tmp = t_1; elseif (x <= 1e+158) tmp = Float64(Float64(x * 0.5) / Float64(y_m / x)); elseif (x <= 2.2e+207) tmp = t_1; else tmp = t_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) t_0 = (x / y_m) / (2.0 / x); t_1 = ((y_m - z) / y_m) * ((y_m + z) / 2.0); tmp = 0.0; if (x <= 1.02e+42) tmp = t_1; elseif (x <= 1.5e+87) tmp = t_0; elseif (x <= 3.15e+131) tmp = t_1; elseif (x <= 1e+158) tmp = (x * 0.5) / (y_m / x); elseif (x <= 2.2e+207) tmp = t_1; else tmp = t_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_] := Block[{t$95$0 = N[(N[(x / y$95$m), $MachinePrecision] / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.02e+42], t$95$1, If[LessEqual[x, 1.5e+87], t$95$0, If[LessEqual[x, 3.15e+131], t$95$1, If[LessEqual[x, 1e+158], N[(N[(x * 0.5), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e+207], t$95$1, t$95$0]]]]]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{\frac{x}{y\_m}}{\frac{2}{x}}\\
t_1 := \frac{y\_m - z}{y\_m} \cdot \frac{y\_m + z}{2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.15 \cdot 10^{+131}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 10^{+158}:\\
\;\;\;\;\frac{x \cdot 0.5}{\frac{y\_m}{x}}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+207}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if x < 1.01999999999999996e42 or 1.4999999999999999e87 < x < 3.14999999999999998e131 or 9.99999999999999953e157 < x < 2.20000000000000009e207Initial program 65.2%
associate--l+65.2%
+-commutative65.2%
sqr-neg65.2%
difference-of-squares68.3%
fma-def70.1%
sub-neg70.1%
sub-neg70.1%
remove-double-neg70.1%
Simplified70.1%
Taylor expanded in x around 0 51.7%
*-commutative51.7%
times-frac74.4%
Applied egg-rr74.4%
if 1.01999999999999996e42 < x < 1.4999999999999999e87 or 2.20000000000000009e207 < x Initial program 81.6%
Taylor expanded in x around inf 78.9%
unpow278.9%
times-frac87.6%
Applied egg-rr87.6%
clear-num87.5%
un-div-inv87.6%
Applied egg-rr87.6%
if 3.14999999999999998e131 < x < 9.99999999999999953e157Initial program 68.5%
Taylor expanded in x around inf 35.1%
unpow235.1%
times-frac66.1%
Applied egg-rr66.1%
div-inv66.1%
metadata-eval66.1%
*-commutative66.1%
remove-double-div65.8%
div-inv65.8%
times-frac66.7%
un-div-inv66.7%
Applied egg-rr66.7%
Final simplification75.9%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 9.5e+147)
(/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
(* (/ (- y_m z) y_m) (/ (+ y_m z) 2.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 <= 9.5e+147) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 <= 9.5d+147) then
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
else
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 <= 9.5e+147) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 <= 9.5e+147: tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0) else: tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 <= 9.5e+147) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)); else tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.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 <= 9.5e+147) tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0); else tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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, 9.5e+147], 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[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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 9.5 \cdot 10^{+147}:\\
\;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m - z}{y\_m} \cdot \frac{y\_m + z}{2}\\
\end{array}
\end{array}
if y < 9.4999999999999996e147Initial program 74.5%
if 9.4999999999999996e147 < y Initial program 16.8%
associate--l+16.8%
+-commutative16.8%
sqr-neg16.8%
difference-of-squares27.5%
fma-def30.6%
sub-neg30.6%
sub-neg30.6%
remove-double-neg30.6%
Simplified30.6%
Taylor expanded in x around 0 30.6%
*-commutative30.6%
times-frac81.7%
Applied egg-rr81.7%
Final simplification75.4%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= z 4.1e+149)
(* 0.5 (+ (- y_m (/ z (/ y_m z))) (* x (/ x y_m))))
(* (/ (- y_m z) y_m) (/ (+ y_m z) 2.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 (z <= 4.1e+149) {
tmp = 0.5 * ((y_m - (z / (y_m / z))) + (x * (x / y_m)));
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 (z <= 4.1d+149) then
tmp = 0.5d0 * ((y_m - (z / (y_m / z))) + (x * (x / y_m)))
else
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 (z <= 4.1e+149) {
tmp = 0.5 * ((y_m - (z / (y_m / z))) + (x * (x / y_m)));
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 z <= 4.1e+149: tmp = 0.5 * ((y_m - (z / (y_m / z))) + (x * (x / y_m))) else: tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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 (z <= 4.1e+149) tmp = Float64(0.5 * Float64(Float64(y_m - Float64(z / Float64(y_m / z))) + Float64(x * Float64(x / y_m)))); else tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.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 (z <= 4.1e+149) tmp = 0.5 * ((y_m - (z / (y_m / z))) + (x * (x / y_m))); else tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.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[z, 4.1e+149], N[(0.5 * N[(N[(y$95$m - N[(z / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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 4.1 \cdot 10^{+149}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m - \frac{z}{\frac{y\_m}{z}}\right) + x \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m - z}{y\_m} \cdot \frac{y\_m + z}{2}\\
\end{array}
\end{array}
if z < 4.0999999999999996e149Initial program 69.0%
Taylor expanded in x around 0 64.1%
fma-def64.1%
div-sub64.1%
unpow264.1%
associate-/l*79.6%
*-inverses79.6%
/-rgt-identity79.6%
fma-def79.6%
distribute-lft-out79.6%
Simplified79.6%
unpow279.6%
*-un-lft-identity79.6%
times-frac87.6%
Applied egg-rr87.6%
unpow287.5%
*-un-lft-identity87.5%
times-frac91.4%
Applied egg-rr91.4%
/-rgt-identity91.4%
clear-num91.4%
un-div-inv91.4%
Applied egg-rr91.4%
if 4.0999999999999996e149 < z Initial program 57.0%
associate--l+57.0%
+-commutative57.0%
sqr-neg57.0%
difference-of-squares63.5%
fma-def71.6%
sub-neg71.6%
sub-neg71.6%
remove-double-neg71.6%
Simplified71.6%
Taylor expanded in x around 0 74.5%
*-commutative74.5%
times-frac91.9%
Applied egg-rr91.9%
Final simplification91.5%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 1.05e+53)
(/ (/ x y_m) (/ 2.0 x))
(/ 1.0 (* 2.0 (/ 1.0 (- y_m z)))))))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 <= 1.05e+53) {
tmp = (x / y_m) / (2.0 / x);
} else {
tmp = 1.0 / (2.0 * (1.0 / (y_m - z)));
}
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 <= 1.05d+53) then
tmp = (x / y_m) / (2.0d0 / x)
else
tmp = 1.0d0 / (2.0d0 * (1.0d0 / (y_m - z)))
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 <= 1.05e+53) {
tmp = (x / y_m) / (2.0 / x);
} else {
tmp = 1.0 / (2.0 * (1.0 / (y_m - z)));
}
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 <= 1.05e+53: tmp = (x / y_m) / (2.0 / x) else: tmp = 1.0 / (2.0 * (1.0 / (y_m - z))) 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 <= 1.05e+53) tmp = Float64(Float64(x / y_m) / Float64(2.0 / x)); else tmp = Float64(1.0 / Float64(2.0 * Float64(1.0 / Float64(y_m - z)))); 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 <= 1.05e+53) tmp = (x / y_m) / (2.0 / x); else tmp = 1.0 / (2.0 * (1.0 / (y_m - z))); 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, 1.05e+53], N[(N[(x / y$95$m), $MachinePrecision] / N[(2.0 / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 * N[(1.0 / N[(y$95$m - z), $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 1.05 \cdot 10^{+53}:\\
\;\;\;\;\frac{\frac{x}{y\_m}}{\frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \frac{1}{y\_m - z}}\\
\end{array}
\end{array}
if y < 1.0500000000000001e53Initial program 74.0%
Taylor expanded in x around inf 35.9%
unpow235.9%
times-frac37.2%
Applied egg-rr37.2%
clear-num37.2%
un-div-inv37.2%
Applied egg-rr37.2%
if 1.0500000000000001e53 < y Initial program 39.4%
associate--l+39.4%
+-commutative39.4%
sqr-neg39.4%
difference-of-squares46.2%
fma-def50.2%
sub-neg50.2%
sub-neg50.2%
remove-double-neg50.2%
Simplified50.2%
Taylor expanded in x around 0 43.9%
clear-num43.8%
inv-pow43.8%
*-commutative43.8%
*-un-lft-identity43.8%
times-frac43.8%
metadata-eval43.8%
Applied egg-rr43.8%
unpow-143.8%
associate-/r*76.5%
+-commutative76.5%
Simplified76.5%
Taylor expanded in y around inf 55.6%
Final simplification40.8%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 1.5e+53) (* 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 <= 1.5e+53) {
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 <= 1.5d+53) 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 <= 1.5e+53) {
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 <= 1.5e+53: 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 <= 1.5e+53) 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 <= 1.5e+53) 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, 1.5e+53], 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 1.5 \cdot 10^{+53}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 1.49999999999999999e53Initial program 74.0%
Taylor expanded in x around inf 35.9%
div-inv35.9%
unpow235.9%
metadata-eval35.9%
div-inv35.9%
clear-num35.9%
associate-*l*37.2%
Applied egg-rr37.2%
if 1.49999999999999999e53 < y Initial program 39.4%
Taylor expanded in y around inf 55.0%
Final simplification40.7%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 5.5e+52) (/ (* 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 <= 5.5e+52) {
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 <= 5.5d+52) 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 <= 5.5e+52) {
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 <= 5.5e+52: 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 <= 5.5e+52) tmp = Float64(Float64(x * Float64(x * 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 <= 5.5e+52) 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, 5.5e+52], N[(N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] / y$95$m), $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 5.5 \cdot 10^{+52}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot 0.5\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 5.49999999999999996e52Initial program 74.0%
Taylor expanded in x around inf 35.9%
div-inv35.9%
unpow235.9%
metadata-eval35.9%
div-inv35.9%
clear-num35.9%
associate-*l*37.2%
Applied egg-rr37.2%
/-rgt-identity37.2%
associate-*r/37.2%
frac-times35.9%
*-un-lft-identity35.9%
Applied egg-rr35.9%
if 5.49999999999999996e52 < y Initial program 39.4%
Taylor expanded in y around inf 55.0%
Final simplification39.6%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 8e+52) (/ (/ x y_m) (/ 2.0 x)) (* 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 <= 8e+52) {
tmp = (x / y_m) / (2.0 / x);
} 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 <= 8d+52) then
tmp = (x / y_m) / (2.0d0 / x)
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 <= 8e+52) {
tmp = (x / y_m) / (2.0 / x);
} 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 <= 8e+52: tmp = (x / y_m) / (2.0 / x) 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 <= 8e+52) tmp = Float64(Float64(x / y_m) / Float64(2.0 / x)); 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 <= 8e+52) tmp = (x / y_m) / (2.0 / x); 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, 8e+52], N[(N[(x / y$95$m), $MachinePrecision] / N[(2.0 / x), $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 8 \cdot 10^{+52}:\\
\;\;\;\;\frac{\frac{x}{y\_m}}{\frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 7.9999999999999999e52Initial program 74.0%
Taylor expanded in x around inf 35.9%
unpow235.9%
times-frac37.2%
Applied egg-rr37.2%
clear-num37.2%
un-div-inv37.2%
Applied egg-rr37.2%
if 7.9999999999999999e52 < y Initial program 39.4%
Taylor expanded in y around inf 55.0%
Final simplification40.7%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 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 67.2%
Taylor expanded in y around inf 31.7%
Final simplification31.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 2024040
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))