
(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 7 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 (<= t_0 -5e-61)
(* 0.5 (* (- x z) (/ z y_m)))
(if (<= t_0 INFINITY)
(* 0.5 (+ y_m (fma x (/ x y_m) (* z (/ 0.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 t_0 = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= -5e-61) {
tmp = 0.5 * ((x - z) * (z / y_m));
} else if (t_0 <= ((double) INFINITY)) {
tmp = 0.5 * (y_m + fma(x, (x / y_m), (z * (0.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) 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 <= -5e-61) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(z / y_m))); elseif (t_0 <= Inf) tmp = Float64(0.5 * Float64(y_m + fma(x, Float64(x / y_m), Float64(z * Float64(0.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 = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, -5e-61], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision] + N[(z * N[(0.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)
\\
\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 -5 \cdot 10^{-61}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{z}{y\_m}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y\_m + \mathsf{fma}\left(x, \frac{x}{y\_m}, z \cdot \frac{0}{y\_m}\right)\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))) < -4.9999999999999999e-61Initial program 79.2%
Taylor expanded in y around inf 86.1%
*-commutative86.1%
Simplified86.1%
unpow286.1%
unpow286.1%
difference-of-squares86.1%
Applied egg-rr86.1%
Taylor expanded in y around 0 66.8%
*-commutative66.8%
associate-/l*69.9%
+-commutative69.9%
Simplified69.9%
Taylor expanded in z around inf 40.6%
if -4.9999999999999999e-61 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 80.4%
remove-double-neg80.4%
distribute-lft-neg-out80.4%
distribute-frac-neg280.4%
distribute-frac-neg80.4%
neg-mul-180.4%
distribute-lft-neg-out80.4%
*-commutative80.4%
distribute-lft-neg-in80.4%
times-frac80.4%
metadata-eval80.4%
metadata-eval80.4%
associate--l+80.4%
fma-define80.4%
Simplified80.4%
prod-diff66.7%
fma-neg66.7%
difference-of-squares66.7%
fma-define66.7%
pow266.7%
Applied egg-rr66.7%
Taylor expanded in z around -inf 54.2%
Taylor expanded in z around 0 64.2%
Simplified69.2%
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.6%
metadata-eval0.6%
metadata-eval0.6%
associate--l+0.6%
fma-define24.7%
Simplified24.7%
prod-diff0.6%
fma-neg0.6%
difference-of-squares2.4%
fma-define23.1%
pow223.1%
Applied egg-rr23.1%
Taylor expanded in z around -inf 22.5%
Taylor expanded in z around 0 62.0%
Taylor expanded in x around 0 79.3%
neg-mul-179.3%
+-commutative79.3%
distribute-rgt1-in79.3%
metadata-eval79.3%
mul0-lft79.3%
associate-*r/79.3%
metadata-eval79.3%
unsub-neg79.3%
div079.3%
neg-sub079.3%
*-commutative79.3%
distribute-lft-neg-out79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Final simplification57.3%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 1e-150)
(* 0.5 (* (- x z) (/ (+ x z) y_m)))
(if (<= y_m 1.42e+141)
(/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
(* 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 (y_m <= 1e-150) {
tmp = 0.5 * ((x - z) * ((x + z) / y_m));
} else if (y_m <= 1.42e+141) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} 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 (y_m <= 1d-150) then
tmp = 0.5d0 * ((x - z) * ((x + z) / y_m))
else if (y_m <= 1.42d+141) then
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
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 (y_m <= 1e-150) {
tmp = 0.5 * ((x - z) * ((x + z) / y_m));
} else if (y_m <= 1.42e+141) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} 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 y_m <= 1e-150: tmp = 0.5 * ((x - z) * ((x + z) / y_m)) elif y_m <= 1.42e+141: tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0) 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 (y_m <= 1e-150) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(Float64(x + z) / y_m))); elseif (y_m <= 1.42e+141) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)); 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 (y_m <= 1e-150) tmp = 0.5 * ((x - z) * ((x + z) / y_m)); elseif (y_m <= 1.42e+141) tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0); 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[y$95$m, 1e-150], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.42e+141], 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[(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}\;y\_m \leq 10^{-150}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y\_m}\right)\\
\mathbf{elif}\;y\_m \leq 1.42 \cdot 10^{+141}:\\
\;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 1.00000000000000001e-150Initial program 75.5%
Taylor expanded in y around inf 76.4%
*-commutative76.4%
Simplified76.4%
unpow276.4%
unpow276.4%
difference-of-squares82.9%
Applied egg-rr82.9%
Taylor expanded in y around 0 73.9%
*-commutative73.9%
associate-/l*76.6%
+-commutative76.6%
Simplified76.6%
if 1.00000000000000001e-150 < y < 1.42000000000000005e141Initial program 94.2%
if 1.42000000000000005e141 < y Initial program 12.9%
remove-double-neg12.9%
distribute-lft-neg-out12.9%
distribute-frac-neg212.9%
distribute-frac-neg12.9%
neg-mul-112.9%
distribute-lft-neg-out12.9%
*-commutative12.9%
distribute-lft-neg-in12.9%
times-frac13.4%
metadata-eval13.4%
metadata-eval13.4%
associate--l+13.4%
fma-define13.4%
Simplified13.4%
prod-diff13.4%
fma-neg13.4%
difference-of-squares14.1%
fma-define14.2%
pow214.2%
Applied egg-rr14.2%
Taylor expanded in z around -inf 9.8%
Taylor expanded in z around 0 86.8%
Taylor expanded in x around 0 87.7%
neg-mul-187.7%
+-commutative87.7%
distribute-rgt1-in87.7%
metadata-eval87.7%
mul0-lft87.7%
associate-*r/87.7%
metadata-eval87.7%
unsub-neg87.7%
div087.7%
neg-sub087.7%
*-commutative87.7%
distribute-lft-neg-out87.7%
distribute-rgt-neg-in87.7%
Simplified87.7%
Final simplification81.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 (<= y_m 1.5e-19)
(* 0.5 (* (- x z) (/ z y_m)))
(if (<= y_m 1.55e+102) (* 0.5 (* (- x z) (/ 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 <= 1.5e-19) {
tmp = 0.5 * ((x - z) * (z / y_m));
} else if (y_m <= 1.55e+102) {
tmp = 0.5 * ((x - z) * (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 <= 1.5d-19) then
tmp = 0.5d0 * ((x - z) * (z / y_m))
else if (y_m <= 1.55d+102) then
tmp = 0.5d0 * ((x - z) * (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 <= 1.5e-19) {
tmp = 0.5 * ((x - z) * (z / y_m));
} else if (y_m <= 1.55e+102) {
tmp = 0.5 * ((x - z) * (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 <= 1.5e-19: tmp = 0.5 * ((x - z) * (z / y_m)) elif y_m <= 1.55e+102: tmp = 0.5 * ((x - z) * (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 <= 1.5e-19) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(z / y_m))); elseif (y_m <= 1.55e+102) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(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 <= 1.5e-19) tmp = 0.5 * ((x - z) * (z / y_m)); elseif (y_m <= 1.55e+102) tmp = 0.5 * ((x - z) * (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, 1.5e-19], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.55e+102], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(x / 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^{-19}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{z}{y\_m}\right)\\
\mathbf{elif}\;y\_m \leq 1.55 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 1.49999999999999996e-19Initial program 78.8%
Taylor expanded in y around inf 78.6%
*-commutative78.6%
Simplified78.6%
unpow278.6%
unpow278.6%
difference-of-squares84.2%
Applied egg-rr84.2%
Taylor expanded in y around 0 75.6%
*-commutative75.6%
associate-/l*77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in z around inf 49.8%
if 1.49999999999999996e-19 < y < 1.54999999999999993e102Initial program 87.6%
Taylor expanded in y around inf 87.7%
*-commutative87.7%
Simplified87.7%
unpow287.7%
unpow287.7%
difference-of-squares94.0%
Applied egg-rr94.0%
Taylor expanded in y around 0 81.7%
*-commutative81.7%
associate-/l*87.5%
+-commutative87.5%
Simplified87.5%
Taylor expanded in z around 0 63.6%
if 1.54999999999999993e102 < y Initial program 30.0%
Taylor expanded in y around inf 67.4%
*-commutative67.4%
Simplified67.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 (<= y_m 3.35e+93)
(* 0.5 (* (- x z) (/ (+ x z) 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 (y_m <= 3.35e+93) {
tmp = 0.5 * ((x - z) * ((x + z) / 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 (y_m <= 3.35d+93) then
tmp = 0.5d0 * ((x - z) * ((x + z) / 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 (y_m <= 3.35e+93) {
tmp = 0.5 * ((x - z) * ((x + z) / 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 y_m <= 3.35e+93: tmp = 0.5 * ((x - z) * ((x + z) / 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 (y_m <= 3.35e+93) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(Float64(x + z) / 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 (y_m <= 3.35e+93) tmp = 0.5 * ((x - z) * ((x + z) / 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[y$95$m, 3.35e+93], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $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}\;y\_m \leq 3.35 \cdot 10^{+93}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 3.34999999999999983e93Initial program 79.5%
Taylor expanded in y around inf 79.3%
*-commutative79.3%
Simplified79.3%
unpow279.3%
unpow279.3%
difference-of-squares85.0%
Applied egg-rr85.0%
Taylor expanded in y around 0 76.1%
*-commutative76.1%
associate-/l*78.7%
+-commutative78.7%
Simplified78.7%
if 3.34999999999999983e93 < y Initial program 30.0%
remove-double-neg30.0%
distribute-lft-neg-out30.0%
distribute-frac-neg230.0%
distribute-frac-neg30.0%
neg-mul-130.0%
distribute-lft-neg-out30.0%
*-commutative30.0%
distribute-lft-neg-in30.0%
times-frac30.4%
metadata-eval30.4%
metadata-eval30.4%
associate--l+30.4%
fma-define30.4%
Simplified30.4%
prod-diff30.4%
fma-neg30.4%
difference-of-squares31.0%
fma-define33.2%
pow233.2%
Applied egg-rr33.2%
Taylor expanded in z around -inf 14.6%
Taylor expanded in z around 0 89.7%
Taylor expanded in x around 0 81.9%
neg-mul-181.9%
+-commutative81.9%
distribute-rgt1-in81.9%
metadata-eval81.9%
mul0-lft81.9%
associate-*r/81.9%
metadata-eval81.9%
unsub-neg81.9%
div081.9%
neg-sub081.9%
*-commutative81.9%
distribute-lft-neg-out81.9%
distribute-rgt-neg-in81.9%
Simplified81.9%
Final simplification79.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= x 4.25e+89)
(* 0.5 (- y_m (* z (/ z y_m))))
(* 0.5 (* (- x z) (/ 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 <= 4.25e+89) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = 0.5 * ((x - z) * (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 <= 4.25d+89) then
tmp = 0.5d0 * (y_m - (z * (z / y_m)))
else
tmp = 0.5d0 * ((x - z) * (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 <= 4.25e+89) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = 0.5 * ((x - z) * (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 <= 4.25e+89: tmp = 0.5 * (y_m - (z * (z / y_m))) else: tmp = 0.5 * ((x - z) * (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 (x <= 4.25e+89) tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); else tmp = Float64(0.5 * Float64(Float64(x - z) * 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 <= 4.25e+89) tmp = 0.5 * (y_m - (z * (z / y_m))); else tmp = 0.5 * ((x - z) * (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[x, 4.25e+89], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(x / 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}\;x \leq 4.25 \cdot 10^{+89}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if x < 4.25000000000000023e89Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.3%
metadata-eval71.3%
metadata-eval71.3%
associate--l+71.3%
fma-define73.7%
Simplified73.7%
prod-diff54.6%
fma-neg54.6%
difference-of-squares54.8%
fma-define56.2%
pow256.2%
Applied egg-rr56.2%
Taylor expanded in z around -inf 53.3%
Taylor expanded in z around 0 90.7%
Taylor expanded in x around 0 74.4%
neg-mul-174.4%
+-commutative74.4%
distribute-rgt1-in74.4%
metadata-eval74.4%
mul0-lft74.4%
associate-*r/74.4%
metadata-eval74.4%
unsub-neg74.4%
div074.4%
neg-sub074.4%
*-commutative74.4%
distribute-lft-neg-out74.4%
distribute-rgt-neg-in74.4%
Simplified74.4%
if 4.25000000000000023e89 < x Initial program 68.6%
Taylor expanded in y around inf 69.8%
*-commutative69.8%
Simplified69.8%
unpow269.8%
unpow269.8%
difference-of-squares80.6%
Applied egg-rr80.6%
Taylor expanded in y around 0 79.2%
*-commutative79.2%
associate-/l*85.3%
+-commutative85.3%
Simplified85.3%
Taylor expanded in z around 0 80.2%
Final simplification75.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 (<= y_m 2.05e+94) (* 0.5 (* (- x z) (/ 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 <= 2.05e+94) {
tmp = 0.5 * ((x - z) * (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 <= 2.05d+94) then
tmp = 0.5d0 * ((x - z) * (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 <= 2.05e+94) {
tmp = 0.5 * ((x - z) * (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 <= 2.05e+94: tmp = 0.5 * ((x - z) * (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 <= 2.05e+94) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(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 <= 2.05e+94) tmp = 0.5 * ((x - z) * (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, 2.05e+94], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(x / 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 2.05 \cdot 10^{+94}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 2.05000000000000015e94Initial program 79.5%
Taylor expanded in y around inf 79.3%
*-commutative79.3%
Simplified79.3%
unpow279.3%
unpow279.3%
difference-of-squares85.0%
Applied egg-rr85.0%
Taylor expanded in y around 0 76.1%
*-commutative76.1%
associate-/l*78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in z around 0 44.8%
if 2.05000000000000015e94 < y Initial program 30.0%
Taylor expanded in y around inf 67.4%
*-commutative67.4%
Simplified67.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 (* 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 70.8%
Taylor expanded in y around inf 30.9%
*-commutative30.9%
Simplified30.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 2024091
(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)))