
(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 10 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}
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
:precision binary64
(let* ((t_0 (/ (+ x z_m) y_m)))
(*
y_s
(if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z_m z_m)) (* y_m 2.0)) -5e+155)
(* z_m (* -0.5 t_0))
(* y_m (+ 0.5 (* 0.5 (* (/ (- x z_m) y_m) t_0))))))))z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double t_0 = (x + z_m) / y_m;
double tmp;
if (((((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)) <= -5e+155) {
tmp = z_m * (-0.5 * t_0);
} else {
tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * t_0)));
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: t_0
real(8) :: tmp
t_0 = (x + z_m) / y_m
if (((((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0d0)) <= (-5d+155)) then
tmp = z_m * ((-0.5d0) * t_0)
else
tmp = y_m * (0.5d0 + (0.5d0 * (((x - z_m) / y_m) * t_0)))
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double t_0 = (x + z_m) / y_m;
double tmp;
if (((((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)) <= -5e+155) {
tmp = z_m * (-0.5 * t_0);
} else {
tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * t_0)));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): t_0 = (x + z_m) / y_m tmp = 0 if ((((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)) <= -5e+155: tmp = z_m * (-0.5 * t_0) else: tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * t_0))) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) t_0 = Float64(Float64(x + z_m) / y_m) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z_m * z_m)) / Float64(y_m * 2.0)) <= -5e+155) tmp = Float64(z_m * Float64(-0.5 * t_0)); else tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x - z_m) / y_m) * t_0)))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) t_0 = (x + z_m) / y_m; tmp = 0.0; if (((((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)) <= -5e+155) tmp = z_m * (-0.5 * t_0); else tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * t_0))); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]}, N[(y$95$s * If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], -5e+155], N[(z$95$m * N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{x + z\_m}{y\_m}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2} \leq -5 \cdot 10^{+155}:\\
\;\;\;\;z\_m \cdot \left(-0.5 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x - z\_m}{y\_m} \cdot t\_0\right)\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.9999999999999999e155Initial program 59.9%
remove-double-neg59.9%
distribute-lft-neg-out59.9%
distribute-frac-neg259.9%
distribute-frac-neg59.9%
neg-mul-159.9%
distribute-lft-neg-out59.9%
*-commutative59.9%
distribute-lft-neg-in59.9%
times-frac59.9%
metadata-eval59.9%
metadata-eval59.9%
associate--l+59.9%
fma-define59.9%
Simplified59.9%
Taylor expanded in y around 0 58.6%
associate-*r/58.6%
*-commutative58.6%
associate-/l*58.6%
Simplified58.6%
pow258.6%
pow258.6%
difference-of-squares58.6%
Applied egg-rr58.6%
Taylor expanded in x around 0 23.7%
neg-mul-123.7%
Simplified23.7%
Taylor expanded in z around 0 28.7%
distribute-lft-out28.7%
*-lft-identity28.7%
associate-*l/28.7%
*-lft-identity28.7%
associate-*l/28.7%
distribute-lft-in29.8%
*-commutative29.8%
associate-*r/29.8%
*-rgt-identity29.8%
+-commutative29.8%
Simplified29.8%
if -4.9999999999999999e155 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial 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.3%
metadata-eval70.3%
metadata-eval70.3%
associate--l+70.3%
fma-define72.7%
Simplified72.7%
Taylor expanded in y around inf 72.1%
pow251.1%
pow251.1%
difference-of-squares57.9%
Applied egg-rr76.9%
*-commutative76.9%
unpow276.9%
times-frac94.3%
Applied egg-rr94.3%
Final simplification71.3%
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
:precision binary64
(let* ((t_0 (/ (- x z_m) y_m))
(t_1 (/ (- (+ (* x x) (* y_m y_m)) (* z_m z_m)) (* y_m 2.0))))
(*
y_s
(if (<= t_1 0.0)
(* 0.5 (* t_0 (+ x z_m)))
(if (<= t_1 1e+298)
t_1
(if (<= t_1 INFINITY)
(* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m)))))
(* y_m (+ 0.5 (* 0.5 (* t_0 (/ z_m y_m)))))))))))z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double t_0 = (x - z_m) / y_m;
double t_1 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
double tmp;
if (t_1 <= 0.0) {
tmp = 0.5 * (t_0 * (x + z_m));
} else if (t_1 <= 1e+298) {
tmp = t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))));
}
return y_s * tmp;
}
z_m = Math.abs(z);
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_m) {
double t_0 = (x - z_m) / y_m;
double t_1 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
double tmp;
if (t_1 <= 0.0) {
tmp = 0.5 * (t_0 * (x + z_m));
} else if (t_1 <= 1e+298) {
tmp = t_1;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): t_0 = (x - z_m) / y_m t_1 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0) tmp = 0 if t_1 <= 0.0: tmp = 0.5 * (t_0 * (x + z_m)) elif t_1 <= 1e+298: tmp = t_1 elif t_1 <= math.inf: tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))) else: tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m)))) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) t_0 = Float64(Float64(x - z_m) / y_m) t_1 = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z_m * z_m)) / Float64(y_m * 2.0)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(0.5 * Float64(t_0 * Float64(x + z_m))); elseif (t_1 <= 1e+298) tmp = t_1; elseif (t_1 <= Inf) tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m))))); else tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(t_0 * Float64(z_m / y_m))))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) t_0 = (x - z_m) / y_m; t_1 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0); tmp = 0.0; if (t_1 <= 0.0) tmp = 0.5 * (t_0 * (x + z_m)); elseif (t_1 <= 1e+298) tmp = t_1; elseif (t_1 <= Inf) tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))); else tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m)))); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$1, 0.0], N[(0.5 * N[(t$95$0 * N[(x + z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+298], t$95$1, If[LessEqual[t$95$1, Infinity], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(t$95$0 * N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{x - z\_m}{y\_m}\\
t_1 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;0.5 \cdot \left(t\_0 \cdot \left(x + z\_m\right)\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+298}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(t\_0 \cdot \frac{z\_m}{y\_m}\right)\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 64.5%
remove-double-neg64.5%
distribute-lft-neg-out64.5%
distribute-frac-neg264.5%
distribute-frac-neg64.5%
neg-mul-164.5%
distribute-lft-neg-out64.5%
*-commutative64.5%
distribute-lft-neg-in64.5%
times-frac64.5%
metadata-eval64.5%
metadata-eval64.5%
associate--l+64.5%
fma-define64.5%
Simplified64.5%
Taylor expanded in y around inf 77.8%
pow251.5%
pow251.5%
difference-of-squares51.5%
Applied egg-rr77.8%
Taylor expanded in y around 0 51.5%
associate-/l*58.5%
Simplified58.5%
if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 9.9999999999999996e297Initial program 99.6%
if 9.9999999999999996e297 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 69.0%
remove-double-neg69.0%
distribute-lft-neg-out69.0%
distribute-frac-neg269.0%
distribute-frac-neg69.0%
neg-mul-169.0%
distribute-lft-neg-out69.0%
*-commutative69.0%
distribute-lft-neg-in69.0%
times-frac67.8%
metadata-eval67.8%
metadata-eval67.8%
associate--l+67.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in y around inf 91.4%
pow267.8%
pow267.8%
difference-of-squares67.8%
Applied egg-rr91.4%
*-commutative91.4%
unpow291.4%
times-frac98.8%
Applied egg-rr98.8%
Taylor expanded in x around inf 76.0%
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-define21.1%
Simplified21.1%
Taylor expanded in y around inf 0.0%
pow210.9%
pow210.9%
difference-of-squares69.3%
Applied egg-rr42.1%
*-commutative42.1%
unpow242.1%
times-frac99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 79.2%
Final simplification71.6%
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
:precision binary64
(*
y_s
(if (<= z_m 7.5e+47)
(* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m)))))
(* y_m (+ 0.5 (* 0.5 (* (/ (- x z_m) y_m) (/ z_m y_m))))))))z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (z_m <= 7.5e+47) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * (z_m / y_m))));
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 7.5d+47) then
tmp = y_m * (0.5d0 + (0.5d0 * (((x + z_m) / y_m) * (x / y_m))))
else
tmp = y_m * (0.5d0 + (0.5d0 * (((x - z_m) / y_m) * (z_m / y_m))))
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (z_m <= 7.5e+47) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * (z_m / y_m))));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if z_m <= 7.5e+47: tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))) else: tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * (z_m / y_m)))) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (z_m <= 7.5e+47) tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m))))); else tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x - z_m) / y_m) * Float64(z_m / y_m))))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (z_m <= 7.5e+47) tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))); else tmp = y_m * (0.5 + (0.5 * (((x - z_m) / y_m) * (z_m / y_m)))); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[z$95$m, 7.5e+47], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 7.5 \cdot 10^{+47}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x - z\_m}{y\_m} \cdot \frac{z\_m}{y\_m}\right)\right)\\
\end{array}
\end{array}
if z < 7.4999999999999999e47Initial program 67.3%
remove-double-neg67.3%
distribute-lft-neg-out67.3%
distribute-frac-neg267.3%
distribute-frac-neg67.3%
neg-mul-167.3%
distribute-lft-neg-out67.3%
*-commutative67.3%
distribute-lft-neg-in67.3%
times-frac66.9%
metadata-eval66.9%
metadata-eval66.9%
associate--l+66.9%
fma-define66.9%
Simplified66.9%
Taylor expanded in y around inf 78.4%
pow251.3%
pow251.3%
difference-of-squares53.7%
Applied egg-rr80.3%
*-commutative80.3%
unpow280.3%
times-frac93.8%
Applied egg-rr93.8%
Taylor expanded in x around inf 81.3%
if 7.4999999999999999e47 < z Initial program 65.2%
remove-double-neg65.2%
distribute-lft-neg-out65.2%
distribute-frac-neg265.2%
distribute-frac-neg65.2%
neg-mul-165.2%
distribute-lft-neg-out65.2%
*-commutative65.2%
distribute-lft-neg-in65.2%
times-frac65.2%
metadata-eval65.2%
metadata-eval65.2%
associate--l+65.2%
fma-define74.1%
Simplified74.1%
Taylor expanded in y around inf 63.0%
pow265.3%
pow265.3%
difference-of-squares78.8%
Applied egg-rr71.9%
*-commutative71.9%
unpow271.9%
times-frac95.7%
Applied egg-rr95.7%
Taylor expanded in x around 0 87.5%
Final simplification82.4%
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
:precision binary64
(*
y_s
(if (<= z_m 1.46e+34)
(* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m)))))
(* 0.5 (* (/ (- x z_m) y_m) (+ x z_m))))))z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (z_m <= 1.46e+34) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m));
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 1.46d+34) then
tmp = y_m * (0.5d0 + (0.5d0 * (((x + z_m) / y_m) * (x / y_m))))
else
tmp = 0.5d0 * (((x - z_m) / y_m) * (x + z_m))
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (z_m <= 1.46e+34) {
tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
} else {
tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if z_m <= 1.46e+34: tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))) else: tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m)) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (z_m <= 1.46e+34) tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m))))); else tmp = Float64(0.5 * Float64(Float64(Float64(x - z_m) / y_m) * Float64(x + z_m))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (z_m <= 1.46e+34) tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m)))); else tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m)); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[z$95$m, 1.46e+34], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x + z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1.46 \cdot 10^{+34}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x - z\_m}{y\_m} \cdot \left(x + z\_m\right)\right)\\
\end{array}
\end{array}
if z < 1.46e34Initial program 66.6%
remove-double-neg66.6%
distribute-lft-neg-out66.6%
distribute-frac-neg266.6%
distribute-frac-neg66.6%
neg-mul-166.6%
distribute-lft-neg-out66.6%
*-commutative66.6%
distribute-lft-neg-in66.6%
times-frac66.3%
metadata-eval66.3%
metadata-eval66.3%
associate--l+66.3%
fma-define66.3%
Simplified66.3%
Taylor expanded in y around inf 78.0%
pow250.4%
pow250.4%
difference-of-squares52.8%
Applied egg-rr79.9%
*-commutative79.9%
unpow279.9%
times-frac93.7%
Applied egg-rr93.7%
Taylor expanded in x around inf 81.1%
if 1.46e34 < z Initial program 68.0%
remove-double-neg68.0%
distribute-lft-neg-out68.0%
distribute-frac-neg268.0%
distribute-frac-neg68.0%
neg-mul-168.0%
distribute-lft-neg-out68.0%
*-commutative68.0%
distribute-lft-neg-in68.0%
times-frac68.0%
metadata-eval68.0%
metadata-eval68.0%
associate--l+68.0%
fma-define76.2%
Simplified76.2%
Taylor expanded in y around inf 66.0%
pow268.1%
pow268.1%
difference-of-squares80.6%
Applied egg-rr74.1%
Taylor expanded in y around 0 80.5%
associate-/l*89.0%
Simplified89.0%
Final simplification82.6%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (if (<= y_m 4.2e+100) (* 0.5 (* (/ (- x z_m) y_m) (+ x z_m))) (* y_m 0.5))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (y_m <= 4.2e+100) {
tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m));
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (y_m <= 4.2d+100) then
tmp = 0.5d0 * (((x - z_m) / y_m) * (x + z_m))
else
tmp = y_m * 0.5d0
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (y_m <= 4.2e+100) {
tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m));
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if y_m <= 4.2e+100: tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m)) else: tmp = y_m * 0.5 return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (y_m <= 4.2e+100) tmp = Float64(0.5 * Float64(Float64(Float64(x - z_m) / y_m) * Float64(x + z_m))); else tmp = Float64(y_m * 0.5); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (y_m <= 4.2e+100) tmp = 0.5 * (((x - z_m) / y_m) * (x + z_m)); else tmp = y_m * 0.5; end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[y$95$m, 4.2e+100], N[(0.5 * N[(N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x + z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 4.2 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(\frac{x - z\_m}{y\_m} \cdot \left(x + z\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 4.1999999999999997e100Initial program 72.7%
remove-double-neg72.7%
distribute-lft-neg-out72.7%
distribute-frac-neg272.7%
distribute-frac-neg72.7%
neg-mul-172.7%
distribute-lft-neg-out72.7%
*-commutative72.7%
distribute-lft-neg-in72.7%
times-frac72.3%
metadata-eval72.3%
metadata-eval72.3%
associate--l+72.3%
fma-define74.1%
Simplified74.1%
Taylor expanded in y around inf 75.7%
pow260.0%
pow260.0%
difference-of-squares64.6%
Applied egg-rr79.3%
Taylor expanded in y around 0 64.2%
associate-/l*69.0%
Simplified69.0%
if 4.1999999999999997e100 < y Initial program 26.4%
remove-double-neg26.4%
distribute-lft-neg-out26.4%
distribute-frac-neg226.4%
distribute-frac-neg26.4%
neg-mul-126.4%
distribute-lft-neg-out26.4%
*-commutative26.4%
distribute-lft-neg-in26.4%
times-frac26.4%
metadata-eval26.4%
metadata-eval26.4%
associate--l+26.4%
fma-define26.4%
Simplified26.4%
Taylor expanded in y around inf 84.4%
Final simplification70.9%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (if (<= y_m 1.25e+77) (* (* x (- x z_m)) (/ 0.5 y_m)) (* y_m 0.5))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (y_m <= 1.25e+77) {
tmp = (x * (x - z_m)) * (0.5 / y_m);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (y_m <= 1.25d+77) then
tmp = (x * (x - z_m)) * (0.5d0 / y_m)
else
tmp = y_m * 0.5d0
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (y_m <= 1.25e+77) {
tmp = (x * (x - z_m)) * (0.5 / y_m);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if y_m <= 1.25e+77: tmp = (x * (x - z_m)) * (0.5 / y_m) else: tmp = y_m * 0.5 return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (y_m <= 1.25e+77) tmp = Float64(Float64(x * Float64(x - z_m)) * Float64(0.5 / y_m)); else tmp = Float64(y_m * 0.5); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (y_m <= 1.25e+77) tmp = (x * (x - z_m)) * (0.5 / y_m); else tmp = y_m * 0.5; end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[y$95$m, 1.25e+77], N[(N[(x * N[(x - z$95$m), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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.25 \cdot 10^{+77}:\\
\;\;\;\;\left(x \cdot \left(x - z\_m\right)\right) \cdot \frac{0.5}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 1.25000000000000001e77Initial program 72.7%
remove-double-neg72.7%
distribute-lft-neg-out72.7%
distribute-frac-neg272.7%
distribute-frac-neg72.7%
neg-mul-172.7%
distribute-lft-neg-out72.7%
*-commutative72.7%
distribute-lft-neg-in72.7%
times-frac72.3%
metadata-eval72.3%
metadata-eval72.3%
associate--l+72.3%
fma-define74.1%
Simplified74.1%
Taylor expanded in y around 0 60.6%
associate-*r/61.0%
*-commutative61.0%
associate-/l*61.0%
Simplified61.0%
pow261.0%
pow261.0%
difference-of-squares65.6%
Applied egg-rr65.6%
Taylor expanded in x around inf 42.0%
if 1.25000000000000001e77 < y Initial program 34.9%
remove-double-neg34.9%
distribute-lft-neg-out34.9%
distribute-frac-neg234.9%
distribute-frac-neg34.9%
neg-mul-134.9%
distribute-lft-neg-out34.9%
*-commutative34.9%
distribute-lft-neg-in34.9%
times-frac34.9%
metadata-eval34.9%
metadata-eval34.9%
associate--l+34.9%
fma-define34.9%
Simplified34.9%
Taylor expanded in y around inf 77.1%
Final simplification47.3%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (if (<= z_m 2.1e+63) (* y_m 0.5) (* z_m (* -0.5 (/ (+ x z_m) y_m))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (z_m <= 2.1e+63) {
tmp = y_m * 0.5;
} else {
tmp = z_m * (-0.5 * ((x + z_m) / y_m));
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 2.1d+63) then
tmp = y_m * 0.5d0
else
tmp = z_m * ((-0.5d0) * ((x + z_m) / y_m))
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (z_m <= 2.1e+63) {
tmp = y_m * 0.5;
} else {
tmp = z_m * (-0.5 * ((x + z_m) / y_m));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if z_m <= 2.1e+63: tmp = y_m * 0.5 else: tmp = z_m * (-0.5 * ((x + z_m) / y_m)) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (z_m <= 2.1e+63) tmp = Float64(y_m * 0.5); else tmp = Float64(z_m * Float64(-0.5 * Float64(Float64(x + z_m) / y_m))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (z_m <= 2.1e+63) tmp = y_m * 0.5; else tmp = z_m * (-0.5 * ((x + z_m) / y_m)); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[z$95$m, 2.1e+63], N[(y$95$m * 0.5), $MachinePrecision], N[(z$95$m * N[(-0.5 * N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.1 \cdot 10^{+63}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z\_m \cdot \left(-0.5 \cdot \frac{x + z\_m}{y\_m}\right)\\
\end{array}
\end{array}
if z < 2.1000000000000002e63Initial program 67.6%
remove-double-neg67.6%
distribute-lft-neg-out67.6%
distribute-frac-neg267.6%
distribute-frac-neg67.6%
neg-mul-167.6%
distribute-lft-neg-out67.6%
*-commutative67.6%
distribute-lft-neg-in67.6%
times-frac67.2%
metadata-eval67.2%
metadata-eval67.2%
associate--l+67.2%
fma-define67.2%
Simplified67.2%
Taylor expanded in y around inf 44.6%
if 2.1000000000000002e63 < z Initial program 63.6%
remove-double-neg63.6%
distribute-lft-neg-out63.6%
distribute-frac-neg263.6%
distribute-frac-neg63.6%
neg-mul-163.6%
distribute-lft-neg-out63.6%
*-commutative63.6%
distribute-lft-neg-in63.6%
times-frac63.6%
metadata-eval63.6%
metadata-eval63.6%
associate--l+63.6%
fma-define72.9%
Simplified72.9%
Taylor expanded in y around 0 66.0%
associate-*r/66.0%
*-commutative66.0%
associate-/l*66.0%
Simplified66.0%
pow266.0%
pow266.0%
difference-of-squares80.2%
Applied egg-rr80.2%
Taylor expanded in x around 0 70.7%
neg-mul-170.7%
Simplified70.7%
Taylor expanded in z around 0 65.4%
distribute-lft-out65.4%
*-lft-identity65.4%
associate-*l/65.4%
*-lft-identity65.4%
associate-*l/65.4%
distribute-lft-in74.7%
*-commutative74.7%
associate-*r/74.7%
*-rgt-identity74.7%
+-commutative74.7%
Simplified74.7%
Final simplification49.6%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (if (<= z_m 5.2e+63) (* y_m 0.5) (* (* z_m z_m) (/ (- 0.5) y_m)))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (z_m <= 5.2e+63) {
tmp = y_m * 0.5;
} else {
tmp = (z_m * z_m) * (-0.5 / y_m);
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 5.2d+63) then
tmp = y_m * 0.5d0
else
tmp = (z_m * z_m) * (-0.5d0 / y_m)
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (z_m <= 5.2e+63) {
tmp = y_m * 0.5;
} else {
tmp = (z_m * z_m) * (-0.5 / y_m);
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if z_m <= 5.2e+63: tmp = y_m * 0.5 else: tmp = (z_m * z_m) * (-0.5 / y_m) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (z_m <= 5.2e+63) tmp = Float64(y_m * 0.5); else tmp = Float64(Float64(z_m * z_m) * Float64(Float64(-0.5) / y_m)); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (z_m <= 5.2e+63) tmp = y_m * 0.5; else tmp = (z_m * z_m) * (-0.5 / y_m); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[z$95$m, 5.2e+63], N[(y$95$m * 0.5), $MachinePrecision], N[(N[(z$95$m * z$95$m), $MachinePrecision] * N[((-0.5) / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5.2 \cdot 10^{+63}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot z\_m\right) \cdot \frac{-0.5}{y\_m}\\
\end{array}
\end{array}
if z < 5.2000000000000002e63Initial program 67.6%
remove-double-neg67.6%
distribute-lft-neg-out67.6%
distribute-frac-neg267.6%
distribute-frac-neg67.6%
neg-mul-167.6%
distribute-lft-neg-out67.6%
*-commutative67.6%
distribute-lft-neg-in67.6%
times-frac67.2%
metadata-eval67.2%
metadata-eval67.2%
associate--l+67.2%
fma-define67.2%
Simplified67.2%
Taylor expanded in y around inf 44.6%
if 5.2000000000000002e63 < z Initial program 63.6%
remove-double-neg63.6%
distribute-lft-neg-out63.6%
distribute-frac-neg263.6%
distribute-frac-neg63.6%
neg-mul-163.6%
distribute-lft-neg-out63.6%
*-commutative63.6%
distribute-lft-neg-in63.6%
times-frac63.6%
metadata-eval63.6%
metadata-eval63.6%
associate--l+63.6%
fma-define72.9%
Simplified72.9%
Taylor expanded in y around 0 66.0%
associate-*r/66.0%
*-commutative66.0%
associate-/l*66.0%
Simplified66.0%
pow266.0%
pow266.0%
difference-of-squares80.2%
Applied egg-rr80.2%
Taylor expanded in x around 0 70.7%
neg-mul-170.7%
Simplified70.7%
Taylor expanded in x around 0 65.6%
Final simplification48.1%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (if (<= z_m 7.8e+154) (* y_m 0.5) (* -0.5 (* x (/ z_m y_m))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
double tmp;
if (z_m <= 7.8e+154) {
tmp = y_m * 0.5;
} else {
tmp = -0.5 * (x * (z_m / y_m));
}
return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 7.8d+154) then
tmp = y_m * 0.5d0
else
tmp = (-0.5d0) * (x * (z_m / y_m))
end if
code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
double tmp;
if (z_m <= 7.8e+154) {
tmp = y_m * 0.5;
} else {
tmp = -0.5 * (x * (z_m / y_m));
}
return y_s * tmp;
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): tmp = 0 if z_m <= 7.8e+154: tmp = y_m * 0.5 else: tmp = -0.5 * (x * (z_m / y_m)) return y_s * tmp
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) tmp = 0.0 if (z_m <= 7.8e+154) tmp = Float64(y_m * 0.5); else tmp = Float64(-0.5 * Float64(x * Float64(z_m / y_m))); end return Float64(y_s * tmp) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z_m) tmp = 0.0; if (z_m <= 7.8e+154) tmp = y_m * 0.5; else tmp = -0.5 * (x * (z_m / y_m)); end tmp_2 = y_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[z$95$m, 7.8e+154], N[(y$95$m * 0.5), $MachinePrecision], N[(-0.5 * N[(x * N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 7.8 \cdot 10^{+154}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \frac{z\_m}{y\_m}\right)\\
\end{array}
\end{array}
if z < 7.8000000000000006e154Initial program 68.3%
remove-double-neg68.3%
distribute-lft-neg-out68.3%
distribute-frac-neg268.3%
distribute-frac-neg68.3%
neg-mul-168.3%
distribute-lft-neg-out68.3%
*-commutative68.3%
distribute-lft-neg-in68.3%
times-frac68.0%
metadata-eval68.0%
metadata-eval68.0%
associate--l+68.0%
fma-define68.0%
Simplified68.0%
Taylor expanded in y around inf 42.2%
if 7.8000000000000006e154 < z Initial program 52.9%
remove-double-neg52.9%
distribute-lft-neg-out52.9%
distribute-frac-neg252.9%
distribute-frac-neg52.9%
neg-mul-152.9%
distribute-lft-neg-out52.9%
*-commutative52.9%
distribute-lft-neg-in52.9%
times-frac52.9%
metadata-eval52.9%
metadata-eval52.9%
associate--l+52.9%
fma-define70.2%
Simplified70.2%
Taylor expanded in y around 0 57.5%
associate-*r/57.5%
*-commutative57.5%
associate-/l*57.5%
Simplified57.5%
pow257.5%
pow257.5%
difference-of-squares83.6%
Applied egg-rr83.6%
Taylor expanded in x around 0 83.6%
neg-mul-183.6%
Simplified83.6%
Taylor expanded in x around inf 23.4%
associate-/l*27.3%
Simplified27.3%
Final simplification40.9%
z_m = (fabs.f64 z) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z_m) :precision binary64 (* y_s (* y_m 0.5)))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
return y_s * (y_m * 0.5);
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z_m
code = y_s * (y_m * 0.5d0)
end function
z_m = Math.abs(z);
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_m) {
return y_s * (y_m * 0.5);
}
z_m = math.fabs(z) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z_m): return y_s * (y_m * 0.5)
z_m = abs(z) y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z_m) return Float64(y_s * Float64(y_m * 0.5)) end
z_m = abs(z); y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z_m) tmp = y_s * (y_m * 0.5); end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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 66.9%
remove-double-neg66.9%
distribute-lft-neg-out66.9%
distribute-frac-neg266.9%
distribute-frac-neg66.9%
neg-mul-166.9%
distribute-lft-neg-out66.9%
*-commutative66.9%
distribute-lft-neg-in66.9%
times-frac66.6%
metadata-eval66.6%
metadata-eval66.6%
associate--l+66.6%
fma-define68.2%
Simplified68.2%
Taylor expanded in y around inf 38.9%
Final simplification38.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 2024152
(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)))