
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (- x z) (/ (+ x z) y)))))
double code(double x, double y, double z) {
return 0.5 * (y + ((x - z) * ((x + z) / 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 + ((x - z) * ((x + z) / y)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((x - z) * ((x + z) / y)));
}
def code(x, y, z): return 0.5 * (y + ((x - z) * ((x + z) / y)))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(Float64(x + z) / y)))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((x - z) * ((x + z) / y))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{x + z}{y}\right)
\end{array}
Initial program 71.9%
remove-double-neg71.9%
distribute-lft-neg-out71.9%
distribute-frac-neg271.9%
distribute-frac-neg71.9%
neg-mul-171.9%
distribute-lft-neg-out71.9%
*-commutative71.9%
distribute-lft-neg-in71.9%
times-frac71.9%
metadata-eval71.9%
metadata-eval71.9%
associate--l+71.9%
fma-define73.8%
Simplified73.8%
Taylor expanded in x around 0 78.6%
associate--l+78.6%
div-sub83.7%
Simplified83.7%
unpow283.7%
unpow283.7%
difference-of-squares90.8%
Applied egg-rr90.8%
*-commutative90.8%
associate-/l*99.9%
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (* (+ x z) (/ (- x z) y)))))
(if (<= y 6e+84)
t_0
(if (<= y 9.8e+203)
(* 0.5 (- y (/ (* z z) y)))
(if (<= y 2.1e+227) t_0 (* 0.5 y))))))
double code(double x, double y, double z) {
double t_0 = 0.5 * ((x + z) * ((x - z) / y));
double tmp;
if (y <= 6e+84) {
tmp = t_0;
} else if (y <= 9.8e+203) {
tmp = 0.5 * (y - ((z * z) / y));
} else if (y <= 2.1e+227) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * ((x + z) * ((x - z) / y))
if (y <= 6d+84) then
tmp = t_0
else if (y <= 9.8d+203) then
tmp = 0.5d0 * (y - ((z * z) / y))
else if (y <= 2.1d+227) then
tmp = t_0
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 0.5 * ((x + z) * ((x - z) / y));
double tmp;
if (y <= 6e+84) {
tmp = t_0;
} else if (y <= 9.8e+203) {
tmp = 0.5 * (y - ((z * z) / y));
} else if (y <= 2.1e+227) {
tmp = t_0;
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): t_0 = 0.5 * ((x + z) * ((x - z) / y)) tmp = 0 if y <= 6e+84: tmp = t_0 elif y <= 9.8e+203: tmp = 0.5 * (y - ((z * z) / y)) elif y <= 2.1e+227: tmp = t_0 else: tmp = 0.5 * y return tmp
function code(x, y, z) t_0 = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))) tmp = 0.0 if (y <= 6e+84) tmp = t_0; elseif (y <= 9.8e+203) tmp = Float64(0.5 * Float64(y - Float64(Float64(z * z) / y))); elseif (y <= 2.1e+227) tmp = t_0; else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.5 * ((x + z) * ((x - z) / y)); tmp = 0.0; if (y <= 6e+84) tmp = t_0; elseif (y <= 9.8e+203) tmp = 0.5 * (y - ((z * z) / y)); elseif (y <= 2.1e+227) tmp = t_0; else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6e+84], t$95$0, If[LessEqual[y, 9.8e+203], N[(0.5 * N[(y - N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e+227], t$95$0, N[(0.5 * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\mathbf{if}\;y \leq 6 \cdot 10^{+84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{+203}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z \cdot z}{y}\right)\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+227}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 5.99999999999999992e84 or 9.7999999999999995e203 < y < 2.10000000000000019e227Initial program 80.0%
remove-double-neg80.0%
distribute-lft-neg-out80.0%
distribute-frac-neg280.0%
distribute-frac-neg80.0%
neg-mul-180.0%
distribute-lft-neg-out80.0%
*-commutative80.0%
distribute-lft-neg-in80.0%
times-frac80.0%
metadata-eval80.0%
metadata-eval80.0%
associate--l+80.0%
fma-define82.2%
Simplified82.2%
Taylor expanded in x around 0 81.1%
associate--l+81.1%
div-sub86.9%
Simplified86.9%
unpow286.9%
unpow286.9%
difference-of-squares93.2%
Applied egg-rr93.2%
Taylor expanded in y around 0 78.1%
associate-*r/82.6%
+-commutative82.6%
Simplified82.6%
if 5.99999999999999992e84 < y < 9.7999999999999995e203Initial program 27.4%
remove-double-neg27.4%
distribute-lft-neg-out27.4%
distribute-frac-neg227.4%
distribute-frac-neg27.4%
neg-mul-127.4%
distribute-lft-neg-out27.4%
*-commutative27.4%
distribute-lft-neg-in27.4%
times-frac27.4%
metadata-eval27.4%
metadata-eval27.4%
associate--l+27.4%
fma-define27.4%
Simplified27.4%
Taylor expanded in x around 0 51.3%
associate--l+51.3%
div-sub51.3%
Simplified51.3%
unpow251.3%
unpow251.3%
difference-of-squares76.9%
Applied egg-rr76.9%
Taylor expanded in x around 0 57.8%
Taylor expanded in x around 0 45.3%
neg-mul-145.3%
Simplified45.3%
if 2.10000000000000019e227 < y Initial program 7.2%
remove-double-neg7.2%
distribute-lft-neg-out7.2%
distribute-frac-neg27.2%
distribute-frac-neg7.2%
neg-mul-17.2%
distribute-lft-neg-out7.2%
*-commutative7.2%
distribute-lft-neg-in7.2%
times-frac7.2%
metadata-eval7.2%
metadata-eval7.2%
associate--l+7.2%
fma-define7.2%
Simplified7.2%
Taylor expanded in y around inf 98.2%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (<= y 3.3e+85) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 (+ y (* (- x z) (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e+85) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * (y + ((x - 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+85) then
tmp = 0.5d0 * ((x + z) * ((x - z) / y))
else
tmp = 0.5d0 * (y + ((x - 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+85) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * (y + ((x - z) * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.3e+85: tmp = 0.5 * ((x + z) * ((x - z) / y)) else: tmp = 0.5 * (y + ((x - z) * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.3e+85) tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); else tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.3e+85) tmp = 0.5 * ((x + z) * ((x - z) / y)); else tmp = 0.5 * (y + ((x - z) * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.3e+85], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+85}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < 3.2999999999999999e85Initial program 80.8%
remove-double-neg80.8%
distribute-lft-neg-out80.8%
distribute-frac-neg280.8%
distribute-frac-neg80.8%
neg-mul-180.8%
distribute-lft-neg-out80.8%
*-commutative80.8%
distribute-lft-neg-in80.8%
times-frac80.8%
metadata-eval80.8%
metadata-eval80.8%
associate--l+80.8%
fma-define83.1%
Simplified83.1%
Taylor expanded in x around 0 81.9%
associate--l+81.9%
div-sub87.9%
Simplified87.9%
unpow287.9%
unpow287.9%
difference-of-squares93.9%
Applied egg-rr93.9%
Taylor expanded in y around 0 78.3%
associate-*r/82.1%
+-commutative82.1%
Simplified82.1%
if 3.2999999999999999e85 < y Initial program 22.1%
remove-double-neg22.1%
distribute-lft-neg-out22.1%
distribute-frac-neg222.1%
distribute-frac-neg22.1%
neg-mul-122.1%
distribute-lft-neg-out22.1%
*-commutative22.1%
distribute-lft-neg-in22.1%
times-frac22.1%
metadata-eval22.1%
metadata-eval22.1%
associate--l+22.1%
fma-define22.1%
Simplified22.1%
Taylor expanded in x around 0 60.5%
associate--l+60.5%
div-sub60.5%
Simplified60.5%
unpow260.5%
unpow260.5%
difference-of-squares73.6%
Applied egg-rr73.6%
*-commutative73.6%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 76.8%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+190) (* 0.5 (- y (/ (* z z) y))) (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+190) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = x * (x * (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 ((x * x) <= 2d+190) then
tmp = 0.5d0 * (y - ((z * z) / y))
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+190) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+190: tmp = 0.5 * (y - ((z * z) / y)) else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+190) tmp = Float64(0.5 * Float64(y - Float64(Float64(z * z) / y))); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+190) tmp = 0.5 * (y - ((z * z) / y)); else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+190], N[(0.5 * N[(y - N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000001e190Initial program 76.2%
remove-double-neg76.2%
distribute-lft-neg-out76.2%
distribute-frac-neg276.2%
distribute-frac-neg76.2%
neg-mul-176.2%
distribute-lft-neg-out76.2%
*-commutative76.2%
distribute-lft-neg-in76.2%
times-frac76.2%
metadata-eval76.2%
metadata-eval76.2%
associate--l+76.2%
fma-define76.2%
Simplified76.2%
Taylor expanded in x around 0 89.7%
associate--l+89.7%
div-sub92.2%
Simplified92.2%
unpow292.2%
unpow292.2%
difference-of-squares92.2%
Applied egg-rr92.2%
Taylor expanded in x around 0 79.7%
Taylor expanded in x around 0 78.5%
neg-mul-178.5%
Simplified78.5%
if 2.0000000000000001e190 < (*.f64 x x) Initial program 64.6%
remove-double-neg64.6%
distribute-lft-neg-out64.6%
distribute-frac-neg264.6%
distribute-frac-neg64.6%
neg-mul-164.6%
distribute-lft-neg-out64.6%
*-commutative64.6%
distribute-lft-neg-in64.6%
times-frac64.6%
metadata-eval64.6%
metadata-eval64.6%
associate--l+64.6%
fma-define69.8%
Simplified69.8%
clear-num69.8%
un-div-inv69.8%
fma-undefine64.6%
associate--l+64.6%
add-sqr-sqrt64.6%
pow264.6%
hypot-define64.6%
pow264.6%
Applied egg-rr64.6%
Taylor expanded in x around inf 75.2%
associate-/r/75.2%
unpow275.2%
associate-*r*79.0%
Applied egg-rr79.0%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+50) (* z (* z (/ -0.5 y))) (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+50) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = x * (x * (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 ((x * x) <= 1d+50) then
tmp = z * (z * ((-0.5d0) / y))
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+50) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+50: tmp = z * (z * (-0.5 / y)) else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+50) tmp = Float64(z * Float64(z * Float64(-0.5 / y))); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+50) tmp = z * (z * (-0.5 / y)); else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+50], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+50}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.0000000000000001e50Initial program 75.2%
remove-double-neg75.2%
distribute-lft-neg-out75.2%
distribute-frac-neg275.2%
distribute-frac-neg75.2%
neg-mul-175.2%
distribute-lft-neg-out75.2%
*-commutative75.2%
distribute-lft-neg-in75.2%
times-frac75.2%
metadata-eval75.2%
metadata-eval75.2%
associate--l+75.2%
fma-define75.2%
Simplified75.2%
Taylor expanded in z around inf 52.0%
*-commutative52.0%
associate-*l/52.0%
Simplified52.0%
associate-/l*52.1%
unpow252.1%
associate-*l*57.7%
Applied egg-rr57.7%
if 1.0000000000000001e50 < (*.f64 x x) Initial program 68.4%
remove-double-neg68.4%
distribute-lft-neg-out68.4%
distribute-frac-neg268.4%
distribute-frac-neg68.4%
neg-mul-168.4%
distribute-lft-neg-out68.4%
*-commutative68.4%
distribute-lft-neg-in68.4%
times-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
associate--l+68.4%
fma-define72.4%
Simplified72.4%
clear-num72.3%
un-div-inv72.3%
fma-undefine68.3%
associate--l+68.3%
add-sqr-sqrt68.3%
pow268.3%
hypot-define68.3%
pow268.3%
Applied egg-rr68.3%
Taylor expanded in x around inf 67.5%
associate-/r/67.5%
unpow267.5%
associate-*r*70.5%
Applied egg-rr70.5%
Final simplification63.9%
(FPCore (x y z) :precision binary64 (if (<= y 2.6e+94) (* z (* z (/ -0.5 y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.6e+94) {
tmp = z * (z * (-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 <= 2.6d+94) then
tmp = z * (z * ((-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 <= 2.6e+94) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.6e+94: tmp = z * (z * (-0.5 / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.6e+94) tmp = Float64(z * Float64(z * 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 <= 2.6e+94) tmp = z * (z * (-0.5 / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.6e+94], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{+94}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 2.5999999999999999e94Initial program 80.1%
remove-double-neg80.1%
distribute-lft-neg-out80.1%
distribute-frac-neg280.1%
distribute-frac-neg80.1%
neg-mul-180.1%
distribute-lft-neg-out80.1%
*-commutative80.1%
distribute-lft-neg-in80.1%
times-frac80.1%
metadata-eval80.1%
metadata-eval80.1%
associate--l+80.1%
fma-define82.4%
Simplified82.4%
Taylor expanded in z around inf 39.1%
*-commutative39.1%
associate-*l/39.1%
Simplified39.1%
associate-/l*39.1%
unpow239.1%
associate-*l*41.6%
Applied egg-rr41.6%
if 2.5999999999999999e94 < y Initial program 23.0%
remove-double-neg23.0%
distribute-lft-neg-out23.0%
distribute-frac-neg223.0%
distribute-frac-neg23.0%
neg-mul-123.0%
distribute-lft-neg-out23.0%
*-commutative23.0%
distribute-lft-neg-in23.0%
times-frac23.0%
metadata-eval23.0%
metadata-eval23.0%
associate--l+23.0%
fma-define23.0%
Simplified23.0%
Taylor expanded in y around inf 65.4%
(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 71.9%
remove-double-neg71.9%
distribute-lft-neg-out71.9%
distribute-frac-neg271.9%
distribute-frac-neg71.9%
neg-mul-171.9%
distribute-lft-neg-out71.9%
*-commutative71.9%
distribute-lft-neg-in71.9%
times-frac71.9%
metadata-eval71.9%
metadata-eval71.9%
associate--l+71.9%
fma-define73.8%
Simplified73.8%
Taylor expanded in y around inf 25.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 2024170
(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)))