
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+173) (not (<= y 3.5e+162))) (* (/ (+ z y) (* y 2.0)) (- y z)) (/ (fma (+ z y) (- y z) (* x x)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+173) || !(y <= 3.5e+162)) {
tmp = ((z + y) / (y * 2.0)) * (y - z);
} else {
tmp = fma((z + y), (y - z), (x * x)) / (y * 2.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+173) || !(y <= 3.5e+162)) tmp = Float64(Float64(Float64(z + y) / Float64(y * 2.0)) * Float64(y - z)); else tmp = Float64(fma(Float64(z + y), Float64(y - z), Float64(x * x)) / Float64(y * 2.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+173], N[Not[LessEqual[y, 3.5e+162]], $MachinePrecision]], N[(N[(N[(z + y), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z + y), $MachinePrecision] * N[(y - z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+173} \lor \neg \left(y \leq 3.5 \cdot 10^{+162}\right):\\
\;\;\;\;\frac{z + y}{y \cdot 2} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z + y, y - z, x \cdot x\right)}{y \cdot 2}\\
\end{array}
\end{array}
if y < -4.2e173 or 3.50000000000000018e162 < y Initial program 5.2%
associate--l+5.2%
+-commutative5.2%
sqr-neg5.2%
difference-of-squares12.3%
sub-neg12.3%
remove-double-neg12.3%
*-commutative12.3%
fma-def12.4%
sub-neg12.4%
Simplified12.4%
Taylor expanded in x around 0 12.3%
associate-/l*93.3%
associate-/r/93.4%
Applied egg-rr93.4%
if -4.2e173 < y < 3.50000000000000018e162Initial program 87.2%
associate--l+87.2%
+-commutative87.2%
sqr-neg87.2%
difference-of-squares87.7%
sub-neg87.7%
remove-double-neg87.7%
*-commutative87.7%
fma-def89.8%
sub-neg89.8%
Simplified89.8%
Final simplification90.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (hypot (hypot x y) z)))
(if (<= (* z z) 2e+129)
(* t_0 (* (/ 0.5 y) t_0))
(* (/ (+ z y) (* y 2.0)) (- y z)))))
double code(double x, double y, double z) {
double t_0 = hypot(hypot(x, y), z);
double tmp;
if ((z * z) <= 2e+129) {
tmp = t_0 * ((0.5 / y) * t_0);
} else {
tmp = ((z + y) / (y * 2.0)) * (y - z);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.hypot(Math.hypot(x, y), z);
double tmp;
if ((z * z) <= 2e+129) {
tmp = t_0 * ((0.5 / y) * t_0);
} else {
tmp = ((z + y) / (y * 2.0)) * (y - z);
}
return tmp;
}
def code(x, y, z): t_0 = math.hypot(math.hypot(x, y), z) tmp = 0 if (z * z) <= 2e+129: tmp = t_0 * ((0.5 / y) * t_0) else: tmp = ((z + y) / (y * 2.0)) * (y - z) return tmp
function code(x, y, z) t_0 = hypot(hypot(x, y), z) tmp = 0.0 if (Float64(z * z) <= 2e+129) tmp = Float64(t_0 * Float64(Float64(0.5 / y) * t_0)); else tmp = Float64(Float64(Float64(z + y) / Float64(y * 2.0)) * Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = hypot(hypot(x, y), z); tmp = 0.0; if ((z * z) <= 2e+129) tmp = t_0 * ((0.5 / y) * t_0); else tmp = ((z + y) / (y * 2.0)) * (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 2e+129], N[(t$95$0 * N[(N[(0.5 / y), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z + y), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)\\
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+129}:\\
\;\;\;\;t_0 \cdot \left(\frac{0.5}{y} \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z + y}{y \cdot 2} \cdot \left(y - z\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2e129Initial program 77.2%
div-inv77.1%
*-commutative77.1%
*-commutative77.1%
associate-/r*77.1%
metadata-eval77.1%
add-sqr-sqrt77.1%
pow277.1%
hypot-def77.1%
pow277.1%
Applied egg-rr77.1%
clear-num77.1%
metadata-eval77.1%
associate-*l/77.2%
div-inv77.2%
metadata-eval77.2%
associate-/l*77.1%
div-inv77.1%
associate-/r*77.1%
metadata-eval77.1%
metadata-eval77.1%
div-inv77.1%
clear-num77.1%
Applied egg-rr77.1%
associate-/r/77.1%
add-sqr-sqrt70.0%
associate-*r*70.1%
Applied egg-rr92.1%
if 2e129 < (*.f64 z z) Initial program 56.3%
associate--l+56.3%
+-commutative56.3%
sqr-neg56.3%
difference-of-squares61.3%
sub-neg61.3%
remove-double-neg61.3%
*-commutative61.3%
fma-def65.5%
sub-neg65.5%
Simplified65.5%
Taylor expanded in x around 0 63.4%
associate-/l*85.2%
associate-/r/85.3%
Applied egg-rr85.3%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.65e+36) (not (<= y 3.5e+162))) (* (/ (+ z y) (* y 2.0)) (- y z)) (/ (- (fma x x (* y y)) (* z z)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.65e+36) || !(y <= 3.5e+162)) {
tmp = ((z + y) / (y * 2.0)) * (y - z);
} else {
tmp = (fma(x, x, (y * y)) - (z * z)) / (y * 2.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -2.65e+36) || !(y <= 3.5e+162)) tmp = Float64(Float64(Float64(z + y) / Float64(y * 2.0)) * Float64(y - z)); else tmp = Float64(Float64(fma(x, x, Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.65e+36], N[Not[LessEqual[y, 3.5e+162]], $MachinePrecision]], N[(N[(N[(z + y), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{+36} \lor \neg \left(y \leq 3.5 \cdot 10^{+162}\right):\\
\;\;\;\;\frac{z + y}{y \cdot 2} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\end{array}
\end{array}
if y < -2.65e36 or 3.50000000000000018e162 < y Initial program 30.9%
associate--l+30.9%
+-commutative30.9%
sqr-neg30.9%
difference-of-squares36.6%
sub-neg36.6%
remove-double-neg36.6%
*-commutative36.6%
fma-def37.9%
sub-neg37.9%
Simplified37.9%
Taylor expanded in x around 0 35.5%
associate-/l*88.0%
associate-/r/88.0%
Applied egg-rr88.0%
if -2.65e36 < y < 3.50000000000000018e162Initial program 88.9%
div-sub82.4%
sqr-neg82.4%
div-sub88.9%
fma-def88.9%
sqr-neg88.9%
Simplified88.9%
Final simplification88.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- y z) (* (/ 0.5 y) (+ z y)))) (t_1 (* x (* (/ 0.5 y) x))))
(if (<= x 1.85e+57)
t_0
(if (<= x 3.7e+86)
(/ (* x (* 0.5 x)) y)
(if (<= x 6.8e+111)
t_0
(if (<= x 9e+119)
t_1
(if (<= x 5.3e+129)
t_0
(if (<= x 5.5e+182)
t_1
(if (<= x 1.05e+195) t_0 (/ x (* 2.0 (/ y x))))))))))))
double code(double x, double y, double z) {
double t_0 = (y - z) * ((0.5 / y) * (z + y));
double t_1 = x * ((0.5 / y) * x);
double tmp;
if (x <= 1.85e+57) {
tmp = t_0;
} else if (x <= 3.7e+86) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 6.8e+111) {
tmp = t_0;
} else if (x <= 9e+119) {
tmp = t_1;
} else if (x <= 5.3e+129) {
tmp = t_0;
} else if (x <= 5.5e+182) {
tmp = t_1;
} else if (x <= 1.05e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (y - z) * ((0.5d0 / y) * (z + y))
t_1 = x * ((0.5d0 / y) * x)
if (x <= 1.85d+57) then
tmp = t_0
else if (x <= 3.7d+86) then
tmp = (x * (0.5d0 * x)) / y
else if (x <= 6.8d+111) then
tmp = t_0
else if (x <= 9d+119) then
tmp = t_1
else if (x <= 5.3d+129) then
tmp = t_0
else if (x <= 5.5d+182) then
tmp = t_1
else if (x <= 1.05d+195) then
tmp = t_0
else
tmp = x / (2.0d0 * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) * ((0.5 / y) * (z + y));
double t_1 = x * ((0.5 / y) * x);
double tmp;
if (x <= 1.85e+57) {
tmp = t_0;
} else if (x <= 3.7e+86) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 6.8e+111) {
tmp = t_0;
} else if (x <= 9e+119) {
tmp = t_1;
} else if (x <= 5.3e+129) {
tmp = t_0;
} else if (x <= 5.5e+182) {
tmp = t_1;
} else if (x <= 1.05e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) * ((0.5 / y) * (z + y)) t_1 = x * ((0.5 / y) * x) tmp = 0 if x <= 1.85e+57: tmp = t_0 elif x <= 3.7e+86: tmp = (x * (0.5 * x)) / y elif x <= 6.8e+111: tmp = t_0 elif x <= 9e+119: tmp = t_1 elif x <= 5.3e+129: tmp = t_0 elif x <= 5.5e+182: tmp = t_1 elif x <= 1.05e+195: tmp = t_0 else: tmp = x / (2.0 * (y / x)) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) * Float64(Float64(0.5 / y) * Float64(z + y))) t_1 = Float64(x * Float64(Float64(0.5 / y) * x)) tmp = 0.0 if (x <= 1.85e+57) tmp = t_0; elseif (x <= 3.7e+86) tmp = Float64(Float64(x * Float64(0.5 * x)) / y); elseif (x <= 6.8e+111) tmp = t_0; elseif (x <= 9e+119) tmp = t_1; elseif (x <= 5.3e+129) tmp = t_0; elseif (x <= 5.5e+182) tmp = t_1; elseif (x <= 1.05e+195) tmp = t_0; else tmp = Float64(x / Float64(2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) * ((0.5 / y) * (z + y)); t_1 = x * ((0.5 / y) * x); tmp = 0.0; if (x <= 1.85e+57) tmp = t_0; elseif (x <= 3.7e+86) tmp = (x * (0.5 * x)) / y; elseif (x <= 6.8e+111) tmp = t_0; elseif (x <= 9e+119) tmp = t_1; elseif (x <= 5.3e+129) tmp = t_0; elseif (x <= 5.5e+182) tmp = t_1; elseif (x <= 1.05e+195) tmp = t_0; else tmp = x / (2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] * N[(N[(0.5 / y), $MachinePrecision] * N[(z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(N[(0.5 / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.85e+57], t$95$0, If[LessEqual[x, 3.7e+86], N[(N[(x * N[(0.5 * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 6.8e+111], t$95$0, If[LessEqual[x, 9e+119], t$95$1, If[LessEqual[x, 5.3e+129], t$95$0, If[LessEqual[x, 5.5e+182], t$95$1, If[LessEqual[x, 1.05e+195], t$95$0, N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) \cdot \left(\frac{0.5}{y} \cdot \left(z + y\right)\right)\\
t_1 := x \cdot \left(\frac{0.5}{y} \cdot x\right)\\
\mathbf{if}\;x \leq 1.85 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+86}:\\
\;\;\;\;\frac{x \cdot \left(0.5 \cdot x\right)}{y}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+111}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+182}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+195}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < 1.85000000000000003e57 or 3.69999999999999992e86 < x < 6.8000000000000003e111 or 9.00000000000000039e119 < x < 5.2999999999999999e129 or 5.49999999999999977e182 < x < 1.05000000000000005e195Initial program 69.6%
associate--l+69.6%
+-commutative69.6%
sqr-neg69.6%
difference-of-squares71.9%
sub-neg71.9%
remove-double-neg71.9%
*-commutative71.9%
fma-def72.9%
sub-neg72.9%
Simplified72.9%
Taylor expanded in x around 0 54.1%
div-inv54.0%
*-commutative54.0%
associate-*l*76.0%
metadata-eval76.0%
div-inv76.0%
clear-num76.0%
Applied egg-rr76.0%
if 1.85000000000000003e57 < x < 3.69999999999999992e86Initial program 100.0%
Taylor expanded in x around inf 75.0%
div-inv75.0%
unpow275.0%
associate-*l*75.0%
metadata-eval75.0%
div-inv75.0%
clear-num75.0%
Applied egg-rr75.0%
*-commutative75.0%
associate-*r/75.0%
associate-*l/75.0%
*-commutative75.0%
Applied egg-rr75.0%
if 6.8000000000000003e111 < x < 9.00000000000000039e119 or 5.2999999999999999e129 < x < 5.49999999999999977e182Initial program 68.7%
Taylor expanded in x around inf 61.5%
div-inv61.5%
unpow261.5%
associate-*l*67.9%
metadata-eval67.9%
div-inv67.9%
clear-num67.9%
Applied egg-rr67.9%
if 1.05000000000000005e195 < x Initial program 59.3%
Taylor expanded in x around inf 67.5%
div-inv67.5%
unpow267.5%
associate-*l*84.6%
metadata-eval84.6%
div-inv84.6%
clear-num84.6%
Applied egg-rr84.6%
div-inv84.6%
associate-*r*84.6%
*-commutative84.6%
associate-/r/84.7%
div-inv84.8%
*-un-lft-identity84.8%
*-commutative84.8%
times-frac84.8%
metadata-eval84.8%
Applied egg-rr84.8%
Final simplification76.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ z y) (* y 2.0)) (- y z)))
(t_1 (* (- y z) (* (/ 0.5 y) (+ z y))))
(t_2 (* x (* (/ 0.5 y) x))))
(if (<= x 1.95e+57)
t_0
(if (<= x 1.9e+86)
(/ (* x (* 0.5 x)) y)
(if (<= x 4.5e+111)
t_1
(if (<= x 2.8e+119)
t_2
(if (<= x 4.4e+130)
t_1
(if (<= x 2.35e+182)
t_2
(if (<= x 1e+195) t_0 (/ x (* 2.0 (/ y x))))))))))))
double code(double x, double y, double z) {
double t_0 = ((z + y) / (y * 2.0)) * (y - z);
double t_1 = (y - z) * ((0.5 / y) * (z + y));
double t_2 = x * ((0.5 / y) * x);
double tmp;
if (x <= 1.95e+57) {
tmp = t_0;
} else if (x <= 1.9e+86) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 4.5e+111) {
tmp = t_1;
} else if (x <= 2.8e+119) {
tmp = t_2;
} else if (x <= 4.4e+130) {
tmp = t_1;
} else if (x <= 2.35e+182) {
tmp = t_2;
} else if (x <= 1e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((z + y) / (y * 2.0d0)) * (y - z)
t_1 = (y - z) * ((0.5d0 / y) * (z + y))
t_2 = x * ((0.5d0 / y) * x)
if (x <= 1.95d+57) then
tmp = t_0
else if (x <= 1.9d+86) then
tmp = (x * (0.5d0 * x)) / y
else if (x <= 4.5d+111) then
tmp = t_1
else if (x <= 2.8d+119) then
tmp = t_2
else if (x <= 4.4d+130) then
tmp = t_1
else if (x <= 2.35d+182) then
tmp = t_2
else if (x <= 1d+195) then
tmp = t_0
else
tmp = x / (2.0d0 * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((z + y) / (y * 2.0)) * (y - z);
double t_1 = (y - z) * ((0.5 / y) * (z + y));
double t_2 = x * ((0.5 / y) * x);
double tmp;
if (x <= 1.95e+57) {
tmp = t_0;
} else if (x <= 1.9e+86) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 4.5e+111) {
tmp = t_1;
} else if (x <= 2.8e+119) {
tmp = t_2;
} else if (x <= 4.4e+130) {
tmp = t_1;
} else if (x <= 2.35e+182) {
tmp = t_2;
} else if (x <= 1e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
def code(x, y, z): t_0 = ((z + y) / (y * 2.0)) * (y - z) t_1 = (y - z) * ((0.5 / y) * (z + y)) t_2 = x * ((0.5 / y) * x) tmp = 0 if x <= 1.95e+57: tmp = t_0 elif x <= 1.9e+86: tmp = (x * (0.5 * x)) / y elif x <= 4.5e+111: tmp = t_1 elif x <= 2.8e+119: tmp = t_2 elif x <= 4.4e+130: tmp = t_1 elif x <= 2.35e+182: tmp = t_2 elif x <= 1e+195: tmp = t_0 else: tmp = x / (2.0 * (y / x)) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(z + y) / Float64(y * 2.0)) * Float64(y - z)) t_1 = Float64(Float64(y - z) * Float64(Float64(0.5 / y) * Float64(z + y))) t_2 = Float64(x * Float64(Float64(0.5 / y) * x)) tmp = 0.0 if (x <= 1.95e+57) tmp = t_0; elseif (x <= 1.9e+86) tmp = Float64(Float64(x * Float64(0.5 * x)) / y); elseif (x <= 4.5e+111) tmp = t_1; elseif (x <= 2.8e+119) tmp = t_2; elseif (x <= 4.4e+130) tmp = t_1; elseif (x <= 2.35e+182) tmp = t_2; elseif (x <= 1e+195) tmp = t_0; else tmp = Float64(x / Float64(2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((z + y) / (y * 2.0)) * (y - z); t_1 = (y - z) * ((0.5 / y) * (z + y)); t_2 = x * ((0.5 / y) * x); tmp = 0.0; if (x <= 1.95e+57) tmp = t_0; elseif (x <= 1.9e+86) tmp = (x * (0.5 * x)) / y; elseif (x <= 4.5e+111) tmp = t_1; elseif (x <= 2.8e+119) tmp = t_2; elseif (x <= 4.4e+130) tmp = t_1; elseif (x <= 2.35e+182) tmp = t_2; elseif (x <= 1e+195) tmp = t_0; else tmp = x / (2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(z + y), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(N[(0.5 / y), $MachinePrecision] * N[(z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(0.5 / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.95e+57], t$95$0, If[LessEqual[x, 1.9e+86], N[(N[(x * N[(0.5 * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 4.5e+111], t$95$1, If[LessEqual[x, 2.8e+119], t$95$2, If[LessEqual[x, 4.4e+130], t$95$1, If[LessEqual[x, 2.35e+182], t$95$2, If[LessEqual[x, 1e+195], t$95$0, N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z + y}{y \cdot 2} \cdot \left(y - z\right)\\
t_1 := \left(y - z\right) \cdot \left(\frac{0.5}{y} \cdot \left(z + y\right)\right)\\
t_2 := x \cdot \left(\frac{0.5}{y} \cdot x\right)\\
\mathbf{if}\;x \leq 1.95 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+86}:\\
\;\;\;\;\frac{x \cdot \left(0.5 \cdot x\right)}{y}\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+111}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+119}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+130}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+182}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 10^{+195}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < 1.94999999999999984e57 or 2.34999999999999992e182 < x < 9.99999999999999977e194Initial program 69.9%
associate--l+69.9%
+-commutative69.9%
sqr-neg69.9%
difference-of-squares71.7%
sub-neg71.7%
remove-double-neg71.7%
*-commutative71.7%
fma-def72.8%
sub-neg72.8%
Simplified72.8%
Taylor expanded in x around 0 53.7%
associate-/l*75.6%
associate-/r/75.6%
Applied egg-rr75.6%
if 1.94999999999999984e57 < x < 1.89999999999999989e86Initial program 100.0%
Taylor expanded in x around inf 75.0%
div-inv75.0%
unpow275.0%
associate-*l*75.0%
metadata-eval75.0%
div-inv75.0%
clear-num75.0%
Applied egg-rr75.0%
*-commutative75.0%
associate-*r/75.0%
associate-*l/75.0%
*-commutative75.0%
Applied egg-rr75.0%
if 1.89999999999999989e86 < x < 4.50000000000000001e111 or 2.80000000000000013e119 < x < 4.39999999999999987e130Initial program 62.5%
associate--l+62.5%
+-commutative62.5%
sqr-neg62.5%
difference-of-squares77.4%
sub-neg77.4%
remove-double-neg77.4%
*-commutative77.4%
fma-def77.4%
sub-neg77.4%
Simplified77.4%
Taylor expanded in x around 0 65.2%
div-inv65.2%
*-commutative65.2%
associate-*l*87.8%
metadata-eval87.8%
div-inv87.8%
clear-num87.8%
Applied egg-rr87.8%
if 4.50000000000000001e111 < x < 2.80000000000000013e119 or 4.39999999999999987e130 < x < 2.34999999999999992e182Initial program 68.7%
Taylor expanded in x around inf 61.5%
div-inv61.5%
unpow261.5%
associate-*l*67.9%
metadata-eval67.9%
div-inv67.9%
clear-num67.9%
Applied egg-rr67.9%
if 9.99999999999999977e194 < x Initial program 59.3%
Taylor expanded in x around inf 67.5%
div-inv67.5%
unpow267.5%
associate-*l*84.6%
metadata-eval84.6%
div-inv84.6%
clear-num84.6%
Applied egg-rr84.6%
div-inv84.6%
associate-*r*84.6%
*-commutative84.6%
associate-/r/84.7%
div-inv84.8%
*-un-lft-identity84.8%
*-commutative84.8%
times-frac84.8%
metadata-eval84.8%
Applied egg-rr84.8%
Final simplification76.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.22e+36) (not (<= y 3.5e+162))) (* (/ (+ z y) (* y 2.0)) (- y z)) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.22e+36) || !(y <= 3.5e+162)) {
tmp = ((z + y) / (y * 2.0)) * (y - z);
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 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 ((y <= (-2.22d+36)) .or. (.not. (y <= 3.5d+162))) then
tmp = ((z + y) / (y * 2.0d0)) * (y - z)
else
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.22e+36) || !(y <= 3.5e+162)) {
tmp = ((z + y) / (y * 2.0)) * (y - z);
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.22e+36) or not (y <= 3.5e+162): tmp = ((z + y) / (y * 2.0)) * (y - z) else: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.22e+36) || !(y <= 3.5e+162)) tmp = Float64(Float64(Float64(z + y) / Float64(y * 2.0)) * Float64(y - z)); else tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.22e+36) || ~((y <= 3.5e+162))) tmp = ((z + y) / (y * 2.0)) * (y - z); else tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.22e+36], N[Not[LessEqual[y, 3.5e+162]], $MachinePrecision]], N[(N[(N[(z + y), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.22 \cdot 10^{+36} \lor \neg \left(y \leq 3.5 \cdot 10^{+162}\right):\\
\;\;\;\;\frac{z + y}{y \cdot 2} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\end{array}
\end{array}
if y < -2.22e36 or 3.50000000000000018e162 < y Initial program 30.9%
associate--l+30.9%
+-commutative30.9%
sqr-neg30.9%
difference-of-squares36.6%
sub-neg36.6%
remove-double-neg36.6%
*-commutative36.6%
fma-def37.9%
sub-neg37.9%
Simplified37.9%
Taylor expanded in x around 0 35.5%
associate-/l*88.0%
associate-/r/88.0%
Applied egg-rr88.0%
if -2.22e36 < y < 3.50000000000000018e162Initial program 88.9%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (or (<= x 1.6e+19) (and (not (<= x 5.5e+182)) (<= x 1e+195))) (* 0.5 y) (* x (* (/ 0.5 y) x))))
double code(double x, double y, double z) {
double tmp;
if ((x <= 1.6e+19) || (!(x <= 5.5e+182) && (x <= 1e+195))) {
tmp = 0.5 * y;
} else {
tmp = x * ((0.5 / y) * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= 1.6d+19) .or. (.not. (x <= 5.5d+182)) .and. (x <= 1d+195)) then
tmp = 0.5d0 * y
else
tmp = x * ((0.5d0 / y) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= 1.6e+19) || (!(x <= 5.5e+182) && (x <= 1e+195))) {
tmp = 0.5 * y;
} else {
tmp = x * ((0.5 / y) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= 1.6e+19) or (not (x <= 5.5e+182) and (x <= 1e+195)): tmp = 0.5 * y else: tmp = x * ((0.5 / y) * x) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= 1.6e+19) || (!(x <= 5.5e+182) && (x <= 1e+195))) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(Float64(0.5 / y) * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= 1.6e+19) || (~((x <= 5.5e+182)) && (x <= 1e+195))) tmp = 0.5 * y; else tmp = x * ((0.5 / y) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, 1.6e+19], And[N[Not[LessEqual[x, 5.5e+182]], $MachinePrecision], LessEqual[x, 1e+195]]], N[(0.5 * y), $MachinePrecision], N[(x * N[(N[(0.5 / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+19} \lor \neg \left(x \leq 5.5 \cdot 10^{+182}\right) \land x \leq 10^{+195}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{0.5}{y} \cdot x\right)\\
\end{array}
\end{array}
if x < 1.6e19 or 5.49999999999999977e182 < x < 9.99999999999999977e194Initial program 68.8%
Taylor expanded in y around inf 41.3%
if 1.6e19 < x < 5.49999999999999977e182 or 9.99999999999999977e194 < x Initial program 69.4%
Taylor expanded in x around inf 56.7%
div-inv56.7%
unpow256.7%
associate-*l*65.7%
metadata-eval65.7%
div-inv65.7%
clear-num65.7%
Applied egg-rr65.7%
Final simplification47.0%
(FPCore (x y z)
:precision binary64
(if (<= x 8.4e+18)
(* 0.5 y)
(if (<= x 5.5e+182)
(* x (* (/ 0.5 y) x))
(if (<= x 1e+195) (* 0.5 y) (* x (/ 0.5 (/ y x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 8.4e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = x * ((0.5 / y) * x);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x * (0.5 / (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 8.4d+18) then
tmp = 0.5d0 * y
else if (x <= 5.5d+182) then
tmp = x * ((0.5d0 / y) * x)
else if (x <= 1d+195) then
tmp = 0.5d0 * y
else
tmp = x * (0.5d0 / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 8.4e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = x * ((0.5 / y) * x);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x * (0.5 / (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 8.4e+18: tmp = 0.5 * y elif x <= 5.5e+182: tmp = x * ((0.5 / y) * x) elif x <= 1e+195: tmp = 0.5 * y else: tmp = x * (0.5 / (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 8.4e+18) tmp = Float64(0.5 * y); elseif (x <= 5.5e+182) tmp = Float64(x * Float64(Float64(0.5 / y) * x)); elseif (x <= 1e+195) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(0.5 / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 8.4e+18) tmp = 0.5 * y; elseif (x <= 5.5e+182) tmp = x * ((0.5 / y) * x); elseif (x <= 1e+195) tmp = 0.5 * y; else tmp = x * (0.5 / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 8.4e+18], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 5.5e+182], N[(x * N[(N[(0.5 / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+195], N[(0.5 * y), $MachinePrecision], N[(x * N[(0.5 / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.4 \cdot 10^{+18}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+182}:\\
\;\;\;\;x \cdot \left(\frac{0.5}{y} \cdot x\right)\\
\mathbf{elif}\;x \leq 10^{+195}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{0.5}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < 8.4e18 or 5.49999999999999977e182 < x < 9.99999999999999977e194Initial program 68.8%
Taylor expanded in y around inf 41.3%
if 8.4e18 < x < 5.49999999999999977e182Initial program 77.2%
Taylor expanded in x around inf 48.4%
div-inv48.5%
unpow248.5%
associate-*l*51.2%
metadata-eval51.2%
div-inv51.2%
clear-num51.2%
Applied egg-rr51.2%
if 9.99999999999999977e194 < x Initial program 59.3%
Taylor expanded in x around inf 67.5%
div-inv67.5%
unpow267.5%
associate-*l*84.6%
metadata-eval84.6%
div-inv84.6%
clear-num84.6%
Applied egg-rr84.6%
associate-*r/84.7%
*-commutative84.7%
associate-/l*84.7%
Applied egg-rr84.7%
Final simplification47.1%
(FPCore (x y z)
:precision binary64
(if (<= x 9.1e+18)
(* 0.5 y)
(if (<= x 5.5e+182)
(* (/ x y) (/ x 2.0))
(if (<= x 1e+195) (* 0.5 y) (* x (/ 0.5 (/ y x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 9.1e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = (x / y) * (x / 2.0);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x * (0.5 / (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 9.1d+18) then
tmp = 0.5d0 * y
else if (x <= 5.5d+182) then
tmp = (x / y) * (x / 2.0d0)
else if (x <= 1d+195) then
tmp = 0.5d0 * y
else
tmp = x * (0.5d0 / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 9.1e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = (x / y) * (x / 2.0);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x * (0.5 / (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 9.1e+18: tmp = 0.5 * y elif x <= 5.5e+182: tmp = (x / y) * (x / 2.0) elif x <= 1e+195: tmp = 0.5 * y else: tmp = x * (0.5 / (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 9.1e+18) tmp = Float64(0.5 * y); elseif (x <= 5.5e+182) tmp = Float64(Float64(x / y) * Float64(x / 2.0)); elseif (x <= 1e+195) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(0.5 / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 9.1e+18) tmp = 0.5 * y; elseif (x <= 5.5e+182) tmp = (x / y) * (x / 2.0); elseif (x <= 1e+195) tmp = 0.5 * y; else tmp = x * (0.5 / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 9.1e+18], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 5.5e+182], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+195], N[(0.5 * y), $MachinePrecision], N[(x * N[(0.5 / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.1 \cdot 10^{+18}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+182}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\mathbf{elif}\;x \leq 10^{+195}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{0.5}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < 9.1e18 or 5.49999999999999977e182 < x < 9.99999999999999977e194Initial program 68.8%
Taylor expanded in y around inf 41.3%
if 9.1e18 < x < 5.49999999999999977e182Initial program 77.2%
Taylor expanded in x around inf 48.4%
unpow248.4%
times-frac51.3%
Applied egg-rr51.3%
if 9.99999999999999977e194 < x Initial program 59.3%
Taylor expanded in x around inf 67.5%
div-inv67.5%
unpow267.5%
associate-*l*84.6%
metadata-eval84.6%
div-inv84.6%
clear-num84.6%
Applied egg-rr84.6%
associate-*r/84.7%
*-commutative84.7%
associate-/l*84.7%
Applied egg-rr84.7%
Final simplification47.1%
(FPCore (x y z)
:precision binary64
(if (<= x 3.5e+18)
(* 0.5 y)
(if (<= x 5.5e+182)
(* (/ x y) (/ x 2.0))
(if (<= x 1e+195) (* 0.5 y) (/ x (* 2.0 (/ y x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = (x / y) * (x / 2.0);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 3.5d+18) then
tmp = 0.5d0 * y
else if (x <= 5.5d+182) then
tmp = (x / y) * (x / 2.0d0)
else if (x <= 1d+195) then
tmp = 0.5d0 * y
else
tmp = x / (2.0d0 * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e+18) {
tmp = 0.5 * y;
} else if (x <= 5.5e+182) {
tmp = (x / y) * (x / 2.0);
} else if (x <= 1e+195) {
tmp = 0.5 * y;
} else {
tmp = x / (2.0 * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.5e+18: tmp = 0.5 * y elif x <= 5.5e+182: tmp = (x / y) * (x / 2.0) elif x <= 1e+195: tmp = 0.5 * y else: tmp = x / (2.0 * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.5e+18) tmp = Float64(0.5 * y); elseif (x <= 5.5e+182) tmp = Float64(Float64(x / y) * Float64(x / 2.0)); elseif (x <= 1e+195) tmp = Float64(0.5 * y); else tmp = Float64(x / Float64(2.0 * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.5e+18) tmp = 0.5 * y; elseif (x <= 5.5e+182) tmp = (x / y) * (x / 2.0); elseif (x <= 1e+195) tmp = 0.5 * y; else tmp = x / (2.0 * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.5e+18], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 5.5e+182], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+195], N[(0.5 * y), $MachinePrecision], N[(x / N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+18}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+182}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\mathbf{elif}\;x \leq 10^{+195}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if x < 3.5e18 or 5.49999999999999977e182 < x < 9.99999999999999977e194Initial program 68.8%
Taylor expanded in y around inf 41.3%
if 3.5e18 < x < 5.49999999999999977e182Initial program 77.2%
Taylor expanded in x around inf 48.4%
unpow248.4%
times-frac51.3%
Applied egg-rr51.3%
if 9.99999999999999977e194 < x Initial program 59.3%
Taylor expanded in x around inf 67.5%
div-inv67.5%
unpow267.5%
associate-*l*84.6%
metadata-eval84.6%
div-inv84.6%
clear-num84.6%
Applied egg-rr84.6%
div-inv84.6%
associate-*r*84.6%
*-commutative84.6%
associate-/r/84.7%
div-inv84.8%
*-un-lft-identity84.8%
*-commutative84.8%
times-frac84.8%
metadata-eval84.8%
Applied egg-rr84.8%
Final simplification47.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.0%
Taylor expanded in y around inf 35.7%
Final simplification35.7%
(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 2023301
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))