
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z)
:precision binary64
(if (<= (* z z) 2e+195)
(fma 0.5 (fma x (/ x y) y) (* -0.5 (/ (pow z 2.0) y)))
(if (<= (* z z) 1e+291)
(* (/ 0.5 y) (- (pow (hypot x y) 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) <= 2e+195) {
tmp = fma(0.5, fma(x, (x / y), y), (-0.5 * (pow(z, 2.0) / y)));
} else if ((z * z) <= 1e+291) {
tmp = (0.5 / y) * (pow(hypot(x, y), 2.0) - 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) <= 2e+195) tmp = fma(0.5, fma(x, Float64(x / y), y), Float64(-0.5 * Float64((z ^ 2.0) / y))); elseif (Float64(z * z) <= 1e+291) tmp = Float64(Float64(0.5 / y) * Float64((hypot(x, y) ^ 2.0) - (z ^ 2.0))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+195], N[(0.5 * N[(x * N[(x / y), $MachinePrecision] + y), $MachinePrecision] + N[(-0.5 * N[(N[Power[z, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+291], N[(N[(0.5 / y), $MachinePrecision] * N[(N[Power[N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[z, 2.0], $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 2 \cdot 10^{+195}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \mathsf{fma}\left(x, \frac{x}{y}, y\right), -0.5 \cdot \frac{{z}^{2}}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 10^{+291}:\\
\;\;\;\;\frac{0.5}{y} \cdot \left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{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) < 1.99999999999999995e195Initial program 75.9%
clear-num75.7%
inv-pow75.7%
*-commutative75.7%
*-un-lft-identity75.7%
times-frac75.7%
metadata-eval75.7%
add-sqr-sqrt75.7%
pow275.7%
hypot-def75.7%
pow275.7%
Applied egg-rr75.7%
unpow-175.7%
associate-/r*75.7%
metadata-eval75.7%
associate-/l*75.9%
add-cube-cbrt74.8%
times-frac74.8%
pow274.8%
Applied egg-rr74.8%
Taylor expanded in z around inf 89.3%
+-commutative89.3%
fma-def89.3%
+-commutative89.3%
unpow289.3%
associate-*l/96.5%
*-commutative96.5%
fma-def96.5%
Simplified96.5%
if 1.99999999999999995e195 < (*.f64 z z) < 9.9999999999999996e290Initial program 95.2%
div-sub55.2%
sub-neg55.2%
div-inv55.2%
add-sqr-sqrt55.2%
pow255.2%
hypot-def55.2%
*-commutative55.2%
associate-/r*55.2%
metadata-eval55.2%
div-inv55.2%
pow255.2%
*-commutative55.2%
associate-/r*55.2%
metadata-eval55.2%
Applied egg-rr55.2%
sub-neg55.2%
distribute-rgt-out--95.2%
Simplified95.2%
if 9.9999999999999996e290 < (*.f64 z z) Initial program 54.5%
Taylor expanded in x around 0 61.4%
div-sub61.4%
unpow261.4%
associate-/l*66.8%
*-inverses66.8%
/-rgt-identity66.8%
Simplified66.8%
unpow266.8%
*-un-lft-identity66.8%
times-frac93.2%
Applied egg-rr93.2%
Final simplification95.6%
(FPCore (x y z) :precision binary64 (if (<= y 4e+79) (/ (fma (- y z) (+ z y) (* x x)) (* y 2.0)) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+79) {
tmp = fma((y - z), (z + y), (x * x)) / (y * 2.0);
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4e+79) tmp = Float64(fma(Float64(y - z), Float64(z + y), Float64(x * x)) / Float64(y * 2.0)); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4e+79], N[(N[(N[(y - z), $MachinePrecision] * N[(z + y), $MachinePrecision] + N[(x * x), $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 4 \cdot 10^{+79}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, z + y, x \cdot x\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < 3.99999999999999987e79Initial program 79.0%
associate--l+79.0%
+-commutative79.0%
sqr-neg79.0%
difference-of-squares79.2%
fma-def80.6%
sub-neg80.6%
sub-neg80.6%
remove-double-neg80.6%
Simplified80.6%
if 3.99999999999999987e79 < y Initial program 40.4%
Taylor expanded in x around 0 40.5%
div-sub40.5%
unpow240.5%
associate-/l*71.0%
*-inverses71.0%
/-rgt-identity71.0%
Simplified71.0%
unpow271.0%
*-un-lft-identity71.0%
times-frac89.1%
Applied egg-rr89.1%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (if (<= y 4e+79) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+79) {
tmp = (((x * x) + (y * y)) - (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 <= 4d+79) then
tmp = (((x * x) + (y * y)) - (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 <= 4e+79) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e+79: tmp = (((x * x) + (y * y)) - (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 <= 4e+79) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - 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 <= 4e+79) tmp = (((x * x) + (y * y)) - (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, 4e+79], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $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 4 \cdot 10^{+79}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\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.99999999999999987e79Initial program 79.0%
if 3.99999999999999987e79 < y Initial program 40.4%
Taylor expanded in x around 0 40.5%
div-sub40.5%
unpow240.5%
associate-/l*71.0%
*-inverses71.0%
/-rgt-identity71.0%
Simplified71.0%
unpow271.0%
*-un-lft-identity71.0%
times-frac89.1%
Applied egg-rr89.1%
Final simplification80.7%
(FPCore (x y z) :precision binary64 (if (<= x 4.7e+99) (* 0.5 (- y (/ (* z z) y))) (/ x (* 2.0 (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4.7e+99) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = x / (2.0 * (y / x));
}
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 <= 4.7d+99) then
tmp = 0.5d0 * (y - ((z * z) / y))
else
tmp = x / (2.0d0 * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 4.7e+99) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 4.7e+99: tmp = 0.5 * (y - ((z * z) / y)) else: tmp = x / (2.0 * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 4.7e+99) tmp = Float64(0.5 * Float64(y - Float64(Float64(z * z) / y))); else tmp = Float64(x / Float64(2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 4.7e+99) tmp = 0.5 * (y - ((z * z) / y)); else tmp = x / (2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 4.7e+99], N[(0.5 * N[(y - N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.7 \cdot 10^{+99}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < 4.69999999999999982e99Initial program 73.5%
Taylor expanded in x around 0 54.5%
div-sub54.6%
unpow254.6%
associate-/l*70.0%
*-inverses70.0%
/-rgt-identity70.0%
Simplified70.0%
unpow270.0%
Applied egg-rr70.0%
if 4.69999999999999982e99 < x Initial program 67.2%
Taylor expanded in x around inf 70.0%
unpow270.0%
times-frac77.1%
Applied egg-rr77.1%
clear-num77.1%
frac-times77.1%
*-un-lft-identity77.1%
Applied egg-rr77.1%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (<= x 5.6e+107) (* 0.5 (- y (* z (/ z y)))) (/ x (* 2.0 (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5.6e+107) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = x / (2.0 * (y / x));
}
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 <= 5.6d+107) then
tmp = 0.5d0 * (y - (z * (z / y)))
else
tmp = x / (2.0d0 * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 5.6e+107) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 5.6e+107: tmp = 0.5 * (y - (z * (z / y))) else: tmp = x / (2.0 * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 5.6e+107) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); else tmp = Float64(x / Float64(2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5.6e+107) tmp = 0.5 * (y - (z * (z / y))); else tmp = x / (2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 5.6e+107], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{+107}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < 5.59999999999999969e107Initial program 73.2%
Taylor expanded in x around 0 54.3%
div-sub54.3%
unpow254.3%
associate-/l*69.7%
*-inverses69.7%
/-rgt-identity69.7%
Simplified69.7%
unpow269.7%
*-un-lft-identity69.7%
times-frac76.2%
Applied egg-rr76.2%
if 5.59999999999999969e107 < x Initial program 68.8%
Taylor expanded in x around inf 71.8%
unpow271.8%
times-frac79.1%
Applied egg-rr79.1%
clear-num79.2%
frac-times79.2%
*-un-lft-identity79.2%
Applied egg-rr79.2%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y 0.46) (* x (* x (/ 0.5 y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.46) {
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 <= 0.46d0) 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 <= 0.46) {
tmp = x * (x * (0.5 / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.46: tmp = x * (x * (0.5 / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.46) tmp = Float64(x * Float64(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 <= 0.46) tmp = x * (x * (0.5 / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.46], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.46:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 0.46000000000000002Initial program 80.0%
Taylor expanded in x around inf 35.1%
div-inv35.1%
unpow235.1%
*-commutative35.1%
associate-/r*35.1%
metadata-eval35.1%
associate-*l*38.3%
Applied egg-rr38.3%
if 0.46000000000000002 < y Initial program 45.9%
Taylor expanded in y around inf 65.1%
Final simplification44.1%
(FPCore (x y z) :precision binary64 (if (<= y 3000000000.0) (* (/ x y) (/ x 2.0)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3000000000.0) {
tmp = (x / y) * (x / 2.0);
} 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 <= 3000000000.0d0) then
tmp = (x / y) * (x / 2.0d0)
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 <= 3000000000.0) {
tmp = (x / y) * (x / 2.0);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3000000000.0: tmp = (x / y) * (x / 2.0) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3000000000.0) tmp = Float64(Float64(x / y) * Float64(x / 2.0)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3000000000.0) tmp = (x / y) * (x / 2.0); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3000000000.0], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3000000000:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 3e9Initial program 80.0%
Taylor expanded in x around inf 35.1%
unpow235.1%
times-frac38.3%
Applied egg-rr38.3%
if 3e9 < y Initial program 45.9%
Taylor expanded in y around inf 65.1%
Final simplification44.1%
(FPCore (x y z) :precision binary64 (if (<= y 0.034) (/ x (* 2.0 (/ y x))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.034) {
tmp = x / (2.0 * (y / x));
} 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 <= 0.034d0) then
tmp = x / (2.0d0 * (y / x))
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 <= 0.034) {
tmp = x / (2.0 * (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.034: tmp = x / (2.0 * (y / x)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.034) tmp = Float64(x / Float64(2.0 * Float64(y / x))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.034) tmp = x / (2.0 * (y / x)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.034], N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.034:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 0.034000000000000002Initial program 80.0%
Taylor expanded in x around inf 35.1%
unpow235.1%
times-frac38.3%
Applied egg-rr38.3%
clear-num38.3%
frac-times38.3%
*-un-lft-identity38.3%
Applied egg-rr38.3%
if 0.034000000000000002 < y Initial program 45.9%
Taylor expanded in y around inf 65.1%
Final simplification44.2%
(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 72.5%
Taylor expanded in y around inf 34.2%
Final simplification34.2%
(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 2024036
(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)))