
(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 10 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
(let* ((t_0 (hypot y (hypot x z))))
(if (<= y -5.3e+67)
(/ (* t_0 0.5) (/ y (hypot y x)))
(if (<= y 7.5e+163)
(/ (fma y y (fma x x (* z (- z)))) (* y 2.0))
(* t_0 (* 0.5 (/ (hypot y x) y)))))))
double code(double x, double y, double z) {
double t_0 = hypot(y, hypot(x, z));
double tmp;
if (y <= -5.3e+67) {
tmp = (t_0 * 0.5) / (y / hypot(y, x));
} else if (y <= 7.5e+163) {
tmp = fma(y, y, fma(x, x, (z * -z))) / (y * 2.0);
} else {
tmp = t_0 * (0.5 * (hypot(y, x) / y));
}
return tmp;
}
function code(x, y, z) t_0 = hypot(y, hypot(x, z)) tmp = 0.0 if (y <= -5.3e+67) tmp = Float64(Float64(t_0 * 0.5) / Float64(y / hypot(y, x))); elseif (y <= 7.5e+163) tmp = Float64(fma(y, y, fma(x, x, Float64(z * Float64(-z)))) / Float64(y * 2.0)); else tmp = Float64(t_0 * Float64(0.5 * Float64(hypot(y, x) / y))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -5.3e+67], N[(N[(t$95$0 * 0.5), $MachinePrecision] / N[(y / N[Sqrt[y ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e+163], N[(N[(y * y + N[(x * x + N[(z * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(0.5 * N[(N[Sqrt[y ^ 2 + x ^ 2], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -5.3 \cdot 10^{+67}:\\
\;\;\;\;\frac{t_0 \cdot 0.5}{\frac{y}{\mathsf{hypot}\left(y, x\right)}}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+163}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, z \cdot \left(-z\right)\right)\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)\\
\end{array}
\end{array}
if y < -5.3e67Initial program 29.5%
div-inv29.5%
add-sqr-sqrt25.3%
associate-*l*25.3%
Applied egg-rr89.3%
Taylor expanded in z around 0 30.5%
associate-*l/30.5%
*-lft-identity30.5%
+-commutative30.5%
unpow230.5%
unpow230.5%
hypot-def89.3%
Simplified89.3%
associate-*r*89.3%
clear-num89.3%
un-div-inv89.3%
Applied egg-rr89.3%
if -5.3e67 < y < 7.50000000000000001e163Initial program 91.8%
sqr-neg91.8%
sqr-neg91.8%
+-commutative91.8%
associate--l+91.8%
fma-def92.4%
fma-neg95.2%
distribute-rgt-neg-in95.2%
Simplified95.2%
if 7.50000000000000001e163 < y Initial program 8.5%
div-inv8.5%
add-sqr-sqrt8.5%
associate-*l*8.5%
Applied egg-rr86.5%
Taylor expanded in z around 0 9.2%
associate-*l/9.2%
*-lft-identity9.2%
+-commutative9.2%
unpow29.2%
unpow29.2%
hypot-def86.6%
Simplified86.6%
Final simplification93.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.3e+67) (not (<= y 7.5e+163))) (* (hypot y (hypot x z)) (* 0.5 (/ (hypot y x) y))) (/ (fma y y (fma x x (* z (- z)))) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.3e+67) || !(y <= 7.5e+163)) {
tmp = hypot(y, hypot(x, z)) * (0.5 * (hypot(y, x) / y));
} else {
tmp = fma(y, y, fma(x, x, (z * -z))) / (y * 2.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -5.3e+67) || !(y <= 7.5e+163)) tmp = Float64(hypot(y, hypot(x, z)) * Float64(0.5 * Float64(hypot(y, x) / y))); else tmp = Float64(fma(y, y, fma(x, x, Float64(z * Float64(-z)))) / Float64(y * 2.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.3e+67], N[Not[LessEqual[y, 7.5e+163]], $MachinePrecision]], N[(N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] * N[(0.5 * N[(N[Sqrt[y ^ 2 + x ^ 2], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y + N[(x * x + N[(z * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+67} \lor \neg \left(y \leq 7.5 \cdot 10^{+163}\right):\\
\;\;\;\;\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right) \cdot \left(0.5 \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, z \cdot \left(-z\right)\right)\right)}{y \cdot 2}\\
\end{array}
\end{array}
if y < -5.3e67 or 7.50000000000000001e163 < y Initial program 21.3%
div-inv21.3%
add-sqr-sqrt18.7%
associate-*l*18.7%
Applied egg-rr88.2%
Taylor expanded in z around 0 22.2%
associate-*l/22.2%
*-lft-identity22.2%
+-commutative22.2%
unpow222.2%
unpow222.2%
hypot-def88.3%
Simplified88.3%
if -5.3e67 < y < 7.50000000000000001e163Initial program 91.8%
sqr-neg91.8%
sqr-neg91.8%
+-commutative91.8%
associate--l+91.8%
fma-def92.4%
fma-neg95.2%
distribute-rgt-neg-in95.2%
Simplified95.2%
Final simplification93.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (hypot y (hypot x z))))
(if (<= y -1.35e+154)
(* t_0 -0.5)
(if (<= y 7.5e+163)
(/ (fma y y (fma x x (* z (- z)))) (* y 2.0))
(* t_0 0.5)))))
double code(double x, double y, double z) {
double t_0 = hypot(y, hypot(x, z));
double tmp;
if (y <= -1.35e+154) {
tmp = t_0 * -0.5;
} else if (y <= 7.5e+163) {
tmp = fma(y, y, fma(x, x, (z * -z))) / (y * 2.0);
} else {
tmp = t_0 * 0.5;
}
return tmp;
}
function code(x, y, z) t_0 = hypot(y, hypot(x, z)) tmp = 0.0 if (y <= -1.35e+154) tmp = Float64(t_0 * -0.5); elseif (y <= 7.5e+163) tmp = Float64(fma(y, y, fma(x, x, Float64(z * Float64(-z)))) / Float64(y * 2.0)); else tmp = Float64(t_0 * 0.5); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -1.35e+154], N[(t$95$0 * -0.5), $MachinePrecision], If[LessEqual[y, 7.5e+163], N[(N[(y * y + N[(x * x + N[(z * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0 \cdot -0.5\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+163}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, z \cdot \left(-z\right)\right)\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot 0.5\\
\end{array}
\end{array}
if y < -1.35000000000000003e154Initial program 11.1%
div-inv11.1%
add-sqr-sqrt11.1%
associate-*l*11.1%
Applied egg-rr90.2%
Taylor expanded in y around -inf 75.9%
if -1.35000000000000003e154 < y < 7.50000000000000001e163Initial program 89.6%
sqr-neg89.6%
sqr-neg89.6%
+-commutative89.6%
associate--l+89.6%
fma-def90.2%
fma-neg92.7%
distribute-rgt-neg-in92.7%
Simplified92.7%
if 7.50000000000000001e163 < y Initial program 8.5%
div-inv8.5%
add-sqr-sqrt8.5%
associate-*l*8.5%
Applied egg-rr86.5%
Taylor expanded in y around inf 79.8%
Final simplification89.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (hypot y (hypot x z))))
(if (<= y -1.35e+154)
(* t_0 -0.5)
(if (<= y 1.3e+146)
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
(if (<= y 1.55e+170) (/ -0.5 (/ (/ y z) z)) (* t_0 0.5))))))
double code(double x, double y, double z) {
double t_0 = hypot(y, hypot(x, z));
double tmp;
if (y <= -1.35e+154) {
tmp = t_0 * -0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = t_0 * 0.5;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.hypot(y, Math.hypot(x, z));
double tmp;
if (y <= -1.35e+154) {
tmp = t_0 * -0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = t_0 * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = math.hypot(y, math.hypot(x, z)) tmp = 0 if y <= -1.35e+154: tmp = t_0 * -0.5 elif y <= 1.3e+146: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) elif y <= 1.55e+170: tmp = -0.5 / ((y / z) / z) else: tmp = t_0 * 0.5 return tmp
function code(x, y, z) t_0 = hypot(y, hypot(x, z)) tmp = 0.0 if (y <= -1.35e+154) tmp = Float64(t_0 * -0.5); elseif (y <= 1.3e+146) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); elseif (y <= 1.55e+170) tmp = Float64(-0.5 / Float64(Float64(y / z) / z)); else tmp = Float64(t_0 * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = hypot(y, hypot(x, z)); tmp = 0.0; if (y <= -1.35e+154) tmp = t_0 * -0.5; elseif (y <= 1.3e+146) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); elseif (y <= 1.55e+170) tmp = -0.5 / ((y / z) / z); else tmp = t_0 * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -1.35e+154], N[(t$95$0 * -0.5), $MachinePrecision], If[LessEqual[y, 1.3e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.55e+170], N[(-0.5 / N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0 \cdot -0.5\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+170}:\\
\;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot 0.5\\
\end{array}
\end{array}
if y < -1.35000000000000003e154Initial program 11.1%
div-inv11.1%
add-sqr-sqrt11.1%
associate-*l*11.1%
Applied egg-rr90.2%
Taylor expanded in y around -inf 75.9%
if -1.35000000000000003e154 < y < 1.30000000000000007e146Initial program 91.8%
if 1.30000000000000007e146 < y < 1.55e170Initial program 23.2%
Taylor expanded in z around inf 33.6%
*-commutative33.6%
Simplified33.6%
*-commutative33.6%
clear-num33.6%
un-div-inv33.6%
Applied egg-rr33.6%
*-un-lft-identity33.6%
unpow233.6%
times-frac75.4%
Applied egg-rr75.4%
associate-*l/75.7%
*-lft-identity75.7%
Simplified75.7%
if 1.55e170 < y Initial program 9.3%
div-inv9.3%
add-sqr-sqrt9.3%
associate-*l*9.3%
Applied egg-rr92.4%
Taylor expanded in y around inf 84.9%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.35e+154)
(* (hypot y (hypot x z)) -0.5)
(if (<= y 1.3e+146)
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
(if (<= y 1.55e+170) (/ -0.5 (/ (/ y z) z)) (* y 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+154) {
tmp = hypot(y, hypot(x, z)) * -0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = y * 0.5;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+154) {
tmp = Math.hypot(y, Math.hypot(x, z)) * -0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+154: tmp = math.hypot(y, math.hypot(x, z)) * -0.5 elif y <= 1.3e+146: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) elif y <= 1.55e+170: tmp = -0.5 / ((y / z) / z) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+154) tmp = Float64(hypot(y, hypot(x, z)) * -0.5); elseif (y <= 1.3e+146) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); elseif (y <= 1.55e+170) tmp = Float64(-0.5 / Float64(Float64(y / z) / z)); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+154) tmp = hypot(y, hypot(x, z)) * -0.5; elseif (y <= 1.3e+146) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); elseif (y <= 1.55e+170) tmp = -0.5 / ((y / z) / z); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+154], N[(N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[y, 1.3e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.55e+170], N[(-0.5 / N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right) \cdot -0.5\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+170}:\\
\;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.35000000000000003e154Initial program 11.1%
div-inv11.1%
add-sqr-sqrt11.1%
associate-*l*11.1%
Applied egg-rr90.2%
Taylor expanded in y around -inf 75.9%
if -1.35000000000000003e154 < y < 1.30000000000000007e146Initial program 91.8%
if 1.30000000000000007e146 < y < 1.55e170Initial program 23.2%
Taylor expanded in z around inf 33.6%
*-commutative33.6%
Simplified33.6%
*-commutative33.6%
clear-num33.6%
un-div-inv33.6%
Applied egg-rr33.6%
*-un-lft-identity33.6%
unpow233.6%
times-frac75.4%
Applied egg-rr75.4%
associate-*l/75.7%
*-lft-identity75.7%
Simplified75.7%
if 1.55e170 < y Initial program 9.3%
Taylor expanded in y around inf 84.7%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.35e+154)
(* y 0.5)
(if (<= y 1.3e+146)
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
(if (<= y 1.55e+170) (/ -0.5 (/ (/ y z) z)) (* y 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+154) {
tmp = y * 0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = y * 0.5;
}
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 <= (-1.35d+154)) then
tmp = y * 0.5d0
else if (y <= 1.3d+146) then
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
else if (y <= 1.55d+170) then
tmp = (-0.5d0) / ((y / z) / z)
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+154) {
tmp = y * 0.5;
} else if (y <= 1.3e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else if (y <= 1.55e+170) {
tmp = -0.5 / ((y / z) / z);
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+154: tmp = y * 0.5 elif y <= 1.3e+146: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) elif y <= 1.55e+170: tmp = -0.5 / ((y / z) / z) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+154) tmp = Float64(y * 0.5); elseif (y <= 1.3e+146) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); elseif (y <= 1.55e+170) tmp = Float64(-0.5 / Float64(Float64(y / z) / z)); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+154) tmp = y * 0.5; elseif (y <= 1.3e+146) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); elseif (y <= 1.55e+170) tmp = -0.5 / ((y / z) / z); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+154], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 1.3e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.55e+170], N[(-0.5 / N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+170}:\\
\;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.35000000000000003e154 or 1.55e170 < y Initial program 10.3%
Taylor expanded in y around inf 79.8%
if -1.35000000000000003e154 < y < 1.30000000000000007e146Initial program 91.8%
if 1.30000000000000007e146 < y < 1.55e170Initial program 23.2%
Taylor expanded in z around inf 33.6%
*-commutative33.6%
Simplified33.6%
*-commutative33.6%
clear-num33.6%
un-div-inv33.6%
Applied egg-rr33.6%
*-un-lft-identity33.6%
unpow233.6%
times-frac75.4%
Applied egg-rr75.4%
associate-*l/75.7%
*-lft-identity75.7%
Simplified75.7%
Final simplification88.4%
(FPCore (x y z)
:precision binary64
(if (<= x 3.2e-122)
(* y 0.5)
(if (or (<= x 1.2e-28) (and (not (<= x 4.5e+24)) (<= x 4.1e+108)))
(* -0.5 (* z (/ z y)))
(* x (* x (/ 0.5 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.2e-122) {
tmp = y * 0.5;
} else if ((x <= 1.2e-28) || (!(x <= 4.5e+24) && (x <= 4.1e+108))) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 3.2d-122) then
tmp = y * 0.5d0
else if ((x <= 1.2d-28) .or. (.not. (x <= 4.5d+24)) .and. (x <= 4.1d+108)) then
tmp = (-0.5d0) * (z * (z / y))
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.2e-122) {
tmp = y * 0.5;
} else if ((x <= 1.2e-28) || (!(x <= 4.5e+24) && (x <= 4.1e+108))) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.2e-122: tmp = y * 0.5 elif (x <= 1.2e-28) or (not (x <= 4.5e+24) and (x <= 4.1e+108)): tmp = -0.5 * (z * (z / y)) else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.2e-122) tmp = Float64(y * 0.5); elseif ((x <= 1.2e-28) || (!(x <= 4.5e+24) && (x <= 4.1e+108))) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.2e-122) tmp = y * 0.5; elseif ((x <= 1.2e-28) || (~((x <= 4.5e+24)) && (x <= 4.1e+108))) tmp = -0.5 * (z * (z / y)); else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.2e-122], N[(y * 0.5), $MachinePrecision], If[Or[LessEqual[x, 1.2e-28], And[N[Not[LessEqual[x, 4.5e+24]], $MachinePrecision], LessEqual[x, 4.1e+108]]], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-122}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-28} \lor \neg \left(x \leq 4.5 \cdot 10^{+24}\right) \land x \leq 4.1 \cdot 10^{+108}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 3.2000000000000002e-122Initial program 71.4%
Taylor expanded in y around inf 38.3%
if 3.2000000000000002e-122 < x < 1.2000000000000001e-28 or 4.50000000000000019e24 < x < 4.0999999999999999e108Initial program 74.4%
Taylor expanded in z around inf 46.3%
*-commutative46.3%
Simplified46.3%
div-inv46.3%
unpow246.3%
associate-*l*53.8%
div-inv53.8%
Applied egg-rr53.8%
if 1.2000000000000001e-28 < x < 4.50000000000000019e24 or 4.0999999999999999e108 < x Initial program 63.0%
Taylor expanded in x around inf 60.4%
associate-*r/60.4%
associate-/l*60.5%
Simplified60.5%
associate-/r/60.5%
unpow260.5%
associate-*r*74.7%
Applied egg-rr74.7%
Final simplification47.1%
(FPCore (x y z)
:precision binary64
(if (<= x 9.5e-129)
(* y 0.5)
(if (<= x 1.5e-27)
(* -0.5 (* z (/ z y)))
(if (or (<= x 5.8e+24) (not (<= x 1.15e+108)))
(* x (* x (/ 0.5 y)))
(/ -0.5 (/ (/ y z) z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 9.5e-129) {
tmp = y * 0.5;
} else if (x <= 1.5e-27) {
tmp = -0.5 * (z * (z / y));
} else if ((x <= 5.8e+24) || !(x <= 1.15e+108)) {
tmp = x * (x * (0.5 / y));
} else {
tmp = -0.5 / ((y / z) / 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 <= 9.5d-129) then
tmp = y * 0.5d0
else if (x <= 1.5d-27) then
tmp = (-0.5d0) * (z * (z / y))
else if ((x <= 5.8d+24) .or. (.not. (x <= 1.15d+108))) then
tmp = x * (x * (0.5d0 / y))
else
tmp = (-0.5d0) / ((y / z) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 9.5e-129) {
tmp = y * 0.5;
} else if (x <= 1.5e-27) {
tmp = -0.5 * (z * (z / y));
} else if ((x <= 5.8e+24) || !(x <= 1.15e+108)) {
tmp = x * (x * (0.5 / y));
} else {
tmp = -0.5 / ((y / z) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 9.5e-129: tmp = y * 0.5 elif x <= 1.5e-27: tmp = -0.5 * (z * (z / y)) elif (x <= 5.8e+24) or not (x <= 1.15e+108): tmp = x * (x * (0.5 / y)) else: tmp = -0.5 / ((y / z) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 9.5e-129) tmp = Float64(y * 0.5); elseif (x <= 1.5e-27) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); elseif ((x <= 5.8e+24) || !(x <= 1.15e+108)) tmp = Float64(x * Float64(x * Float64(0.5 / y))); else tmp = Float64(-0.5 / Float64(Float64(y / z) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 9.5e-129) tmp = y * 0.5; elseif (x <= 1.5e-27) tmp = -0.5 * (z * (z / y)); elseif ((x <= 5.8e+24) || ~((x <= 1.15e+108))) tmp = x * (x * (0.5 / y)); else tmp = -0.5 / ((y / z) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 9.5e-129], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 1.5e-27], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 5.8e+24], N[Not[LessEqual[x, 1.15e+108]], $MachinePrecision]], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{-129}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-27}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+24} \lor \neg \left(x \leq 1.15 \cdot 10^{+108}\right):\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{\frac{y}{z}}{z}}\\
\end{array}
\end{array}
if x < 9.5000000000000006e-129Initial program 71.4%
Taylor expanded in y around inf 38.3%
if 9.5000000000000006e-129 < x < 1.5000000000000001e-27Initial program 78.8%
Taylor expanded in z around inf 40.9%
*-commutative40.9%
Simplified40.9%
div-inv40.9%
unpow240.9%
associate-*l*48.8%
div-inv48.9%
Applied egg-rr48.9%
if 1.5000000000000001e-27 < x < 5.79999999999999958e24 or 1.1499999999999999e108 < x Initial program 63.0%
Taylor expanded in x around inf 60.4%
associate-*r/60.4%
associate-/l*60.5%
Simplified60.5%
associate-/r/60.5%
unpow260.5%
associate-*r*74.7%
Applied egg-rr74.7%
if 5.79999999999999958e24 < x < 1.1499999999999999e108Initial program 70.6%
Taylor expanded in z around inf 51.0%
*-commutative51.0%
Simplified51.0%
*-commutative51.0%
clear-num51.0%
un-div-inv51.0%
Applied egg-rr51.0%
*-un-lft-identity51.0%
unpow251.0%
times-frac58.1%
Applied egg-rr58.1%
associate-*l/58.2%
*-lft-identity58.2%
Simplified58.2%
Final simplification47.1%
(FPCore (x y z) :precision binary64 (if (or (<= z 1.18e+51) (and (not (<= z 7.5e+114)) (<= z 1e+133))) (* y 0.5) (* -0.5 (* z (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 1.18e+51) || (!(z <= 7.5e+114) && (z <= 1e+133))) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (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 <= 1.18d+51) .or. (.not. (z <= 7.5d+114)) .and. (z <= 1d+133)) then
tmp = y * 0.5d0
else
tmp = (-0.5d0) * (z * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 1.18e+51) || (!(z <= 7.5e+114) && (z <= 1e+133))) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (z * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 1.18e+51) or (not (z <= 7.5e+114) and (z <= 1e+133)): tmp = y * 0.5 else: tmp = -0.5 * (z * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 1.18e+51) || (!(z <= 7.5e+114) && (z <= 1e+133))) tmp = Float64(y * 0.5); else tmp = Float64(-0.5 * Float64(z * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 1.18e+51) || (~((z <= 7.5e+114)) && (z <= 1e+133))) tmp = y * 0.5; else tmp = -0.5 * (z * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 1.18e+51], And[N[Not[LessEqual[z, 7.5e+114]], $MachinePrecision], LessEqual[z, 1e+133]]], N[(y * 0.5), $MachinePrecision], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.18 \cdot 10^{+51} \lor \neg \left(z \leq 7.5 \cdot 10^{+114}\right) \land z \leq 10^{+133}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < 1.18e51 or 7.5000000000000001e114 < z < 1e133Initial program 70.4%
Taylor expanded in y around inf 38.0%
if 1.18e51 < z < 7.5000000000000001e114 or 1e133 < z Initial program 71.7%
Taylor expanded in z around inf 65.3%
*-commutative65.3%
Simplified65.3%
div-inv65.3%
unpow265.3%
associate-*l*75.1%
div-inv75.1%
Applied egg-rr75.1%
Final simplification44.9%
(FPCore (x y z) :precision binary64 (* y 0.5))
double code(double x, double y, double z) {
return y * 0.5;
}
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
end function
public static double code(double x, double y, double z) {
return y * 0.5;
}
def code(x, y, z): return y * 0.5
function code(x, y, z) return Float64(y * 0.5) end
function tmp = code(x, y, z) tmp = y * 0.5; end
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5
\end{array}
Initial program 70.6%
Taylor expanded in y around inf 33.0%
Final simplification33.0%
(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 2023318
(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)))