
(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) y) (+ x z)))))
double code(double x, double y, double z) {
return 0.5 * (y + (((x - z) / y) * (x + z)));
}
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) / y) * (x + z)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + (((x - z) / y) * (x + z)));
}
def code(x, y, z): return 0.5 * (y + (((x - z) / y) * (x + z)))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(Float64(x - z) / y) * Float64(x + z)))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + (((x - z) / y) * (x + z))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] * N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{x - z}{y} \cdot \left(x + z\right)\right)
\end{array}
Initial program 72.9%
remove-double-neg72.9%
distribute-lft-neg-out72.9%
distribute-frac-neg272.9%
distribute-frac-neg72.9%
neg-mul-172.9%
distribute-lft-neg-out72.9%
*-commutative72.9%
distribute-lft-neg-in72.9%
times-frac72.9%
metadata-eval72.9%
metadata-eval72.9%
associate--l+72.9%
fma-define74.8%
Simplified74.8%
Taylor expanded in x around 0 81.1%
associate--l+81.1%
div-sub84.6%
Simplified84.6%
unpow284.6%
pow284.6%
difference-of-squares88.2%
Applied egg-rr88.2%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* 0.5 (/ x y)))))
(if (<= z 1.05e-244)
(* 0.5 y)
(if (<= z 8.8e-190)
t_0
(if (<= z 7.6e-136)
(* 0.5 y)
(if (<= z 1.7e-105)
t_0
(if (<= z 2.6e-46)
(* 0.5 y)
(if (<= z 0.000255)
t_0
(if (<= z 650000000.0)
(* 0.5 y)
(if (<= z 4.5e+55) t_0 (* z (* z (/ -0.5 y)))))))))))))
double code(double x, double y, double z) {
double t_0 = x * (0.5 * (x / y));
double tmp;
if (z <= 1.05e-244) {
tmp = 0.5 * y;
} else if (z <= 8.8e-190) {
tmp = t_0;
} else if (z <= 7.6e-136) {
tmp = 0.5 * y;
} else if (z <= 1.7e-105) {
tmp = t_0;
} else if (z <= 2.6e-46) {
tmp = 0.5 * y;
} else if (z <= 0.000255) {
tmp = t_0;
} else if (z <= 650000000.0) {
tmp = 0.5 * y;
} else if (z <= 4.5e+55) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (0.5d0 * (x / y))
if (z <= 1.05d-244) then
tmp = 0.5d0 * y
else if (z <= 8.8d-190) then
tmp = t_0
else if (z <= 7.6d-136) then
tmp = 0.5d0 * y
else if (z <= 1.7d-105) then
tmp = t_0
else if (z <= 2.6d-46) then
tmp = 0.5d0 * y
else if (z <= 0.000255d0) then
tmp = t_0
else if (z <= 650000000.0d0) then
tmp = 0.5d0 * y
else if (z <= 4.5d+55) then
tmp = t_0
else
tmp = z * (z * ((-0.5d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (0.5 * (x / y));
double tmp;
if (z <= 1.05e-244) {
tmp = 0.5 * y;
} else if (z <= 8.8e-190) {
tmp = t_0;
} else if (z <= 7.6e-136) {
tmp = 0.5 * y;
} else if (z <= 1.7e-105) {
tmp = t_0;
} else if (z <= 2.6e-46) {
tmp = 0.5 * y;
} else if (z <= 0.000255) {
tmp = t_0;
} else if (z <= 650000000.0) {
tmp = 0.5 * y;
} else if (z <= 4.5e+55) {
tmp = t_0;
} else {
tmp = z * (z * (-0.5 / y));
}
return tmp;
}
def code(x, y, z): t_0 = x * (0.5 * (x / y)) tmp = 0 if z <= 1.05e-244: tmp = 0.5 * y elif z <= 8.8e-190: tmp = t_0 elif z <= 7.6e-136: tmp = 0.5 * y elif z <= 1.7e-105: tmp = t_0 elif z <= 2.6e-46: tmp = 0.5 * y elif z <= 0.000255: tmp = t_0 elif z <= 650000000.0: tmp = 0.5 * y elif z <= 4.5e+55: tmp = t_0 else: tmp = z * (z * (-0.5 / y)) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(0.5 * Float64(x / y))) tmp = 0.0 if (z <= 1.05e-244) tmp = Float64(0.5 * y); elseif (z <= 8.8e-190) tmp = t_0; elseif (z <= 7.6e-136) tmp = Float64(0.5 * y); elseif (z <= 1.7e-105) tmp = t_0; elseif (z <= 2.6e-46) tmp = Float64(0.5 * y); elseif (z <= 0.000255) tmp = t_0; elseif (z <= 650000000.0) tmp = Float64(0.5 * y); elseif (z <= 4.5e+55) tmp = t_0; else tmp = Float64(z * Float64(z * Float64(-0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (0.5 * (x / y)); tmp = 0.0; if (z <= 1.05e-244) tmp = 0.5 * y; elseif (z <= 8.8e-190) tmp = t_0; elseif (z <= 7.6e-136) tmp = 0.5 * y; elseif (z <= 1.7e-105) tmp = t_0; elseif (z <= 2.6e-46) tmp = 0.5 * y; elseif (z <= 0.000255) tmp = t_0; elseif (z <= 650000000.0) tmp = 0.5 * y; elseif (z <= 4.5e+55) tmp = t_0; else tmp = z * (z * (-0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.05e-244], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 8.8e-190], t$95$0, If[LessEqual[z, 7.6e-136], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 1.7e-105], t$95$0, If[LessEqual[z, 2.6e-46], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 0.000255], t$95$0, If[LessEqual[z, 650000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 4.5e+55], t$95$0, N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(0.5 \cdot \frac{x}{y}\right)\\
\mathbf{if}\;z \leq 1.05 \cdot 10^{-244}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-136}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-46}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 0.000255:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 650000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\end{array}
\end{array}
if z < 1.05000000000000001e-244 or 8.80000000000000017e-190 < z < 7.6000000000000005e-136 or 1.69999999999999996e-105 < z < 2.6000000000000002e-46 or 2.55e-4 < z < 6.5e8Initial program 72.9%
Taylor expanded in y around inf 41.2%
*-commutative41.2%
Simplified41.2%
if 1.05000000000000001e-244 < z < 8.80000000000000017e-190 or 7.6000000000000005e-136 < z < 1.69999999999999996e-105 or 2.6000000000000002e-46 < z < 2.55e-4 or 6.5e8 < z < 4.49999999999999998e55Initial program 82.6%
clear-num82.5%
inv-pow82.5%
associate-/l*82.4%
add-sqr-sqrt82.4%
pow282.4%
hypot-define82.4%
pow282.4%
Applied egg-rr82.4%
Taylor expanded in x around inf 63.8%
associate-*r/63.8%
unpow263.8%
associate-/r*71.3%
Applied egg-rr71.3%
unpow-171.3%
clear-num71.3%
associate-/r/71.2%
*-un-lft-identity71.2%
*-commutative71.2%
times-frac71.2%
metadata-eval71.2%
Applied egg-rr71.2%
if 4.49999999999999998e55 < z Initial program 63.0%
Taylor expanded in z around inf 65.0%
associate-*r/65.0%
metadata-eval65.0%
distribute-lft-neg-in65.0%
*-commutative65.0%
distribute-neg-frac65.0%
associate-*r/65.0%
distribute-rgt-neg-in65.0%
distribute-neg-frac65.0%
metadata-eval65.0%
Simplified65.0%
add-cbrt-cube55.0%
pow355.0%
Applied egg-rr55.0%
rem-cbrt-cube65.0%
*-commutative65.0%
unpow265.0%
associate-*r*65.0%
Applied egg-rr65.0%
Final simplification49.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* 0.5 (/ x y)))))
(if (<= z 9.2e-245)
(* 0.5 y)
(if (<= z 8.8e-190)
(/ x (/ (* y -2.0) (- x)))
(if (<= z 7e-136)
(* 0.5 y)
(if (<= z 1.26e-105)
t_0
(if (<= z 2.2e-46)
(* 0.5 y)
(if (<= z 0.000365)
t_0
(if (<= z 620000000.0)
(* 0.5 y)
(if (<= z 6.5e+54) t_0 (* z (* z (/ -0.5 y)))))))))))))
double code(double x, double y, double z) {
double t_0 = x * (0.5 * (x / y));
double tmp;
if (z <= 9.2e-245) {
tmp = 0.5 * y;
} else if (z <= 8.8e-190) {
tmp = x / ((y * -2.0) / -x);
} else if (z <= 7e-136) {
tmp = 0.5 * y;
} else if (z <= 1.26e-105) {
tmp = t_0;
} else if (z <= 2.2e-46) {
tmp = 0.5 * y;
} else if (z <= 0.000365) {
tmp = t_0;
} else if (z <= 620000000.0) {
tmp = 0.5 * y;
} else if (z <= 6.5e+54) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (0.5d0 * (x / y))
if (z <= 9.2d-245) then
tmp = 0.5d0 * y
else if (z <= 8.8d-190) then
tmp = x / ((y * (-2.0d0)) / -x)
else if (z <= 7d-136) then
tmp = 0.5d0 * y
else if (z <= 1.26d-105) then
tmp = t_0
else if (z <= 2.2d-46) then
tmp = 0.5d0 * y
else if (z <= 0.000365d0) then
tmp = t_0
else if (z <= 620000000.0d0) then
tmp = 0.5d0 * y
else if (z <= 6.5d+54) then
tmp = t_0
else
tmp = z * (z * ((-0.5d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (0.5 * (x / y));
double tmp;
if (z <= 9.2e-245) {
tmp = 0.5 * y;
} else if (z <= 8.8e-190) {
tmp = x / ((y * -2.0) / -x);
} else if (z <= 7e-136) {
tmp = 0.5 * y;
} else if (z <= 1.26e-105) {
tmp = t_0;
} else if (z <= 2.2e-46) {
tmp = 0.5 * y;
} else if (z <= 0.000365) {
tmp = t_0;
} else if (z <= 620000000.0) {
tmp = 0.5 * y;
} else if (z <= 6.5e+54) {
tmp = t_0;
} else {
tmp = z * (z * (-0.5 / y));
}
return tmp;
}
def code(x, y, z): t_0 = x * (0.5 * (x / y)) tmp = 0 if z <= 9.2e-245: tmp = 0.5 * y elif z <= 8.8e-190: tmp = x / ((y * -2.0) / -x) elif z <= 7e-136: tmp = 0.5 * y elif z <= 1.26e-105: tmp = t_0 elif z <= 2.2e-46: tmp = 0.5 * y elif z <= 0.000365: tmp = t_0 elif z <= 620000000.0: tmp = 0.5 * y elif z <= 6.5e+54: tmp = t_0 else: tmp = z * (z * (-0.5 / y)) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(0.5 * Float64(x / y))) tmp = 0.0 if (z <= 9.2e-245) tmp = Float64(0.5 * y); elseif (z <= 8.8e-190) tmp = Float64(x / Float64(Float64(y * -2.0) / Float64(-x))); elseif (z <= 7e-136) tmp = Float64(0.5 * y); elseif (z <= 1.26e-105) tmp = t_0; elseif (z <= 2.2e-46) tmp = Float64(0.5 * y); elseif (z <= 0.000365) tmp = t_0; elseif (z <= 620000000.0) tmp = Float64(0.5 * y); elseif (z <= 6.5e+54) tmp = t_0; else tmp = Float64(z * Float64(z * Float64(-0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (0.5 * (x / y)); tmp = 0.0; if (z <= 9.2e-245) tmp = 0.5 * y; elseif (z <= 8.8e-190) tmp = x / ((y * -2.0) / -x); elseif (z <= 7e-136) tmp = 0.5 * y; elseif (z <= 1.26e-105) tmp = t_0; elseif (z <= 2.2e-46) tmp = 0.5 * y; elseif (z <= 0.000365) tmp = t_0; elseif (z <= 620000000.0) tmp = 0.5 * y; elseif (z <= 6.5e+54) tmp = t_0; else tmp = z * (z * (-0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 9.2e-245], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 8.8e-190], N[(x / N[(N[(y * -2.0), $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e-136], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 1.26e-105], t$95$0, If[LessEqual[z, 2.2e-46], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 0.000365], t$95$0, If[LessEqual[z, 620000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 6.5e+54], t$95$0, N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(0.5 \cdot \frac{x}{y}\right)\\
\mathbf{if}\;z \leq 9.2 \cdot 10^{-245}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-190}:\\
\;\;\;\;\frac{x}{\frac{y \cdot -2}{-x}}\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-136}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-46}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 0.000365:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 620000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\end{array}
\end{array}
if z < 9.2000000000000007e-245 or 8.80000000000000017e-190 < z < 7.00000000000000058e-136 or 1.2600000000000001e-105 < z < 2.2000000000000001e-46 or 3.6499999999999998e-4 < z < 6.2e8Initial program 72.9%
Taylor expanded in y around inf 41.2%
*-commutative41.2%
Simplified41.2%
if 9.2000000000000007e-245 < z < 8.80000000000000017e-190Initial program 74.6%
clear-num74.4%
inv-pow74.4%
associate-/l*74.4%
add-sqr-sqrt74.4%
pow274.4%
hypot-define74.4%
pow274.4%
Applied egg-rr74.4%
Taylor expanded in x around inf 64.3%
associate-*r/64.3%
unpow264.3%
associate-/r*73.2%
Applied egg-rr73.2%
unpow-173.2%
clear-num73.3%
frac-2neg73.3%
distribute-neg-frac73.3%
distribute-rgt-neg-in73.3%
metadata-eval73.3%
Applied egg-rr73.3%
if 7.00000000000000058e-136 < z < 1.2600000000000001e-105 or 2.2000000000000001e-46 < z < 3.6499999999999998e-4 or 6.2e8 < z < 6.5e54Initial program 86.0%
clear-num85.9%
inv-pow85.9%
associate-/l*85.7%
add-sqr-sqrt85.7%
pow285.7%
hypot-define85.7%
pow285.7%
Applied egg-rr85.7%
Taylor expanded in x around inf 63.6%
associate-*r/63.6%
unpow263.6%
associate-/r*70.5%
Applied egg-rr70.5%
unpow-170.5%
clear-num70.5%
associate-/r/70.4%
*-un-lft-identity70.4%
*-commutative70.4%
times-frac70.4%
metadata-eval70.4%
Applied egg-rr70.4%
if 6.5e54 < z Initial program 63.0%
Taylor expanded in z around inf 65.0%
associate-*r/65.0%
metadata-eval65.0%
distribute-lft-neg-in65.0%
*-commutative65.0%
distribute-neg-frac65.0%
associate-*r/65.0%
distribute-rgt-neg-in65.0%
distribute-neg-frac65.0%
metadata-eval65.0%
Simplified65.0%
add-cbrt-cube55.0%
pow355.0%
Applied egg-rr55.0%
rem-cbrt-cube65.0%
*-commutative65.0%
unpow265.0%
associate-*r*65.0%
Applied egg-rr65.0%
Final simplification49.0%
(FPCore (x y z) :precision binary64 (if (<= x 5e+134) (* 0.5 (+ y (* (- x z) (/ z y)))) (* x (* 0.5 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5e+134) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else {
tmp = x * (0.5 * (x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 5d+134) then
tmp = 0.5d0 * (y + ((x - z) * (z / y)))
else
tmp = x * (0.5d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 5e+134) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else {
tmp = x * (0.5 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 5e+134: tmp = 0.5 * (y + ((x - z) * (z / y))) else: tmp = x * (0.5 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 5e+134) tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(z / y)))); else tmp = Float64(x * Float64(0.5 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5e+134) tmp = 0.5 * (y + ((x - z) * (z / y))); else tmp = x * (0.5 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 5e+134], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+134}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if x < 4.99999999999999981e134Initial program 74.3%
remove-double-neg74.3%
distribute-lft-neg-out74.3%
distribute-frac-neg274.3%
distribute-frac-neg74.3%
neg-mul-174.3%
distribute-lft-neg-out74.3%
*-commutative74.3%
distribute-lft-neg-in74.3%
times-frac74.3%
metadata-eval74.3%
metadata-eval74.3%
associate--l+74.3%
fma-define75.7%
Simplified75.7%
Taylor expanded in x around 0 84.3%
associate--l+84.3%
div-sub87.5%
Simplified87.5%
unpow287.5%
pow287.5%
difference-of-squares89.7%
Applied egg-rr89.7%
div-inv89.7%
*-commutative89.7%
associate-*l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 73.7%
if 4.99999999999999981e134 < x Initial program 63.2%
clear-num63.2%
inv-pow63.2%
associate-/l*63.3%
add-sqr-sqrt63.3%
pow263.3%
hypot-define63.3%
pow263.3%
Applied egg-rr63.3%
Taylor expanded in x around inf 63.7%
associate-*r/63.6%
unpow263.6%
associate-/r*71.8%
Applied egg-rr71.8%
unpow-171.8%
clear-num71.8%
associate-/r/71.8%
*-un-lft-identity71.8%
*-commutative71.8%
times-frac71.8%
metadata-eval71.8%
Applied egg-rr71.8%
Final simplification73.4%
(FPCore (x y z) :precision binary64 (if (<= z 4.6e+50) (* 0.5 (+ y (* (+ x z) (/ x y)))) (* 0.5 (+ y (* (- x z) (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 4.6e+50) {
tmp = 0.5 * (y + ((x + z) * (x / 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 (z <= 4.6d+50) then
tmp = 0.5d0 * (y + ((x + z) * (x / 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 (z <= 4.6e+50) {
tmp = 0.5 * (y + ((x + z) * (x / y)));
} else {
tmp = 0.5 * (y + ((x - z) * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 4.6e+50: tmp = 0.5 * (y + ((x + z) * (x / y))) else: tmp = 0.5 * (y + ((x - z) * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 4.6e+50) tmp = Float64(0.5 * Float64(y + Float64(Float64(x + z) * Float64(x / 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 (z <= 4.6e+50) tmp = 0.5 * (y + ((x + z) * (x / y))); else tmp = 0.5 * (y + ((x - z) * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 4.6e+50], N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $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}\;z \leq 4.6 \cdot 10^{+50}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x + z\right) \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < 4.59999999999999994e50Initial program 74.4%
remove-double-neg74.4%
distribute-lft-neg-out74.4%
distribute-frac-neg274.4%
distribute-frac-neg74.4%
neg-mul-174.4%
distribute-lft-neg-out74.4%
*-commutative74.4%
distribute-lft-neg-in74.4%
times-frac74.4%
metadata-eval74.4%
metadata-eval74.4%
associate--l+74.4%
fma-define75.8%
Simplified75.8%
Taylor expanded in x around 0 84.1%
associate--l+84.1%
div-sub87.3%
Simplified87.3%
unpow287.3%
pow287.3%
difference-of-squares89.6%
Applied egg-rr89.6%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 79.9%
if 4.59999999999999994e50 < z Initial program 64.0%
remove-double-neg64.0%
distribute-lft-neg-out64.0%
distribute-frac-neg264.0%
distribute-frac-neg64.0%
neg-mul-164.0%
distribute-lft-neg-out64.0%
*-commutative64.0%
distribute-lft-neg-in64.0%
times-frac64.0%
metadata-eval64.0%
metadata-eval64.0%
associate--l+64.0%
fma-define69.2%
Simplified69.2%
Taylor expanded in x around 0 63.9%
associate--l+63.9%
div-sub69.1%
Simplified69.1%
unpow269.1%
pow269.1%
difference-of-squares79.9%
Applied egg-rr79.9%
div-inv79.8%
*-commutative79.8%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 94.7%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (<= y 1200000000000.0) (* x (* 0.5 (/ x y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1200000000000.0) {
tmp = x * (0.5 * (x / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1200000000000.0d0) then
tmp = x * (0.5d0 * (x / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1200000000000.0) {
tmp = x * (0.5 * (x / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1200000000000.0: tmp = x * (0.5 * (x / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1200000000000.0) tmp = Float64(x * Float64(0.5 * Float64(x / y))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1200000000000.0) tmp = x * (0.5 * (x / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1200000000000.0], N[(x * N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1200000000000:\\
\;\;\;\;x \cdot \left(0.5 \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.2e12Initial program 78.6%
clear-num78.5%
inv-pow78.5%
associate-/l*78.5%
add-sqr-sqrt78.5%
pow278.5%
hypot-define78.5%
pow278.5%
Applied egg-rr78.5%
Taylor expanded in x around inf 35.9%
associate-*r/35.9%
unpow235.9%
associate-/r*40.2%
Applied egg-rr40.2%
unpow-140.2%
clear-num40.2%
associate-/r/40.2%
*-un-lft-identity40.2%
*-commutative40.2%
times-frac40.2%
metadata-eval40.2%
Applied egg-rr40.2%
if 1.2e12 < y Initial program 54.1%
Taylor expanded in y around inf 62.7%
*-commutative62.7%
Simplified62.7%
Final simplification45.5%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 72.9%
Taylor expanded in y around inf 36.5%
*-commutative36.5%
Simplified36.5%
Final simplification36.5%
(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 2024053
(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)))