
(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}
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+271) (* 0.5 (+ y (/ 1.0 (* y (/ 1.0 (- (pow x 2.0) (pow z 2.0))))))) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + (1.0 / (y * (1.0 / (pow(x, 2.0) - pow(z, 2.0))))));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1d+271) then
tmp = 0.5d0 * (y + (1.0d0 / (y * (1.0d0 / ((x ** 2.0d0) - (z ** 2.0d0))))))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + (1.0 / (y * (1.0 / (Math.pow(x, 2.0) - Math.pow(z, 2.0))))));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e+271: tmp = 0.5 * (y + (1.0 / (y * (1.0 / (math.pow(x, 2.0) - math.pow(z, 2.0)))))) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+271) tmp = Float64(0.5 * Float64(y + Float64(1.0 / Float64(y * Float64(1.0 / Float64((x ^ 2.0) - (z ^ 2.0))))))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e+271) tmp = 0.5 * (y + (1.0 / (y * (1.0 / ((x ^ 2.0) - (z ^ 2.0)))))); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+271], N[(0.5 * N[(y + N[(1.0 / N[(y * N[(1.0 / N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+271}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{1}{y \cdot \frac{1}{{x}^{2} - {z}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999953e270Initial program 71.8%
remove-double-neg71.8%
distribute-lft-neg-out71.8%
distribute-frac-neg271.8%
distribute-frac-neg71.8%
neg-mul-171.8%
distribute-lft-neg-out71.8%
*-commutative71.8%
distribute-lft-neg-in71.8%
times-frac71.8%
metadata-eval71.8%
metadata-eval71.8%
associate--l+71.8%
fma-define71.8%
Simplified71.8%
Taylor expanded in x around 0 89.2%
associate--l+89.2%
div-sub92.9%
Simplified92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr92.9%
unpow-192.9%
Simplified92.9%
div-inv92.9%
Applied egg-rr92.9%
if 9.99999999999999953e270 < (*.f64 z z) Initial program 51.9%
remove-double-neg51.9%
distribute-lft-neg-out51.9%
distribute-frac-neg251.9%
distribute-frac-neg51.9%
neg-mul-151.9%
distribute-lft-neg-out51.9%
*-commutative51.9%
distribute-lft-neg-in51.9%
times-frac51.9%
metadata-eval51.9%
metadata-eval51.9%
associate--l+51.9%
fma-define61.9%
Simplified61.9%
Taylor expanded in x around 0 57.8%
associate--l+57.8%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 74.9%
pow274.9%
*-un-lft-identity74.9%
times-frac88.7%
Applied egg-rr88.7%
Taylor expanded in z around 0 88.7%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+271) (* 0.5 (+ y (/ 1.0 (/ y (- (pow x 2.0) (pow z 2.0)))))) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + (1.0 / (y / (pow(x, 2.0) - pow(z, 2.0)))));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1d+271) then
tmp = 0.5d0 * (y + (1.0d0 / (y / ((x ** 2.0d0) - (z ** 2.0d0)))))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + (1.0 / (y / (Math.pow(x, 2.0) - Math.pow(z, 2.0)))));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e+271: tmp = 0.5 * (y + (1.0 / (y / (math.pow(x, 2.0) - math.pow(z, 2.0))))) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+271) tmp = Float64(0.5 * Float64(y + Float64(1.0 / Float64(y / Float64((x ^ 2.0) - (z ^ 2.0)))))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e+271) tmp = 0.5 * (y + (1.0 / (y / ((x ^ 2.0) - (z ^ 2.0))))); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+271], N[(0.5 * N[(y + N[(1.0 / N[(y / N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+271}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{1}{\frac{y}{{x}^{2} - {z}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999953e270Initial program 71.8%
remove-double-neg71.8%
distribute-lft-neg-out71.8%
distribute-frac-neg271.8%
distribute-frac-neg71.8%
neg-mul-171.8%
distribute-lft-neg-out71.8%
*-commutative71.8%
distribute-lft-neg-in71.8%
times-frac71.8%
metadata-eval71.8%
metadata-eval71.8%
associate--l+71.8%
fma-define71.8%
Simplified71.8%
Taylor expanded in x around 0 89.2%
associate--l+89.2%
div-sub92.9%
Simplified92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr92.9%
unpow-192.9%
Simplified92.9%
if 9.99999999999999953e270 < (*.f64 z z) Initial program 51.9%
remove-double-neg51.9%
distribute-lft-neg-out51.9%
distribute-frac-neg251.9%
distribute-frac-neg51.9%
neg-mul-151.9%
distribute-lft-neg-out51.9%
*-commutative51.9%
distribute-lft-neg-in51.9%
times-frac51.9%
metadata-eval51.9%
metadata-eval51.9%
associate--l+51.9%
fma-define61.9%
Simplified61.9%
Taylor expanded in x around 0 57.8%
associate--l+57.8%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 74.9%
pow274.9%
*-un-lft-identity74.9%
times-frac88.7%
Applied egg-rr88.7%
Taylor expanded in z around 0 88.7%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+271) (* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y))) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1d+271) then
tmp = 0.5d0 * (y + (((x ** 2.0d0) - (z ** 2.0d0)) / y))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+271) {
tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e+271: tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y)) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+271) tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e+271) tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y)); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+271], N[(0.5 * N[(y + N[(N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+271}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999953e270Initial program 71.8%
remove-double-neg71.8%
distribute-lft-neg-out71.8%
distribute-frac-neg271.8%
distribute-frac-neg71.8%
neg-mul-171.8%
distribute-lft-neg-out71.8%
*-commutative71.8%
distribute-lft-neg-in71.8%
times-frac71.8%
metadata-eval71.8%
metadata-eval71.8%
associate--l+71.8%
fma-define71.8%
Simplified71.8%
Taylor expanded in x around 0 89.2%
associate--l+89.2%
div-sub92.9%
Simplified92.9%
if 9.99999999999999953e270 < (*.f64 z z) Initial program 51.9%
remove-double-neg51.9%
distribute-lft-neg-out51.9%
distribute-frac-neg251.9%
distribute-frac-neg51.9%
neg-mul-151.9%
distribute-lft-neg-out51.9%
*-commutative51.9%
distribute-lft-neg-in51.9%
times-frac51.9%
metadata-eval51.9%
metadata-eval51.9%
associate--l+51.9%
fma-define61.9%
Simplified61.9%
Taylor expanded in x around 0 57.8%
associate--l+57.8%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 74.9%
pow274.9%
*-un-lft-identity74.9%
times-frac88.7%
Applied egg-rr88.7%
Taylor expanded in z around 0 88.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- (+ (* y y) (* x x)) (* z z)) (* y 2.0))))
(if (<= t_0 0.0)
(* 0.5 (- y (/ z (/ y z))))
(if (<= t_0 INFINITY)
(* 0.5 (+ y (/ (pow x 2.0) y)))
(* 0.5 (- y (* z (/ z y))))))))
double code(double x, double y, double z) {
double t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (y - (z / (y / z)));
} else if (t_0 <= ((double) INFINITY)) {
tmp = 0.5 * (y + (pow(x, 2.0) / y));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (y - (z / (y / z)));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 0.5 * (y + (Math.pow(x, 2.0) / y));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0) tmp = 0 if t_0 <= 0.0: tmp = 0.5 * (y - (z / (y / z))) elif t_0 <= math.inf: tmp = 0.5 * (y + (math.pow(x, 2.0) / y)) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y * y) + Float64(x * x)) - Float64(z * z)) / Float64(y * 2.0)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z)))); elseif (t_0 <= Inf) tmp = Float64(0.5 * Float64(y + Float64((x ^ 2.0) / y))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.5 * (y - (z / (y / z))); elseif (t_0 <= Inf) tmp = 0.5 * (y + ((x ^ 2.0) / y)); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y + N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\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 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-frac-neg270.7%
distribute-frac-neg70.7%
neg-mul-170.7%
distribute-lft-neg-out70.7%
*-commutative70.7%
distribute-lft-neg-in70.7%
times-frac70.7%
metadata-eval70.7%
metadata-eval70.7%
associate--l+70.7%
fma-define70.7%
Simplified70.7%
Taylor expanded in x around 0 86.8%
associate--l+86.8%
div-sub90.3%
Simplified90.3%
Taylor expanded in x around 0 61.4%
pow261.4%
*-un-lft-identity61.4%
times-frac63.7%
Applied egg-rr63.7%
/-rgt-identity63.7%
clear-num63.7%
un-div-inv63.7%
Applied egg-rr63.7%
if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 79.0%
remove-double-neg79.0%
distribute-lft-neg-out79.0%
distribute-frac-neg279.0%
distribute-frac-neg79.0%
neg-mul-179.0%
distribute-lft-neg-out79.0%
*-commutative79.0%
distribute-lft-neg-in79.0%
times-frac79.0%
metadata-eval79.0%
metadata-eval79.0%
associate--l+79.0%
fma-define79.0%
Simplified79.0%
Taylor expanded in x around 0 90.3%
associate--l+90.3%
div-sub96.6%
Simplified96.6%
Taylor expanded in z around 0 63.5%
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-define24.1%
Simplified24.1%
Taylor expanded in x around 0 18.2%
associate--l+18.2%
div-sub18.2%
Simplified18.2%
Taylor expanded in x around 0 45.8%
pow245.8%
*-un-lft-identity45.8%
times-frac72.7%
Applied egg-rr72.7%
Taylor expanded in z around 0 72.7%
Final simplification64.6%
(FPCore (x y z) :precision binary64 (if (<= y 1e+154) (* 0.5 (/ (fma x x (- (* y y) (* z z))) y)) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1e+154) {
tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1e+154) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y)); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1e+154], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < 1.00000000000000004e154Initial program 75.3%
remove-double-neg75.3%
distribute-lft-neg-out75.3%
distribute-frac-neg275.3%
distribute-frac-neg75.3%
neg-mul-175.3%
distribute-lft-neg-out75.3%
*-commutative75.3%
distribute-lft-neg-in75.3%
times-frac75.3%
metadata-eval75.3%
metadata-eval75.3%
associate--l+75.3%
fma-define78.5%
Simplified78.5%
if 1.00000000000000004e154 < y Initial program 7.6%
remove-double-neg7.6%
distribute-lft-neg-out7.6%
distribute-frac-neg27.6%
distribute-frac-neg7.6%
neg-mul-17.6%
distribute-lft-neg-out7.6%
*-commutative7.6%
distribute-lft-neg-in7.6%
times-frac7.6%
metadata-eval7.6%
metadata-eval7.6%
associate--l+7.6%
fma-define7.6%
Simplified7.6%
Taylor expanded in x around 0 71.3%
associate--l+71.3%
div-sub71.3%
Simplified71.3%
Taylor expanded in x around 0 74.0%
pow274.0%
*-un-lft-identity74.0%
times-frac88.9%
Applied egg-rr88.9%
Taylor expanded in z around 0 88.9%
(FPCore (x y z) :precision binary64 (if (<= y 3.3e+99) (/ (- (+ (* y y) (* x x)) (* z z)) (* y 2.0)) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e+99) {
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3.3d+99) then
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0d0)
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e+99) {
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.3e+99: tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.3e+99) tmp = Float64(Float64(Float64(Float64(y * y) + Float64(x * x)) - Float64(z * z)) / Float64(y * 2.0)); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.3e+99) tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.3e+99], N[(N[(N[(N[(y * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+99}:\\
\;\;\;\;\frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < 3.2999999999999999e99Initial program 75.1%
if 3.2999999999999999e99 < y Initial program 27.1%
remove-double-neg27.1%
distribute-lft-neg-out27.1%
distribute-frac-neg227.1%
distribute-frac-neg27.1%
neg-mul-127.1%
distribute-lft-neg-out27.1%
*-commutative27.1%
distribute-lft-neg-in27.1%
times-frac27.1%
metadata-eval27.1%
metadata-eval27.1%
associate--l+27.1%
fma-define29.3%
Simplified29.3%
Taylor expanded in x around 0 73.2%
associate--l+73.2%
div-sub73.2%
Simplified73.2%
Taylor expanded in x around 0 73.1%
pow273.1%
*-un-lft-identity73.1%
times-frac85.9%
Applied egg-rr85.9%
Taylor expanded in z around 0 85.9%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+249) (* 0.5 (- y (* z (/ z y)))) (* x (/ (* 0.5 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+249) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = x * ((0.5 * x) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 1d+249) then
tmp = 0.5d0 * (y - (z * (z / y)))
else
tmp = x * ((0.5d0 * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+249) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = x * ((0.5 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+249: tmp = 0.5 * (y - (z * (z / y))) else: tmp = x * ((0.5 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+249) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); else tmp = Float64(x * Float64(Float64(0.5 * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+249) tmp = 0.5 * (y - (z * (z / y))); else tmp = x * ((0.5 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+249], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+249}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\
\end{array}
\end{array}
if (*.f64 x x) < 9.9999999999999992e248Initial program 69.2%
remove-double-neg69.2%
distribute-lft-neg-out69.2%
distribute-frac-neg269.2%
distribute-frac-neg69.2%
neg-mul-169.2%
distribute-lft-neg-out69.2%
*-commutative69.2%
distribute-lft-neg-in69.2%
times-frac69.2%
metadata-eval69.2%
metadata-eval69.2%
associate--l+69.2%
fma-define69.2%
Simplified69.2%
Taylor expanded in x around 0 91.5%
associate--l+91.5%
div-sub95.0%
Simplified95.0%
Taylor expanded in x around 0 82.5%
pow282.5%
*-un-lft-identity82.5%
times-frac86.2%
Applied egg-rr86.2%
Taylor expanded in z around 0 86.2%
if 9.9999999999999992e248 < (*.f64 x x) Initial program 60.3%
remove-double-neg60.3%
distribute-lft-neg-out60.3%
distribute-frac-neg260.3%
distribute-frac-neg60.3%
neg-mul-160.3%
distribute-lft-neg-out60.3%
*-commutative60.3%
distribute-lft-neg-in60.3%
times-frac60.3%
metadata-eval60.3%
metadata-eval60.3%
associate--l+60.3%
fma-define68.7%
Simplified68.7%
Taylor expanded in x around inf 69.3%
*-commutative69.3%
associate-*l/69.3%
associate-*r/69.3%
Simplified69.3%
associate-*r/69.3%
clear-num69.3%
Applied egg-rr69.3%
clear-num69.3%
associate-*r/69.3%
pow269.3%
associate-*l*74.8%
*-commutative74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification82.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.42e+104) (* x (/ (* 0.5 x) y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = x * ((0.5 * x) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.42d+104) then
tmp = x * ((0.5d0 * x) / y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = x * ((0.5 * x) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.42e+104: tmp = x * ((0.5 * x) / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.42e+104) tmp = Float64(x * Float64(Float64(0.5 * x) / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.42e+104) tmp = x * ((0.5 * x) / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.42e+104], N[(x * N[(N[(0.5 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.42 \cdot 10^{+104}:\\
\;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.42e104Initial program 74.9%
remove-double-neg74.9%
distribute-lft-neg-out74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
neg-mul-174.9%
distribute-lft-neg-out74.9%
*-commutative74.9%
distribute-lft-neg-in74.9%
times-frac74.9%
metadata-eval74.9%
metadata-eval74.9%
associate--l+74.9%
fma-define78.2%
Simplified78.2%
Taylor expanded in x around inf 36.0%
*-commutative36.0%
associate-*l/36.0%
associate-*r/36.0%
Simplified36.0%
associate-*r/36.0%
clear-num36.0%
Applied egg-rr36.0%
clear-num36.0%
associate-*r/36.0%
pow236.0%
associate-*l*38.1%
*-commutative38.1%
associate-*r/38.1%
Applied egg-rr38.1%
if 1.42e104 < y Initial program 26.1%
remove-double-neg26.1%
distribute-lft-neg-out26.1%
distribute-frac-neg226.1%
distribute-frac-neg26.1%
neg-mul-126.1%
distribute-lft-neg-out26.1%
*-commutative26.1%
distribute-lft-neg-in26.1%
times-frac26.1%
metadata-eval26.1%
metadata-eval26.1%
associate--l+26.1%
fma-define26.1%
Simplified26.1%
Taylor expanded in y around inf 77.5%
Final simplification45.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.42e+104) (* (* x x) (/ 0.5 y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.42d+104) then
tmp = (x * x) * (0.5d0 / y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.42e+104: tmp = (x * x) * (0.5 / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.42e+104) tmp = Float64(Float64(x * x) * Float64(0.5 / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.42e+104) tmp = (x * x) * (0.5 / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.42e+104], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.42 \cdot 10^{+104}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.42e104Initial program 74.9%
remove-double-neg74.9%
distribute-lft-neg-out74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
neg-mul-174.9%
distribute-lft-neg-out74.9%
*-commutative74.9%
distribute-lft-neg-in74.9%
times-frac74.9%
metadata-eval74.9%
metadata-eval74.9%
associate--l+74.9%
fma-define78.2%
Simplified78.2%
Taylor expanded in x around inf 36.0%
*-commutative36.0%
associate-*l/36.0%
associate-*r/36.0%
Simplified36.0%
pow236.0%
Applied egg-rr36.0%
if 1.42e104 < y Initial program 26.1%
remove-double-neg26.1%
distribute-lft-neg-out26.1%
distribute-frac-neg226.1%
distribute-frac-neg26.1%
neg-mul-126.1%
distribute-lft-neg-out26.1%
*-commutative26.1%
distribute-lft-neg-in26.1%
times-frac26.1%
metadata-eval26.1%
metadata-eval26.1%
associate--l+26.1%
fma-define26.1%
Simplified26.1%
Taylor expanded in y around inf 77.5%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 66.3%
remove-double-neg66.3%
distribute-lft-neg-out66.3%
distribute-frac-neg266.3%
distribute-frac-neg66.3%
neg-mul-166.3%
distribute-lft-neg-out66.3%
*-commutative66.3%
distribute-lft-neg-in66.3%
times-frac66.3%
metadata-eval66.3%
metadata-eval66.3%
associate--l+66.3%
fma-define69.1%
Simplified69.1%
Taylor expanded in y around inf 32.8%
(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 2024137
(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)))