
(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 12 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 (fma (+ x z) (/ (- x z) y) y)))
double code(double x, double y, double z) {
return 0.5 * fma((x + z), ((x - z) / y), y);
}
function code(x, y, z) return Float64(0.5 * fma(Float64(x + z), Float64(Float64(x - z) / y), y)) end
code[x_, y_, z_] := N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \mathsf{fma}\left(x + z, \frac{x - z}{y}, y\right)
\end{array}
Initial program 69.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in x around 0 81.2%
associate--l+81.2%
div-sub86.3%
Simplified86.3%
pow286.3%
unpow286.3%
difference-of-squares90.7%
Applied egg-rr90.7%
+-commutative90.7%
associate-/l*99.9%
fma-define99.9%
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(if (<= (* z z) 5e-282)
(* 0.5 y)
(if (<= (* z z) 4e-75)
(* 0.5 (* x (/ (- x z) y)))
(if (<= (* z z) 2e-47) (* 0.5 y) (* (* z (- x z)) (/ 0.5 y))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-282) {
tmp = 0.5 * y;
} else if ((z * z) <= 4e-75) {
tmp = 0.5 * (x * ((x - z) / y));
} else if ((z * z) <= 2e-47) {
tmp = 0.5 * y;
} else {
tmp = (z * (x - z)) * (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 ((z * z) <= 5d-282) then
tmp = 0.5d0 * y
else if ((z * z) <= 4d-75) then
tmp = 0.5d0 * (x * ((x - z) / y))
else if ((z * z) <= 2d-47) then
tmp = 0.5d0 * y
else
tmp = (z * (x - z)) * (0.5d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-282) {
tmp = 0.5 * y;
} else if ((z * z) <= 4e-75) {
tmp = 0.5 * (x * ((x - z) / y));
} else if ((z * z) <= 2e-47) {
tmp = 0.5 * y;
} else {
tmp = (z * (x - z)) * (0.5 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e-282: tmp = 0.5 * y elif (z * z) <= 4e-75: tmp = 0.5 * (x * ((x - z) / y)) elif (z * z) <= 2e-47: tmp = 0.5 * y else: tmp = (z * (x - z)) * (0.5 / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-282) tmp = Float64(0.5 * y); elseif (Float64(z * z) <= 4e-75) tmp = Float64(0.5 * Float64(x * Float64(Float64(x - z) / y))); elseif (Float64(z * z) <= 2e-47) tmp = Float64(0.5 * y); else tmp = Float64(Float64(z * Float64(x - z)) * Float64(0.5 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e-282) tmp = 0.5 * y; elseif ((z * z) <= 4e-75) tmp = 0.5 * (x * ((x - z) / y)); elseif ((z * z) <= 2e-47) tmp = 0.5 * y; else tmp = (z * (x - z)) * (0.5 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-282], N[(0.5 * y), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 4e-75], N[(0.5 * N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e-47], N[(0.5 * y), $MachinePrecision], N[(N[(z * N[(x - z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-282}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-75}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x - z}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{-47}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(x - z\right)\right) \cdot \frac{0.5}{y}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000001e-282 or 3.9999999999999998e-75 < (*.f64 z z) < 1.9999999999999999e-47Initial 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-define66.3%
Simplified66.3%
Taylor expanded in y around inf 62.6%
*-commutative62.6%
Simplified62.6%
if 5.0000000000000001e-282 < (*.f64 z z) < 3.9999999999999998e-75Initial program 86.5%
remove-double-neg86.5%
distribute-lft-neg-out86.5%
distribute-frac-neg286.5%
distribute-frac-neg86.5%
neg-mul-186.5%
distribute-lft-neg-out86.5%
*-commutative86.5%
distribute-lft-neg-in86.5%
times-frac86.5%
metadata-eval86.5%
metadata-eval86.5%
associate--l+86.5%
fma-define86.5%
Simplified86.5%
Taylor expanded in x around 0 93.1%
associate--l+93.1%
div-sub93.1%
Simplified93.1%
pow293.1%
unpow293.1%
difference-of-squares93.1%
Applied egg-rr93.1%
Taylor expanded in y around 0 71.0%
associate-*r/74.2%
+-commutative74.2%
Simplified74.2%
Taylor expanded in z around 0 64.8%
if 1.9999999999999999e-47 < (*.f64 z z) Initial program 68.5%
remove-double-neg68.5%
distribute-lft-neg-out68.5%
distribute-frac-neg268.5%
distribute-frac-neg68.5%
neg-mul-168.5%
distribute-lft-neg-out68.5%
*-commutative68.5%
distribute-lft-neg-in68.5%
times-frac68.5%
metadata-eval68.5%
metadata-eval68.5%
associate--l+68.5%
fma-define72.5%
Simplified72.5%
Taylor expanded in y around 0 65.9%
associate-*r/65.9%
*-commutative65.9%
associate-/l*65.9%
Simplified65.9%
pow281.2%
unpow281.2%
difference-of-squares88.7%
Applied egg-rr73.4%
Taylor expanded in x around 0 67.3%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (if (<= x 1.7e+151) (* 0.5 (+ y (* z (/ (- x z) y)))) (* 0.5 (* (+ x z) (* (- x z) (/ 1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.7e+151) {
tmp = 0.5 * (y + (z * ((x - z) / y)));
} else {
tmp = 0.5 * ((x + z) * ((x - z) * (1.0 / 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 <= 1.7d+151) then
tmp = 0.5d0 * (y + (z * ((x - z) / y)))
else
tmp = 0.5d0 * ((x + z) * ((x - z) * (1.0d0 / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.7e+151) {
tmp = 0.5 * (y + (z * ((x - z) / y)));
} else {
tmp = 0.5 * ((x + z) * ((x - z) * (1.0 / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.7e+151: tmp = 0.5 * (y + (z * ((x - z) / y))) else: tmp = 0.5 * ((x + z) * ((x - z) * (1.0 / y))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.7e+151) tmp = Float64(0.5 * Float64(y + Float64(z * Float64(Float64(x - z) / y)))); else tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) * Float64(1.0 / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.7e+151) tmp = 0.5 * (y + (z * ((x - z) / y))); else tmp = 0.5 * ((x + z) * ((x - z) * (1.0 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.7e+151], N[(0.5 * N[(y + N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \left(\left(x - z\right) \cdot \frac{1}{y}\right)\right)\\
\end{array}
\end{array}
if x < 1.7e151Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.2%
metadata-eval71.2%
metadata-eval71.2%
associate--l+71.2%
fma-define72.0%
Simplified72.0%
Taylor expanded in x around 0 84.0%
associate--l+84.0%
div-sub89.2%
Simplified89.2%
pow289.2%
unpow289.2%
difference-of-squares91.8%
Applied egg-rr91.8%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 82.9%
if 1.7e151 < x Initial program 54.2%
remove-double-neg54.2%
distribute-lft-neg-out54.2%
distribute-frac-neg254.2%
distribute-frac-neg54.2%
neg-mul-154.2%
distribute-lft-neg-out54.2%
*-commutative54.2%
distribute-lft-neg-in54.2%
times-frac54.2%
metadata-eval54.2%
metadata-eval54.2%
associate--l+54.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in x around 0 49.4%
associate--l+49.4%
div-sub54.2%
Simplified54.2%
pow254.2%
unpow254.2%
difference-of-squares78.3%
Applied egg-rr78.3%
Taylor expanded in y around 0 78.3%
associate-*r/90.7%
+-commutative90.7%
Simplified90.7%
clear-num90.7%
associate-/r/90.8%
Applied egg-rr90.8%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (<= y 2.9e-123) (* 0.5 (* x (/ (- x z) y))) (if (<= y 1.65e+61) (* z (* z (/ -0.5 y))) (* 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e-123) {
tmp = 0.5 * (x * ((x - z) / y));
} else if (y <= 1.65e+61) {
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.9d-123) then
tmp = 0.5d0 * (x * ((x - z) / y))
else if (y <= 1.65d+61) 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.9e-123) {
tmp = 0.5 * (x * ((x - z) / y));
} else if (y <= 1.65e+61) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.9e-123: tmp = 0.5 * (x * ((x - z) / y)) elif y <= 1.65e+61: tmp = z * (z * (-0.5 / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.9e-123) tmp = Float64(0.5 * Float64(x * Float64(Float64(x - z) / y))); elseif (y <= 1.65e+61) 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.9e-123) tmp = 0.5 * (x * ((x - z) / y)); elseif (y <= 1.65e+61) tmp = z * (z * (-0.5 / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.9e-123], N[(0.5 * N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e+61], 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.9 \cdot 10^{-123}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x - z}{y}\right)\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+61}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 2.90000000000000004e-123Initial program 74.6%
remove-double-neg74.6%
distribute-lft-neg-out74.6%
distribute-frac-neg274.6%
distribute-frac-neg74.6%
neg-mul-174.6%
distribute-lft-neg-out74.6%
*-commutative74.6%
distribute-lft-neg-in74.6%
times-frac74.6%
metadata-eval74.6%
metadata-eval74.6%
associate--l+74.6%
fma-define77.1%
Simplified77.1%
Taylor expanded in x around 0 79.3%
associate--l+79.3%
div-sub87.3%
Simplified87.3%
pow287.3%
unpow287.3%
difference-of-squares91.1%
Applied egg-rr91.1%
Taylor expanded in y around 0 68.2%
associate-*r/73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in z around 0 43.5%
if 2.90000000000000004e-123 < y < 1.6499999999999999e61Initial program 89.8%
remove-double-neg89.8%
distribute-lft-neg-out89.8%
distribute-frac-neg289.8%
distribute-frac-neg89.8%
neg-mul-189.8%
distribute-lft-neg-out89.8%
*-commutative89.8%
distribute-lft-neg-in89.8%
times-frac89.8%
metadata-eval89.8%
metadata-eval89.8%
associate--l+89.8%
fma-define95.0%
Simplified95.0%
Taylor expanded in z around inf 59.3%
*-commutative59.3%
associate-*l/59.3%
Simplified59.3%
associate-/l*59.2%
unpow259.2%
associate-*l*64.1%
Applied egg-rr64.1%
if 1.6499999999999999e61 < y Initial program 42.2%
remove-double-neg42.2%
distribute-lft-neg-out42.2%
distribute-frac-neg242.2%
distribute-frac-neg42.2%
neg-mul-142.2%
distribute-lft-neg-out42.2%
*-commutative42.2%
distribute-lft-neg-in42.2%
times-frac42.2%
metadata-eval42.2%
metadata-eval42.2%
associate--l+42.2%
fma-define42.3%
Simplified42.3%
Taylor expanded in y around inf 58.2%
*-commutative58.2%
Simplified58.2%
Final simplification49.8%
(FPCore (x y z) :precision binary64 (if (<= x 1.02e+151) (* 0.5 (+ y (* z (/ (- x z) y)))) (/ (* 0.5 (+ x z)) (/ y (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.02e+151) {
tmp = 0.5 * (y + (z * ((x - z) / y)));
} else {
tmp = (0.5 * (x + z)) / (y / (x - z));
}
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 <= 1.02d+151) then
tmp = 0.5d0 * (y + (z * ((x - z) / y)))
else
tmp = (0.5d0 * (x + z)) / (y / (x - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.02e+151) {
tmp = 0.5 * (y + (z * ((x - z) / y)));
} else {
tmp = (0.5 * (x + z)) / (y / (x - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.02e+151: tmp = 0.5 * (y + (z * ((x - z) / y))) else: tmp = (0.5 * (x + z)) / (y / (x - z)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.02e+151) tmp = Float64(0.5 * Float64(y + Float64(z * Float64(Float64(x - z) / y)))); else tmp = Float64(Float64(0.5 * Float64(x + z)) / Float64(y / Float64(x - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.02e+151) tmp = 0.5 * (y + (z * ((x - z) / y))); else tmp = (0.5 * (x + z)) / (y / (x - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.02e+151], N[(0.5 * N[(y + N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(x + z), $MachinePrecision]), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \left(x + z\right)}{\frac{y}{x - z}}\\
\end{array}
\end{array}
if x < 1.02000000000000002e151Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.2%
metadata-eval71.2%
metadata-eval71.2%
associate--l+71.2%
fma-define72.0%
Simplified72.0%
Taylor expanded in x around 0 84.0%
associate--l+84.0%
div-sub89.2%
Simplified89.2%
pow289.2%
unpow289.2%
difference-of-squares91.8%
Applied egg-rr91.8%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 82.9%
if 1.02000000000000002e151 < x Initial program 54.2%
remove-double-neg54.2%
distribute-lft-neg-out54.2%
distribute-frac-neg254.2%
distribute-frac-neg54.2%
neg-mul-154.2%
distribute-lft-neg-out54.2%
*-commutative54.2%
distribute-lft-neg-in54.2%
times-frac54.2%
metadata-eval54.2%
metadata-eval54.2%
associate--l+54.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in x around 0 49.4%
associate--l+49.4%
div-sub54.2%
Simplified54.2%
pow254.2%
unpow254.2%
difference-of-squares78.3%
Applied egg-rr78.3%
Taylor expanded in y around 0 78.3%
associate-*r/90.7%
+-commutative90.7%
Simplified90.7%
associate-*r*90.7%
clear-num90.7%
un-div-inv90.7%
+-commutative90.7%
*-commutative90.7%
Applied egg-rr90.7%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (- x z) y))) (if (<= x 2.56e+151) (* 0.5 (+ y (* z t_0))) (* 0.5 (* (+ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if (x <= 2.56e+151) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((x + z) * t_0);
}
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 = (x - z) / y
if (x <= 2.56d+151) then
tmp = 0.5d0 * (y + (z * t_0))
else
tmp = 0.5d0 * ((x + z) * t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if (x <= 2.56e+151) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((x + z) * t_0);
}
return tmp;
}
def code(x, y, z): t_0 = (x - z) / y tmp = 0 if x <= 2.56e+151: tmp = 0.5 * (y + (z * t_0)) else: tmp = 0.5 * ((x + z) * t_0) return tmp
function code(x, y, z) t_0 = Float64(Float64(x - z) / y) tmp = 0.0 if (x <= 2.56e+151) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); else tmp = Float64(0.5 * Float64(Float64(x + z) * t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - z) / y; tmp = 0.0; if (x <= 2.56e+151) tmp = 0.5 * (y + (z * t_0)); else tmp = 0.5 * ((x + z) * t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, 2.56e+151], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x + z), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - z}{y}\\
\mathbf{if}\;x \leq 2.56 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 2.56000000000000013e151Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.2%
metadata-eval71.2%
metadata-eval71.2%
associate--l+71.2%
fma-define72.0%
Simplified72.0%
Taylor expanded in x around 0 84.0%
associate--l+84.0%
div-sub89.2%
Simplified89.2%
pow289.2%
unpow289.2%
difference-of-squares91.8%
Applied egg-rr91.8%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 82.9%
if 2.56000000000000013e151 < x Initial program 54.2%
remove-double-neg54.2%
distribute-lft-neg-out54.2%
distribute-frac-neg254.2%
distribute-frac-neg54.2%
neg-mul-154.2%
distribute-lft-neg-out54.2%
*-commutative54.2%
distribute-lft-neg-in54.2%
times-frac54.2%
metadata-eval54.2%
metadata-eval54.2%
associate--l+54.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in x around 0 49.4%
associate--l+49.4%
div-sub54.2%
Simplified54.2%
pow254.2%
unpow254.2%
difference-of-squares78.3%
Applied egg-rr78.3%
Taylor expanded in y around 0 78.3%
associate-*r/90.7%
+-commutative90.7%
Simplified90.7%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (if (<= y 4e+168) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+168) {
tmp = 0.5 * ((x + z) * ((x - z) / 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 <= 4d+168) then
tmp = 0.5d0 * ((x + z) * ((x - z) / 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 <= 4e+168) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e+168: tmp = 0.5 * ((x + z) * ((x - z) / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e+168) tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4e+168) tmp = 0.5 * ((x + z) * ((x - z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e+168], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+168}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 3.9999999999999997e168Initial program 77.2%
remove-double-neg77.2%
distribute-lft-neg-out77.2%
distribute-frac-neg277.2%
distribute-frac-neg77.2%
neg-mul-177.2%
distribute-lft-neg-out77.2%
*-commutative77.2%
distribute-lft-neg-in77.2%
times-frac77.2%
metadata-eval77.2%
metadata-eval77.2%
associate--l+77.2%
fma-define79.9%
Simplified79.9%
Taylor expanded in x around 0 81.9%
associate--l+81.9%
div-sub87.6%
Simplified87.6%
pow287.6%
unpow287.6%
difference-of-squares92.0%
Applied egg-rr92.0%
Taylor expanded in y around 0 66.7%
associate-*r/72.1%
+-commutative72.1%
Simplified72.1%
if 3.9999999999999997e168 < y Initial program 9.2%
remove-double-neg9.2%
distribute-lft-neg-out9.2%
distribute-frac-neg29.2%
distribute-frac-neg9.2%
neg-mul-19.2%
distribute-lft-neg-out9.2%
*-commutative9.2%
distribute-lft-neg-in9.2%
times-frac9.2%
metadata-eval9.2%
metadata-eval9.2%
associate--l+9.2%
fma-define9.2%
Simplified9.2%
Taylor expanded in y around inf 79.3%
*-commutative79.3%
Simplified79.3%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (<= z 9.4e+79) (* 0.5 y) (/ z (/ y (* 0.5 (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 9.4e+79) {
tmp = 0.5 * y;
} else {
tmp = z / (y / (0.5 * -z));
}
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 <= 9.4d+79) then
tmp = 0.5d0 * y
else
tmp = z / (y / (0.5d0 * -z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 9.4e+79) {
tmp = 0.5 * y;
} else {
tmp = z / (y / (0.5 * -z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 9.4e+79: tmp = 0.5 * y else: tmp = z / (y / (0.5 * -z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 9.4e+79) tmp = Float64(0.5 * y); else tmp = Float64(z / Float64(y / Float64(0.5 * Float64(-z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 9.4e+79) tmp = 0.5 * y; else tmp = z / (y / (0.5 * -z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 9.4e+79], N[(0.5 * y), $MachinePrecision], N[(z / N[(y / N[(0.5 * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 9.4 \cdot 10^{+79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{0.5 \cdot \left(-z\right)}}\\
\end{array}
\end{array}
if z < 9.40000000000000045e79Initial program 72.2%
remove-double-neg72.2%
distribute-lft-neg-out72.2%
distribute-frac-neg272.2%
distribute-frac-neg72.2%
neg-mul-172.2%
distribute-lft-neg-out72.2%
*-commutative72.2%
distribute-lft-neg-in72.2%
times-frac72.2%
metadata-eval72.2%
metadata-eval72.2%
associate--l+72.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in y around inf 38.4%
*-commutative38.4%
Simplified38.4%
if 9.40000000000000045e79 < z Initial program 59.8%
remove-double-neg59.8%
distribute-lft-neg-out59.8%
distribute-frac-neg259.8%
distribute-frac-neg59.8%
neg-mul-159.8%
distribute-lft-neg-out59.8%
*-commutative59.8%
distribute-lft-neg-in59.8%
times-frac59.8%
metadata-eval59.8%
metadata-eval59.8%
associate--l+59.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in z around inf 71.4%
*-commutative71.4%
associate-*l/71.4%
Simplified71.4%
associate-/l*71.4%
unpow271.4%
associate-*l*77.1%
Applied egg-rr77.1%
associate-*r/77.1%
clear-num77.1%
Applied egg-rr77.1%
un-div-inv77.1%
frac-2neg77.1%
distribute-neg-frac277.1%
distribute-rgt-neg-in77.1%
metadata-eval77.1%
Applied egg-rr77.1%
Final simplification46.1%
(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 69.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in x around 0 81.2%
associate--l+81.2%
div-sub86.3%
Simplified86.3%
pow286.3%
unpow286.3%
difference-of-squares90.7%
Applied egg-rr90.7%
associate-/l*99.9%
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (if (<= z 1.35e+79) (* 0.5 y) (/ z (* y (/ -2.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.35e+79) {
tmp = 0.5 * y;
} else {
tmp = z / (y * (-2.0 / z));
}
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 <= 1.35d+79) then
tmp = 0.5d0 * y
else
tmp = z / (y * ((-2.0d0) / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.35e+79) {
tmp = 0.5 * y;
} else {
tmp = z / (y * (-2.0 / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.35e+79: tmp = 0.5 * y else: tmp = z / (y * (-2.0 / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.35e+79) tmp = Float64(0.5 * y); else tmp = Float64(z / Float64(y * Float64(-2.0 / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.35e+79) tmp = 0.5 * y; else tmp = z / (y * (-2.0 / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.35e+79], N[(0.5 * y), $MachinePrecision], N[(z / N[(y * N[(-2.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.35 \cdot 10^{+79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{y \cdot \frac{-2}{z}}\\
\end{array}
\end{array}
if z < 1.35e79Initial program 72.2%
remove-double-neg72.2%
distribute-lft-neg-out72.2%
distribute-frac-neg272.2%
distribute-frac-neg72.2%
neg-mul-172.2%
distribute-lft-neg-out72.2%
*-commutative72.2%
distribute-lft-neg-in72.2%
times-frac72.2%
metadata-eval72.2%
metadata-eval72.2%
associate--l+72.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in y around inf 38.4%
*-commutative38.4%
Simplified38.4%
if 1.35e79 < z Initial program 59.8%
remove-double-neg59.8%
distribute-lft-neg-out59.8%
distribute-frac-neg259.8%
distribute-frac-neg59.8%
neg-mul-159.8%
distribute-lft-neg-out59.8%
*-commutative59.8%
distribute-lft-neg-in59.8%
times-frac59.8%
metadata-eval59.8%
metadata-eval59.8%
associate--l+59.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in z around inf 71.4%
*-commutative71.4%
associate-*l/71.4%
Simplified71.4%
associate-/l*71.4%
unpow271.4%
associate-*l*77.1%
Applied egg-rr77.1%
associate-*r/77.1%
clear-num77.1%
Applied egg-rr77.1%
un-div-inv77.1%
div-inv77.1%
*-commutative77.1%
associate-/r*77.1%
metadata-eval77.1%
Applied egg-rr77.1%
Final simplification46.1%
(FPCore (x y z) :precision binary64 (if (<= z 1e+79) (* 0.5 y) (* z (* z (/ -0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e+79) {
tmp = 0.5 * y;
} else {
tmp = z * (z * (-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 (z <= 1d+79) then
tmp = 0.5d0 * y
else
tmp = z * (z * ((-0.5d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e+79) {
tmp = 0.5 * y;
} else {
tmp = z * (z * (-0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e+79: tmp = 0.5 * y else: tmp = z * (z * (-0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e+79) tmp = Float64(0.5 * y); else tmp = Float64(z * Float64(z * Float64(-0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e+79) tmp = 0.5 * y; else tmp = z * (z * (-0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e+79], N[(0.5 * y), $MachinePrecision], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\end{array}
\end{array}
if z < 9.99999999999999967e78Initial program 72.2%
remove-double-neg72.2%
distribute-lft-neg-out72.2%
distribute-frac-neg272.2%
distribute-frac-neg72.2%
neg-mul-172.2%
distribute-lft-neg-out72.2%
*-commutative72.2%
distribute-lft-neg-in72.2%
times-frac72.2%
metadata-eval72.2%
metadata-eval72.2%
associate--l+72.2%
fma-define73.2%
Simplified73.2%
Taylor expanded in y around inf 38.4%
*-commutative38.4%
Simplified38.4%
if 9.99999999999999967e78 < z Initial program 59.8%
remove-double-neg59.8%
distribute-lft-neg-out59.8%
distribute-frac-neg259.8%
distribute-frac-neg59.8%
neg-mul-159.8%
distribute-lft-neg-out59.8%
*-commutative59.8%
distribute-lft-neg-in59.8%
times-frac59.8%
metadata-eval59.8%
metadata-eval59.8%
associate--l+59.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in z around inf 71.4%
*-commutative71.4%
associate-*l/71.4%
Simplified71.4%
associate-/l*71.4%
unpow271.4%
associate-*l*77.1%
Applied egg-rr77.1%
Final simplification46.1%
(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 69.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in y around inf 34.8%
*-commutative34.8%
Simplified34.8%
Final simplification34.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 2024123
(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)))