
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (* 0.5 (* (+ (hypot x y) z) (/ (- (hypot x y) z) y))))
double code(double x, double y, double z) {
return 0.5 * ((hypot(x, y) + z) * ((hypot(x, y) - z) / y));
}
public static double code(double x, double y, double z) {
return 0.5 * ((Math.hypot(x, y) + z) * ((Math.hypot(x, y) - z) / y));
}
def code(x, y, z): return 0.5 * ((math.hypot(x, y) + z) * ((math.hypot(x, y) - z) / y))
function code(x, y, z) return Float64(0.5 * Float64(Float64(hypot(x, y) + z) * Float64(Float64(hypot(x, y) - z) / y))) end
function tmp = code(x, y, z) tmp = 0.5 * ((hypot(x, y) + z) * ((hypot(x, y) - z) / y)); end
code[x_, y_, z_] := N[(0.5 * N[(N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] + z), $MachinePrecision] * N[(N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(\left(\mathsf{hypot}\left(x, y\right) + z\right) \cdot \frac{\mathsf{hypot}\left(x, y\right) - 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-define72.7%
Simplified72.7%
fma-undefine71.9%
associate--l+71.9%
add-sqr-sqrt71.9%
difference-of-squares75.5%
hypot-define76.7%
hypot-define77.5%
Applied egg-rr77.5%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 3e+132) (* 0.5 (/ (fma x x (- (* y y) (* z z))) y)) (* 0.5 (* (+ y z) (/ (- y z) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3e+132) {
tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
} else {
tmp = 0.5 * ((y + z) * ((y - z) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3e+132) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y)); else tmp = Float64(0.5 * Float64(Float64(y + z) * Float64(Float64(y - z) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3e+132], 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[(N[(y + z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+132}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\
\end{array}
\end{array}
if y < 2.9999999999999998e132Initial program 82.4%
remove-double-neg82.4%
distribute-lft-neg-out82.4%
distribute-frac-neg282.4%
distribute-frac-neg82.4%
neg-mul-182.4%
distribute-lft-neg-out82.4%
*-commutative82.4%
distribute-lft-neg-in82.4%
times-frac82.4%
metadata-eval82.4%
metadata-eval82.4%
associate--l+82.4%
fma-define83.4%
Simplified83.4%
if 2.9999999999999998e132 < y Initial program 11.4%
remove-double-neg11.4%
distribute-lft-neg-out11.4%
distribute-frac-neg211.4%
distribute-frac-neg11.4%
neg-mul-111.4%
distribute-lft-neg-out11.4%
*-commutative11.4%
distribute-lft-neg-in11.4%
times-frac11.4%
metadata-eval11.4%
metadata-eval11.4%
associate--l+11.4%
fma-define11.4%
Simplified11.4%
fma-undefine11.4%
associate--l+11.4%
add-sqr-sqrt11.4%
difference-of-squares13.3%
hypot-define18.6%
hypot-define21.6%
Applied egg-rr21.6%
Taylor expanded in x around 0 21.6%
associate-/l*91.5%
Simplified91.5%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (* (+ y z) (/ z (- y))))))
(if (<= y 9e-266)
t_0
(if (<= y 1.8e-240)
(* (/ x y) (/ x 2.0))
(if (<= y 0.46)
t_0
(if (<= y 5.6e+76) (* x (* x (/ 1.0 (* y 2.0)))) (* 0.5 y)))))))
double code(double x, double y, double z) {
double t_0 = 0.5 * ((y + z) * (z / -y));
double tmp;
if (y <= 9e-266) {
tmp = t_0;
} else if (y <= 1.8e-240) {
tmp = (x / y) * (x / 2.0);
} else if (y <= 0.46) {
tmp = t_0;
} else if (y <= 5.6e+76) {
tmp = x * (x * (1.0 / (y * 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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * ((y + z) * (z / -y))
if (y <= 9d-266) then
tmp = t_0
else if (y <= 1.8d-240) then
tmp = (x / y) * (x / 2.0d0)
else if (y <= 0.46d0) then
tmp = t_0
else if (y <= 5.6d+76) then
tmp = x * (x * (1.0d0 / (y * 2.0d0)))
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 * ((y + z) * (z / -y));
double tmp;
if (y <= 9e-266) {
tmp = t_0;
} else if (y <= 1.8e-240) {
tmp = (x / y) * (x / 2.0);
} else if (y <= 0.46) {
tmp = t_0;
} else if (y <= 5.6e+76) {
tmp = x * (x * (1.0 / (y * 2.0)));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): t_0 = 0.5 * ((y + z) * (z / -y)) tmp = 0 if y <= 9e-266: tmp = t_0 elif y <= 1.8e-240: tmp = (x / y) * (x / 2.0) elif y <= 0.46: tmp = t_0 elif y <= 5.6e+76: tmp = x * (x * (1.0 / (y * 2.0))) else: tmp = 0.5 * y return tmp
function code(x, y, z) t_0 = Float64(0.5 * Float64(Float64(y + z) * Float64(z / Float64(-y)))) tmp = 0.0 if (y <= 9e-266) tmp = t_0; elseif (y <= 1.8e-240) tmp = Float64(Float64(x / y) * Float64(x / 2.0)); elseif (y <= 0.46) tmp = t_0; elseif (y <= 5.6e+76) tmp = Float64(x * Float64(x * Float64(1.0 / Float64(y * 2.0)))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.5 * ((y + z) * (z / -y)); tmp = 0.0; if (y <= 9e-266) tmp = t_0; elseif (y <= 1.8e-240) tmp = (x / y) * (x / 2.0); elseif (y <= 0.46) tmp = t_0; elseif (y <= 5.6e+76) tmp = x * (x * (1.0 / (y * 2.0))); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(N[(y + z), $MachinePrecision] * N[(z / (-y)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 9e-266], t$95$0, If[LessEqual[y, 1.8e-240], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.46], t$95$0, If[LessEqual[y, 5.6e+76], N[(x * N[(x * N[(1.0 / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(y + z\right) \cdot \frac{z}{-y}\right)\\
\mathbf{if}\;y \leq 9 \cdot 10^{-266}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-240}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\mathbf{elif}\;y \leq 0.46:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+76}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{1}{y \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 9.0000000000000006e-266 or 1.7999999999999999e-240 < y < 0.46000000000000002Initial program 82.3%
remove-double-neg82.3%
distribute-lft-neg-out82.3%
distribute-frac-neg282.3%
distribute-frac-neg82.3%
neg-mul-182.3%
distribute-lft-neg-out82.3%
*-commutative82.3%
distribute-lft-neg-in82.3%
times-frac82.3%
metadata-eval82.3%
metadata-eval82.3%
associate--l+82.3%
fma-define83.3%
Simplified83.3%
fma-undefine82.3%
associate--l+82.3%
add-sqr-sqrt82.3%
difference-of-squares85.7%
hypot-define86.2%
hypot-define86.8%
Applied egg-rr86.8%
Taylor expanded in x around 0 58.2%
associate-/l*68.3%
Simplified68.3%
Taylor expanded in y around 0 45.0%
neg-mul-145.0%
distribute-neg-frac245.0%
Simplified45.0%
if 9.0000000000000006e-266 < y < 1.7999999999999999e-240Initial program 99.6%
clear-num99.6%
inv-pow99.6%
associate-/l*99.2%
add-sqr-sqrt99.2%
pow299.2%
hypot-define99.2%
pow299.2%
Applied egg-rr99.2%
unpow-199.2%
associate-*r/99.6%
Simplified99.6%
Taylor expanded in x around inf 75.1%
clear-num75.1%
unpow275.1%
times-frac74.8%
Applied egg-rr74.8%
if 0.46000000000000002 < y < 5.5999999999999997e76Initial program 78.8%
clear-num78.7%
inv-pow78.7%
associate-/l*78.6%
add-sqr-sqrt78.6%
pow278.6%
hypot-define78.6%
pow278.6%
Applied egg-rr78.6%
unpow-178.6%
associate-*r/78.7%
Simplified78.7%
Taylor expanded in x around inf 46.7%
associate-/r/46.7%
unpow246.7%
associate-*r*56.8%
Applied egg-rr56.8%
if 5.5999999999999997e76 < y Initial program 23.1%
Taylor expanded in y around inf 70.6%
*-commutative70.6%
Simplified70.6%
Final simplification50.8%
(FPCore (x y z)
:precision binary64
(if (<= y 3e-86)
(* 0.5 (* (+ x z) (/ (- x z) y)))
(if (<= y 2.65e+132)
(/ (- (+ (* y y) (* x x)) (* z z)) (* y 2.0))
(* 0.5 (* (+ y z) (/ (- y z) y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3e-86) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else if (y <= 2.65e+132) {
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * ((y + z) * ((y - 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 <= 3d-86) then
tmp = 0.5d0 * ((x + z) * ((x - z) / y))
else if (y <= 2.65d+132) then
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0d0)
else
tmp = 0.5d0 * ((y + z) * ((y - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3e-86) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else if (y <= 2.65e+132) {
tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * ((y + z) * ((y - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3e-86: tmp = 0.5 * ((x + z) * ((x - z) / y)) elif y <= 2.65e+132: tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0) else: tmp = 0.5 * ((y + z) * ((y - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3e-86) tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); elseif (y <= 2.65e+132) tmp = Float64(Float64(Float64(Float64(y * y) + Float64(x * x)) - Float64(z * z)) / Float64(y * 2.0)); else tmp = Float64(0.5 * Float64(Float64(y + z) * Float64(Float64(y - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3e-86) tmp = 0.5 * ((x + z) * ((x - z) / y)); elseif (y <= 2.65e+132) tmp = (((y * y) + (x * x)) - (z * z)) / (y * 2.0); else tmp = 0.5 * ((y + z) * ((y - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3e-86], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.65e+132], 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[(N[(y + z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-86}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+132}:\\
\;\;\;\;\frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\
\end{array}
\end{array}
if y < 3.0000000000000001e-86Initial program 81.0%
remove-double-neg81.0%
distribute-lft-neg-out81.0%
distribute-frac-neg281.0%
distribute-frac-neg81.0%
neg-mul-181.0%
distribute-lft-neg-out81.0%
*-commutative81.0%
distribute-lft-neg-in81.0%
times-frac81.0%
metadata-eval81.0%
metadata-eval81.0%
associate--l+81.0%
fma-define82.1%
Simplified82.1%
fma-undefine81.0%
associate--l+81.0%
add-sqr-sqrt81.0%
difference-of-squares84.7%
hypot-define85.2%
hypot-define85.8%
Applied egg-rr85.8%
Taylor expanded in y around 0 74.0%
associate-/l*76.6%
+-commutative76.6%
Simplified76.6%
if 3.0000000000000001e-86 < y < 2.65e132Initial program 88.5%
if 2.65e132 < y Initial program 11.4%
remove-double-neg11.4%
distribute-lft-neg-out11.4%
distribute-frac-neg211.4%
distribute-frac-neg11.4%
neg-mul-111.4%
distribute-lft-neg-out11.4%
*-commutative11.4%
distribute-lft-neg-in11.4%
times-frac11.4%
metadata-eval11.4%
metadata-eval11.4%
associate--l+11.4%
fma-define11.4%
Simplified11.4%
fma-undefine11.4%
associate--l+11.4%
add-sqr-sqrt11.4%
difference-of-squares13.3%
hypot-define18.6%
hypot-define21.6%
Applied egg-rr21.6%
Taylor expanded in x around 0 21.6%
associate-/l*91.5%
Simplified91.5%
Final simplification80.8%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+227) (* 0.5 (* (+ y z) (/ (- y z) y))) (* 0.5 (* (+ x z) (/ (- x z) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+227) {
tmp = 0.5 * ((y + z) * ((y - z) / y));
} else {
tmp = 0.5 * ((x + z) * ((x - 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 ((x * x) <= 2d+227) then
tmp = 0.5d0 * ((y + z) * ((y - z) / y))
else
tmp = 0.5d0 * ((x + z) * ((x - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+227) {
tmp = 0.5 * ((y + z) * ((y - z) / y));
} else {
tmp = 0.5 * ((x + z) * ((x - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+227: tmp = 0.5 * ((y + z) * ((y - z) / y)) else: tmp = 0.5 * ((x + z) * ((x - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+227) tmp = Float64(0.5 * Float64(Float64(y + z) * Float64(Float64(y - z) / y))); else tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+227) tmp = 0.5 * ((y + z) * ((y - z) / y)); else tmp = 0.5 * ((x + z) * ((x - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+227], N[(0.5 * N[(N[(y + z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+227}:\\
\;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000002e227Initial program 75.9%
remove-double-neg75.9%
distribute-lft-neg-out75.9%
distribute-frac-neg275.9%
distribute-frac-neg75.9%
neg-mul-175.9%
distribute-lft-neg-out75.9%
*-commutative75.9%
distribute-lft-neg-in75.9%
times-frac75.9%
metadata-eval75.9%
metadata-eval75.9%
associate--l+75.9%
fma-define75.9%
Simplified75.9%
fma-undefine75.9%
associate--l+75.9%
add-sqr-sqrt75.9%
difference-of-squares76.4%
hypot-define77.4%
hypot-define77.5%
Applied egg-rr77.5%
Taylor expanded in x around 0 66.2%
associate-/l*88.1%
Simplified88.1%
if 2.0000000000000002e227 < (*.f64 x x) Initial program 62.1%
remove-double-neg62.1%
distribute-lft-neg-out62.1%
distribute-frac-neg262.1%
distribute-frac-neg62.1%
neg-mul-162.1%
distribute-lft-neg-out62.1%
*-commutative62.1%
distribute-lft-neg-in62.1%
times-frac62.1%
metadata-eval62.1%
metadata-eval62.1%
associate--l+62.1%
fma-define64.8%
Simplified64.8%
fma-undefine62.1%
associate--l+62.1%
add-sqr-sqrt62.1%
difference-of-squares73.4%
hypot-define74.8%
hypot-define77.6%
Applied egg-rr77.6%
Taylor expanded in y around 0 77.3%
associate-/l*88.3%
+-commutative88.3%
Simplified88.3%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (<= x 4.5e+113) (* 0.5 (* (+ y z) (/ (- y z) y))) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4.5e+113) {
tmp = 0.5 * ((y + z) * ((y - z) / y));
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if (x <= 4.5d+113) then
tmp = 0.5d0 * ((y + z) * ((y - z) / y))
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 4.5e+113) {
tmp = 0.5 * ((y + z) * ((y - z) / y));
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 4.5e+113: tmp = 0.5 * ((y + z) * ((y - z) / y)) else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 4.5e+113) tmp = Float64(0.5 * Float64(Float64(y + z) * Float64(Float64(y - z) / y))); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 4.5e+113) tmp = 0.5 * ((y + z) * ((y - z) / y)); else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 4.5e+113], N[(0.5 * N[(N[(y + z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.5 \cdot 10^{+113}:\\
\;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if x < 4.5000000000000001e113Initial program 72.6%
remove-double-neg72.6%
distribute-lft-neg-out72.6%
distribute-frac-neg272.6%
distribute-frac-neg72.6%
neg-mul-172.6%
distribute-lft-neg-out72.6%
*-commutative72.6%
distribute-lft-neg-in72.6%
times-frac72.6%
metadata-eval72.6%
metadata-eval72.6%
associate--l+72.6%
fma-define73.1%
Simplified73.1%
fma-undefine72.6%
associate--l+72.6%
add-sqr-sqrt72.6%
difference-of-squares75.0%
hypot-define76.4%
hypot-define76.4%
Applied egg-rr76.4%
Taylor expanded in x around 0 56.5%
associate-/l*78.1%
Simplified78.1%
if 4.5000000000000001e113 < x Initial program 67.1%
clear-num67.1%
inv-pow67.1%
associate-/l*67.1%
add-sqr-sqrt67.1%
pow267.1%
hypot-define67.1%
pow267.1%
Applied egg-rr67.1%
unpow-167.1%
associate-*r/67.1%
Simplified67.1%
Taylor expanded in x around inf 70.0%
clear-num70.0%
unpow270.0%
times-frac85.5%
Applied egg-rr85.5%
Final simplification79.1%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+227) (* 0.5 y) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+227) {
tmp = 0.5 * y;
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if ((x * x) <= 2d+227) then
tmp = 0.5d0 * y
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+227) {
tmp = 0.5 * y;
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+227: tmp = 0.5 * y else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+227) tmp = Float64(0.5 * y); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+227) tmp = 0.5 * y; else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+227], N[(0.5 * y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+227}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000002e227Initial program 75.9%
Taylor expanded in y around inf 39.7%
*-commutative39.7%
Simplified39.7%
if 2.0000000000000002e227 < (*.f64 x x) Initial program 62.1%
clear-num62.1%
inv-pow62.1%
associate-/l*62.1%
add-sqr-sqrt62.1%
pow262.1%
hypot-define62.1%
pow262.1%
Applied egg-rr62.1%
unpow-162.1%
associate-*r/62.1%
Simplified62.1%
Taylor expanded in x around inf 67.1%
clear-num67.1%
unpow267.1%
times-frac76.8%
Applied egg-rr76.8%
Final simplification50.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%
Taylor expanded in y around inf 32.3%
*-commutative32.3%
Simplified32.3%
Final simplification32.3%
(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 2024077
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))