
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (* 0.5 (+ y (* (/ (+ z_m x_m) y) (- x_m z_m)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)));
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = 0.5d0 * (y + (((z_m + x_m) / y) * (x_m - z_m)))
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)));
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)))
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) return Float64(0.5 * Float64(y + Float64(Float64(Float64(z_m + x_m) / y) * Float64(x_m - z_m)))) end
x_m = abs(x); z_m = abs(z); function tmp = code(x_m, y, z_m) tmp = 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m))); end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := N[(0.5 * N[(y + N[(N[(N[(z$95$m + x$95$m), $MachinePrecision] / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
0.5 \cdot \left(y + \frac{z\_m + x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)
\end{array}
Initial program 65.7%
remove-double-neg65.7%
distribute-lft-neg-out65.7%
distribute-frac-neg265.7%
distribute-frac-neg65.7%
neg-mul-165.7%
distribute-lft-neg-out65.7%
*-commutative65.7%
distribute-lft-neg-in65.7%
times-frac65.7%
metadata-eval65.7%
metadata-eval65.7%
associate--l+65.7%
fma-define68.0%
Simplified68.0%
fma-undefine65.7%
associate--l+65.7%
div-sub61.8%
add-sqr-sqrt61.8%
pow261.8%
hypot-define61.8%
pow261.8%
Applied egg-rr61.8%
div-sub65.7%
unpow265.7%
hypot-undefine65.7%
unpow265.7%
unpow265.7%
hypot-undefine65.7%
unpow265.7%
unpow265.7%
rem-square-sqrt65.7%
associate-+r-65.7%
+-commutative65.7%
associate-+l-65.7%
div-sub65.7%
unpow265.7%
associate-/l*84.5%
*-inverses84.5%
*-rgt-identity84.5%
Simplified84.5%
unpow284.5%
unpow284.5%
difference-of-squares90.4%
Applied egg-rr90.4%
*-commutative90.4%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
:precision binary64
(let* ((t_0 (* (/ z_m y) (/ z_m -2.0))))
(if (<= x_m 5.2e-280)
t_0
(if (<= x_m 5e-125)
(* 0.5 y)
(if (<= x_m 1.2e-65)
t_0
(if (<= x_m 1.04e+80) (* 0.5 y) (* x_m (* x_m (/ 0.5 y)))))))))x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
double t_0 = (z_m / y) * (z_m / -2.0);
double tmp;
if (x_m <= 5.2e-280) {
tmp = t_0;
} else if (x_m <= 5e-125) {
tmp = 0.5 * y;
} else if (x_m <= 1.2e-65) {
tmp = t_0;
} else if (x_m <= 1.04e+80) {
tmp = 0.5 * y;
} else {
tmp = x_m * (x_m * (0.5 / y));
}
return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: t_0
real(8) :: tmp
t_0 = (z_m / y) * (z_m / (-2.0d0))
if (x_m <= 5.2d-280) then
tmp = t_0
else if (x_m <= 5d-125) then
tmp = 0.5d0 * y
else if (x_m <= 1.2d-65) then
tmp = t_0
else if (x_m <= 1.04d+80) then
tmp = 0.5d0 * y
else
tmp = x_m * (x_m * (0.5d0 / y))
end if
code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
double t_0 = (z_m / y) * (z_m / -2.0);
double tmp;
if (x_m <= 5.2e-280) {
tmp = t_0;
} else if (x_m <= 5e-125) {
tmp = 0.5 * y;
} else if (x_m <= 1.2e-65) {
tmp = t_0;
} else if (x_m <= 1.04e+80) {
tmp = 0.5 * y;
} else {
tmp = x_m * (x_m * (0.5 / y));
}
return tmp;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): t_0 = (z_m / y) * (z_m / -2.0) tmp = 0 if x_m <= 5.2e-280: tmp = t_0 elif x_m <= 5e-125: tmp = 0.5 * y elif x_m <= 1.2e-65: tmp = t_0 elif x_m <= 1.04e+80: tmp = 0.5 * y else: tmp = x_m * (x_m * (0.5 / y)) return tmp
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) t_0 = Float64(Float64(z_m / y) * Float64(z_m / -2.0)) tmp = 0.0 if (x_m <= 5.2e-280) tmp = t_0; elseif (x_m <= 5e-125) tmp = Float64(0.5 * y); elseif (x_m <= 1.2e-65) tmp = t_0; elseif (x_m <= 1.04e+80) tmp = Float64(0.5 * y); else tmp = Float64(x_m * Float64(x_m * Float64(0.5 / y))); end return tmp end
x_m = abs(x); z_m = abs(z); function tmp_2 = code(x_m, y, z_m) t_0 = (z_m / y) * (z_m / -2.0); tmp = 0.0; if (x_m <= 5.2e-280) tmp = t_0; elseif (x_m <= 5e-125) tmp = 0.5 * y; elseif (x_m <= 1.2e-65) tmp = t_0; elseif (x_m <= 1.04e+80) tmp = 0.5 * y; else tmp = x_m * (x_m * (0.5 / y)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 5.2e-280], t$95$0, If[LessEqual[x$95$m, 5e-125], N[(0.5 * y), $MachinePrecision], If[LessEqual[x$95$m, 1.2e-65], t$95$0, If[LessEqual[x$95$m, 1.04e+80], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(x$95$m * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
\begin{array}{l}
t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\
\mathbf{if}\;x\_m \leq 5.2 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x\_m \leq 5 \cdot 10^{-125}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x\_m \leq 1.04 \cdot 10^{+80}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(x\_m \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 5.2e-280 or 4.99999999999999967e-125 < x < 1.2000000000000001e-65Initial program 66.8%
clear-num66.8%
inv-pow66.8%
associate-/l*65.9%
add-sqr-sqrt65.9%
pow265.9%
hypot-define65.9%
pow265.9%
Applied egg-rr65.9%
Taylor expanded in z around inf 30.8%
associate-*r/30.8%
*-commutative30.8%
Simplified30.8%
unpow-130.8%
clear-num30.8%
unpow230.8%
times-frac34.6%
Applied egg-rr34.6%
if 5.2e-280 < x < 4.99999999999999967e-125 or 1.2000000000000001e-65 < x < 1.04000000000000006e80Initial program 62.7%
Taylor expanded in y around inf 52.7%
*-commutative52.7%
Simplified52.7%
if 1.04000000000000006e80 < x Initial program 65.5%
Taylor expanded in x around inf 65.3%
*-commutative65.3%
associate-*l/65.3%
Simplified65.3%
associate-/l*65.3%
unpow265.3%
associate-*l*70.5%
Applied egg-rr70.5%
Final simplification45.2%
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
:precision binary64
(let* ((t_0 (* (/ z_m y) (/ z_m -2.0))))
(if (<= x_m 1.3e-280)
t_0
(if (<= x_m 4e-125)
(* 0.5 y)
(if (<= x_m 1.2e-65)
t_0
(if (<= x_m 1e+80) (* 0.5 y) (* x_m (/ (* 0.5 x_m) y))))))))x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
double t_0 = (z_m / y) * (z_m / -2.0);
double tmp;
if (x_m <= 1.3e-280) {
tmp = t_0;
} else if (x_m <= 4e-125) {
tmp = 0.5 * y;
} else if (x_m <= 1.2e-65) {
tmp = t_0;
} else if (x_m <= 1e+80) {
tmp = 0.5 * y;
} else {
tmp = x_m * ((0.5 * x_m) / y);
}
return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: t_0
real(8) :: tmp
t_0 = (z_m / y) * (z_m / (-2.0d0))
if (x_m <= 1.3d-280) then
tmp = t_0
else if (x_m <= 4d-125) then
tmp = 0.5d0 * y
else if (x_m <= 1.2d-65) then
tmp = t_0
else if (x_m <= 1d+80) then
tmp = 0.5d0 * y
else
tmp = x_m * ((0.5d0 * x_m) / y)
end if
code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
double t_0 = (z_m / y) * (z_m / -2.0);
double tmp;
if (x_m <= 1.3e-280) {
tmp = t_0;
} else if (x_m <= 4e-125) {
tmp = 0.5 * y;
} else if (x_m <= 1.2e-65) {
tmp = t_0;
} else if (x_m <= 1e+80) {
tmp = 0.5 * y;
} else {
tmp = x_m * ((0.5 * x_m) / y);
}
return tmp;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): t_0 = (z_m / y) * (z_m / -2.0) tmp = 0 if x_m <= 1.3e-280: tmp = t_0 elif x_m <= 4e-125: tmp = 0.5 * y elif x_m <= 1.2e-65: tmp = t_0 elif x_m <= 1e+80: tmp = 0.5 * y else: tmp = x_m * ((0.5 * x_m) / y) return tmp
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) t_0 = Float64(Float64(z_m / y) * Float64(z_m / -2.0)) tmp = 0.0 if (x_m <= 1.3e-280) tmp = t_0; elseif (x_m <= 4e-125) tmp = Float64(0.5 * y); elseif (x_m <= 1.2e-65) tmp = t_0; elseif (x_m <= 1e+80) tmp = Float64(0.5 * y); else tmp = Float64(x_m * Float64(Float64(0.5 * x_m) / y)); end return tmp end
x_m = abs(x); z_m = abs(z); function tmp_2 = code(x_m, y, z_m) t_0 = (z_m / y) * (z_m / -2.0); tmp = 0.0; if (x_m <= 1.3e-280) tmp = t_0; elseif (x_m <= 4e-125) tmp = 0.5 * y; elseif (x_m <= 1.2e-65) tmp = t_0; elseif (x_m <= 1e+80) tmp = 0.5 * y; else tmp = x_m * ((0.5 * x_m) / y); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.3e-280], t$95$0, If[LessEqual[x$95$m, 4e-125], N[(0.5 * y), $MachinePrecision], If[LessEqual[x$95$m, 1.2e-65], t$95$0, If[LessEqual[x$95$m, 1e+80], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(N[(0.5 * x$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
\begin{array}{l}
t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\
\mathbf{if}\;x\_m \leq 1.3 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x\_m \leq 4 \cdot 10^{-125}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x\_m \leq 10^{+80}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \frac{0.5 \cdot x\_m}{y}\\
\end{array}
\end{array}
if x < 1.3e-280 or 4.00000000000000005e-125 < x < 1.2000000000000001e-65Initial program 66.8%
clear-num66.8%
inv-pow66.8%
associate-/l*65.9%
add-sqr-sqrt65.9%
pow265.9%
hypot-define65.9%
pow265.9%
Applied egg-rr65.9%
Taylor expanded in z around inf 30.8%
associate-*r/30.8%
*-commutative30.8%
Simplified30.8%
unpow-130.8%
clear-num30.8%
unpow230.8%
times-frac34.6%
Applied egg-rr34.6%
if 1.3e-280 < x < 4.00000000000000005e-125 or 1.2000000000000001e-65 < x < 1e80Initial program 62.7%
Taylor expanded in y around inf 52.7%
*-commutative52.7%
Simplified52.7%
if 1e80 < x Initial program 65.5%
Taylor expanded in x around inf 65.3%
*-commutative65.3%
associate-*l/65.3%
Simplified65.3%
clear-num65.2%
inv-pow65.2%
*-un-lft-identity65.2%
*-commutative65.2%
times-frac65.2%
metadata-eval65.2%
Applied egg-rr65.2%
unpow-165.2%
Simplified65.2%
associate-*r/65.2%
unpow265.2%
associate-/r*70.4%
*-commutative70.4%
Applied egg-rr70.4%
associate-/l/65.2%
associate-/r/65.3%
metadata-eval65.3%
div-inv65.3%
clear-num65.3%
associate-*l*70.5%
*-commutative70.5%
associate-*r/70.5%
Applied egg-rr70.5%
Final simplification45.2%
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (if (or (<= z_m 2.5e+103) (and (not (<= z_m 5.6e+118)) (<= z_m 1.05e+182))) (* 0.5 (+ y (* (/ x_m y) (- x_m z_m)))) (* (/ z_m y) (/ z_m -2.0))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
double tmp;
if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182))) {
tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
} else {
tmp = (z_m / y) * (z_m / -2.0);
}
return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if ((z_m <= 2.5d+103) .or. (.not. (z_m <= 5.6d+118)) .and. (z_m <= 1.05d+182)) then
tmp = 0.5d0 * (y + ((x_m / y) * (x_m - z_m)))
else
tmp = (z_m / y) * (z_m / (-2.0d0))
end if
code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
double tmp;
if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182))) {
tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
} else {
tmp = (z_m / y) * (z_m / -2.0);
}
return tmp;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): tmp = 0 if (z_m <= 2.5e+103) or (not (z_m <= 5.6e+118) and (z_m <= 1.05e+182)): tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m))) else: tmp = (z_m / y) * (z_m / -2.0) return tmp
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) tmp = 0.0 if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182))) tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m / y) * Float64(x_m - z_m)))); else tmp = Float64(Float64(z_m / y) * Float64(z_m / -2.0)); end return tmp end
x_m = abs(x); z_m = abs(z); function tmp_2 = code(x_m, y, z_m) tmp = 0.0; if ((z_m <= 2.5e+103) || (~((z_m <= 5.6e+118)) && (z_m <= 1.05e+182))) tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m))); else tmp = (z_m / y) * (z_m / -2.0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := If[Or[LessEqual[z$95$m, 2.5e+103], And[N[Not[LessEqual[z$95$m, 5.6e+118]], $MachinePrecision], LessEqual[z$95$m, 1.05e+182]]], N[(0.5 * N[(y + N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.5 \cdot 10^{+103} \lor \neg \left(z\_m \leq 5.6 \cdot 10^{+118}\right) \land z\_m \leq 1.05 \cdot 10^{+182}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\
\end{array}
\end{array}
if z < 2.5e103 or 5.59999999999999972e118 < z < 1.0499999999999999e182Initial program 66.7%
remove-double-neg66.7%
distribute-lft-neg-out66.7%
distribute-frac-neg266.7%
distribute-frac-neg66.7%
neg-mul-166.7%
distribute-lft-neg-out66.7%
*-commutative66.7%
distribute-lft-neg-in66.7%
times-frac66.7%
metadata-eval66.7%
metadata-eval66.7%
associate--l+66.7%
fma-define68.0%
Simplified68.0%
fma-undefine66.7%
associate--l+66.7%
div-sub62.7%
add-sqr-sqrt62.7%
pow262.7%
hypot-define62.7%
pow262.7%
Applied egg-rr62.7%
div-sub66.7%
unpow266.7%
hypot-undefine66.7%
unpow266.7%
unpow266.7%
hypot-undefine66.7%
unpow266.7%
unpow266.7%
rem-square-sqrt66.7%
associate-+r-66.7%
+-commutative66.7%
associate-+l-66.7%
div-sub66.7%
unpow266.7%
associate-/l*87.1%
*-inverses87.1%
*-rgt-identity87.1%
Simplified87.1%
unpow287.1%
unpow287.1%
difference-of-squares91.1%
Applied egg-rr91.1%
*-commutative91.1%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 79.3%
if 2.5e103 < z < 5.59999999999999972e118 or 1.0499999999999999e182 < z Initial program 58.5%
clear-num58.5%
inv-pow58.5%
associate-/l*58.5%
add-sqr-sqrt58.5%
pow258.5%
hypot-define58.5%
pow258.5%
Applied egg-rr58.5%
Taylor expanded in z around inf 75.4%
associate-*r/75.4%
*-commutative75.4%
Simplified75.4%
unpow-175.4%
clear-num75.4%
unpow275.4%
times-frac87.1%
Applied egg-rr87.1%
Final simplification80.2%
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (if (<= z_m 4.1e+21) (* 0.5 (+ y (* (/ x_m y) (- x_m z_m)))) (* 0.5 (+ y (* (/ z_m y) (- x_m z_m))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
double tmp;
if (z_m <= 4.1e+21) {
tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
} else {
tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)));
}
return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 4.1d+21) then
tmp = 0.5d0 * (y + ((x_m / y) * (x_m - z_m)))
else
tmp = 0.5d0 * (y + ((z_m / y) * (x_m - z_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
double tmp;
if (z_m <= 4.1e+21) {
tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
} else {
tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)));
}
return tmp;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): tmp = 0 if z_m <= 4.1e+21: tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m))) else: tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m))) return tmp
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) tmp = 0.0 if (z_m <= 4.1e+21) tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m / y) * Float64(x_m - z_m)))); else tmp = Float64(0.5 * Float64(y + Float64(Float64(z_m / y) * Float64(x_m - z_m)))); end return tmp end
x_m = abs(x); z_m = abs(z); function tmp_2 = code(x_m, y, z_m) tmp = 0.0; if (z_m <= 4.1e+21) tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m))); else tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := If[LessEqual[z$95$m, 4.1e+21], N[(0.5 * N[(y + N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(z$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 4.1 \cdot 10^{+21}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{z\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\
\end{array}
\end{array}
if z < 4.1e21Initial 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.6%
metadata-eval67.6%
metadata-eval67.6%
associate--l+67.6%
fma-define69.1%
Simplified69.1%
fma-undefine67.6%
associate--l+67.6%
div-sub65.6%
add-sqr-sqrt65.6%
pow265.6%
hypot-define65.6%
pow265.6%
Applied egg-rr65.6%
div-sub67.6%
unpow267.6%
hypot-undefine67.6%
unpow267.6%
unpow267.6%
hypot-undefine67.6%
unpow267.6%
unpow267.6%
rem-square-sqrt67.6%
associate-+r-67.6%
+-commutative67.6%
associate-+l-67.6%
div-sub67.6%
unpow267.6%
associate-/l*87.4%
*-inverses87.4%
*-rgt-identity87.4%
Simplified87.4%
unpow287.4%
unpow287.4%
difference-of-squares90.9%
Applied egg-rr90.9%
*-commutative90.9%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 78.5%
if 4.1e21 < z Initial program 59.0%
remove-double-neg59.0%
distribute-lft-neg-out59.0%
distribute-frac-neg259.0%
distribute-frac-neg59.0%
neg-mul-159.0%
distribute-lft-neg-out59.0%
*-commutative59.0%
distribute-lft-neg-in59.0%
times-frac59.0%
metadata-eval59.0%
metadata-eval59.0%
associate--l+59.0%
fma-define64.3%
Simplified64.3%
fma-undefine59.0%
associate--l+59.0%
div-sub48.5%
add-sqr-sqrt48.5%
pow248.5%
hypot-define48.5%
pow248.5%
Applied egg-rr48.5%
div-sub59.0%
unpow259.0%
hypot-undefine59.0%
unpow259.0%
unpow259.0%
hypot-undefine59.0%
unpow259.0%
unpow259.0%
rem-square-sqrt59.0%
associate-+r-59.0%
+-commutative59.0%
associate-+l-59.0%
div-sub59.0%
unpow259.0%
associate-/l*74.3%
*-inverses74.3%
*-rgt-identity74.3%
Simplified74.3%
unpow274.3%
unpow274.3%
difference-of-squares88.7%
Applied egg-rr88.7%
*-commutative88.7%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 83.7%
Final simplification79.7%
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (if (<= x_m 8.5e+79) (* 0.5 y) (* x_m (* x_m (/ 0.5 y)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
double tmp;
if (x_m <= 8.5e+79) {
tmp = 0.5 * y;
} else {
tmp = x_m * (x_m * (0.5 / y));
}
return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (x_m <= 8.5d+79) then
tmp = 0.5d0 * y
else
tmp = x_m * (x_m * (0.5d0 / y))
end if
code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
double tmp;
if (x_m <= 8.5e+79) {
tmp = 0.5 * y;
} else {
tmp = x_m * (x_m * (0.5 / y));
}
return tmp;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): tmp = 0 if x_m <= 8.5e+79: tmp = 0.5 * y else: tmp = x_m * (x_m * (0.5 / y)) return tmp
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) tmp = 0.0 if (x_m <= 8.5e+79) tmp = Float64(0.5 * y); else tmp = Float64(x_m * Float64(x_m * Float64(0.5 / y))); end return tmp end
x_m = abs(x); z_m = abs(z); function tmp_2 = code(x_m, y, z_m) tmp = 0.0; if (x_m <= 8.5e+79) tmp = 0.5 * y; else tmp = x_m * (x_m * (0.5 / y)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := If[LessEqual[x$95$m, 8.5e+79], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(x$95$m * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 8.5 \cdot 10^{+79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(x\_m \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 8.4999999999999998e79Initial program 65.8%
Taylor expanded in y around inf 40.8%
*-commutative40.8%
Simplified40.8%
if 8.4999999999999998e79 < x Initial program 65.5%
Taylor expanded in x around inf 65.3%
*-commutative65.3%
associate-*l/65.3%
Simplified65.3%
associate-/l*65.3%
unpow265.3%
associate-*l*70.5%
Applied egg-rr70.5%
Final simplification46.6%
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (* y -0.5))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
return y * -0.5;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = y * (-0.5d0)
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
return y * -0.5;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): return y * -0.5
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) return Float64(y * -0.5) end
x_m = abs(x); z_m = abs(z); function tmp = code(x_m, y, z_m) tmp = y * -0.5; end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := N[(y * -0.5), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
y \cdot -0.5
\end{array}
Initial program 65.7%
add-sqr-sqrt34.4%
sqrt-unprod32.0%
associate-/r*32.0%
associate--l+32.0%
fma-undefine32.0%
associate-/r*32.0%
associate--l+32.0%
fma-undefine34.4%
frac-times34.4%
Applied egg-rr32.0%
Simplified32.7%
Taylor expanded in y around -inf 1.7%
*-commutative1.7%
Simplified1.7%
Final simplification1.7%
x_m = (fabs.f64 x) z_m = (fabs.f64 z) (FPCore (x_m y z_m) :precision binary64 (* 0.5 y))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
return 0.5 * y;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = 0.5d0 * y
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
return 0.5 * y;
}
x_m = math.fabs(x) z_m = math.fabs(z) def code(x_m, y, z_m): return 0.5 * y
x_m = abs(x) z_m = abs(z) function code(x_m, y, z_m) return Float64(0.5 * y) end
x_m = abs(x); z_m = abs(z); function tmp = code(x_m, y, z_m) tmp = 0.5 * y; end
x_m = N[Abs[x], $MachinePrecision] z_m = N[Abs[z], $MachinePrecision] code[x$95$m_, y_, z$95$m_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
0.5 \cdot y
\end{array}
Initial program 65.7%
Taylor expanded in y around inf 36.4%
*-commutative36.4%
Simplified36.4%
Final simplification36.4%
(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 2024044
(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)))