
(FPCore (p x) :precision binary64 (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))
double code(double p, double x) {
return sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))));
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = sqrt((0.5d0 * (1.0d0 + (x / sqrt((((4.0d0 * p) * p) + (x * x)))))))
end function
public static double code(double p, double x) {
return Math.sqrt((0.5 * (1.0 + (x / Math.sqrt((((4.0 * p) * p) + (x * x)))))));
}
def code(p, x): return math.sqrt((0.5 * (1.0 + (x / math.sqrt((((4.0 * p) * p) + (x * x)))))))
function code(p, x) return sqrt(Float64(0.5 * Float64(1.0 + Float64(x / sqrt(Float64(Float64(Float64(4.0 * p) * p) + Float64(x * x))))))) end
function tmp = code(p, x) tmp = sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x))))))); end
code[p_, x_] := N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(N[(N[(4.0 * p), $MachinePrecision] * p), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (p x) :precision binary64 (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))
double code(double p, double x) {
return sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))));
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = sqrt((0.5d0 * (1.0d0 + (x / sqrt((((4.0d0 * p) * p) + (x * x)))))))
end function
public static double code(double p, double x) {
return Math.sqrt((0.5 * (1.0 + (x / Math.sqrt((((4.0 * p) * p) + (x * x)))))));
}
def code(p, x): return math.sqrt((0.5 * (1.0 + (x / math.sqrt((((4.0 * p) * p) + (x * x)))))))
function code(p, x) return sqrt(Float64(0.5 * Float64(1.0 + Float64(x / sqrt(Float64(Float64(Float64(4.0 * p) * p) + Float64(x * x))))))) end
function tmp = code(p, x) tmp = sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x))))))); end
code[p_, x_] := N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(N[(N[(4.0 * p), $MachinePrecision] * p), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\end{array}
(FPCore (p x) :precision binary64 (if (<= (/ x (sqrt (+ (* p (* 4.0 p)) (* x x)))) -0.98) (sqrt (* 0.5 (fma 2.0 (pow (/ p x) 2.0) (* (pow (/ p x) 4.0) -6.0)))) (sqrt (* 0.5 (+ 1.0 (/ x (hypot (* p 2.0) x)))))))
double code(double p, double x) {
double tmp;
if ((x / sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.98) {
tmp = sqrt((0.5 * fma(2.0, pow((p / x), 2.0), (pow((p / x), 4.0) * -6.0))));
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot((p * 2.0), x)))));
}
return tmp;
}
function code(p, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p * Float64(4.0 * p)) + Float64(x * x)))) <= -0.98) tmp = sqrt(Float64(0.5 * fma(2.0, (Float64(p / x) ^ 2.0), Float64((Float64(p / x) ^ 4.0) * -6.0)))); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(Float64(p * 2.0), x))))); end return tmp end
code[p_, x_] := If[LessEqual[N[(x / N[Sqrt[N[(N[(p * N[(4.0 * p), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.98], N[Sqrt[N[(0.5 * N[(2.0 * N[Power[N[(p / x), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Power[N[(p / x), $MachinePrecision], 4.0], $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(p * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}} \leq -0.98:\\
\;\;\;\;\sqrt{0.5 \cdot \mathsf{fma}\left(2, {\left(\frac{p}{x}\right)}^{2}, {\left(\frac{p}{x}\right)}^{4} \cdot -6\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(p \cdot 2, x\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 4 p) p) (*.f64 x x)))) < -0.97999999999999998Initial program 22.0%
+-commutative22.0%
clear-num22.0%
associate-/r/18.4%
fma-def3.0%
+-commutative3.0%
add-sqr-sqrt3.0%
hypot-def3.0%
associate-*l*3.0%
sqrt-prod3.0%
metadata-eval3.0%
sqrt-unprod2.0%
add-sqr-sqrt3.0%
Applied egg-rr3.0%
Taylor expanded in x around -inf 49.3%
fma-def49.3%
unpow249.3%
unpow249.3%
times-frac54.8%
unpow254.8%
distribute-rgt-out54.8%
metadata-eval54.8%
pow-sqr54.8%
metadata-eval54.8%
pow-sqr54.8%
times-frac68.7%
unpow268.7%
unpow268.7%
times-frac68.7%
unpow268.7%
unpow268.7%
unpow268.7%
times-frac68.7%
unpow268.7%
pow-sqr68.7%
metadata-eval68.7%
metadata-eval68.7%
Simplified68.7%
if -0.97999999999999998 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 4 p) p) (*.f64 x x)))) Initial program 100.0%
add-sqr-sqrt100.0%
hypot-def100.0%
associate-*l*100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-unprod51.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification91.0%
(FPCore (p x) :precision binary64 (if (<= (/ x (sqrt (+ (* p (* 4.0 p)) (* x x)))) -0.98) (sqrt (* 0.5 (* 2.0 (* (/ p x) (/ p x))))) (sqrt (* 0.5 (+ 1.0 (/ x (hypot (* p 2.0) x)))))))
double code(double p, double x) {
double tmp;
if ((x / sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.98) {
tmp = sqrt((0.5 * (2.0 * ((p / x) * (p / x)))));
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot((p * 2.0), x)))));
}
return tmp;
}
public static double code(double p, double x) {
double tmp;
if ((x / Math.sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.98) {
tmp = Math.sqrt((0.5 * (2.0 * ((p / x) * (p / x)))));
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot((p * 2.0), x)))));
}
return tmp;
}
def code(p, x): tmp = 0 if (x / math.sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.98: tmp = math.sqrt((0.5 * (2.0 * ((p / x) * (p / x))))) else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot((p * 2.0), x))))) return tmp
function code(p, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p * Float64(4.0 * p)) + Float64(x * x)))) <= -0.98) tmp = sqrt(Float64(0.5 * Float64(2.0 * Float64(Float64(p / x) * Float64(p / x))))); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(Float64(p * 2.0), x))))); end return tmp end
function tmp_2 = code(p, x) tmp = 0.0; if ((x / sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.98) tmp = sqrt((0.5 * (2.0 * ((p / x) * (p / x))))); else tmp = sqrt((0.5 * (1.0 + (x / hypot((p * 2.0), x))))); end tmp_2 = tmp; end
code[p_, x_] := If[LessEqual[N[(x / N[Sqrt[N[(N[(p * N[(4.0 * p), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.98], N[Sqrt[N[(0.5 * N[(2.0 * N[(N[(p / x), $MachinePrecision] * N[(p / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(0.5 * N[(1.0 + N[(x / N[Sqrt[N[(p * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}} \leq -0.98:\\
\;\;\;\;\sqrt{0.5 \cdot \left(2 \cdot \left(\frac{p}{x} \cdot \frac{p}{x}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot \left(1 + \frac{x}{\mathsf{hypot}\left(p \cdot 2, x\right)}\right)}\\
\end{array}
\end{array}
if (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 4 p) p) (*.f64 x x)))) < -0.97999999999999998Initial program 22.0%
Taylor expanded in x around -inf 54.8%
unpow254.8%
unpow254.8%
times-frac68.6%
Simplified68.6%
if -0.97999999999999998 < (/.f64 x (sqrt.f64 (+.f64 (*.f64 (*.f64 4 p) p) (*.f64 x x)))) Initial program 100.0%
add-sqr-sqrt100.0%
hypot-def100.0%
associate-*l*100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-unprod51.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification91.0%
(FPCore (p x)
:precision binary64
(if (<= p -4.4e-11)
(sqrt 0.5)
(if (<= p -1.1e-306)
1.0
(if (<= p 9e-105) (/ (- p) x) (if (<= p 1.05e-19) 1.0 (sqrt 0.5))))))
double code(double p, double x) {
double tmp;
if (p <= -4.4e-11) {
tmp = sqrt(0.5);
} else if (p <= -1.1e-306) {
tmp = 1.0;
} else if (p <= 9e-105) {
tmp = -p / x;
} else if (p <= 1.05e-19) {
tmp = 1.0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= (-4.4d-11)) then
tmp = sqrt(0.5d0)
else if (p <= (-1.1d-306)) then
tmp = 1.0d0
else if (p <= 9d-105) then
tmp = -p / x
else if (p <= 1.05d-19) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double p, double x) {
double tmp;
if (p <= -4.4e-11) {
tmp = Math.sqrt(0.5);
} else if (p <= -1.1e-306) {
tmp = 1.0;
} else if (p <= 9e-105) {
tmp = -p / x;
} else if (p <= 1.05e-19) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(p, x): tmp = 0 if p <= -4.4e-11: tmp = math.sqrt(0.5) elif p <= -1.1e-306: tmp = 1.0 elif p <= 9e-105: tmp = -p / x elif p <= 1.05e-19: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
function code(p, x) tmp = 0.0 if (p <= -4.4e-11) tmp = sqrt(0.5); elseif (p <= -1.1e-306) tmp = 1.0; elseif (p <= 9e-105) tmp = Float64(Float64(-p) / x); elseif (p <= 1.05e-19) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(p, x) tmp = 0.0; if (p <= -4.4e-11) tmp = sqrt(0.5); elseif (p <= -1.1e-306) tmp = 1.0; elseif (p <= 9e-105) tmp = -p / x; elseif (p <= 1.05e-19) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[p_, x_] := If[LessEqual[p, -4.4e-11], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[p, -1.1e-306], 1.0, If[LessEqual[p, 9e-105], N[((-p) / x), $MachinePrecision], If[LessEqual[p, 1.05e-19], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;p \leq -4.4 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;p \leq -1.1 \cdot 10^{-306}:\\
\;\;\;\;1\\
\mathbf{elif}\;p \leq 9 \cdot 10^{-105}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{elif}\;p \leq 1.05 \cdot 10^{-19}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < -4.4000000000000003e-11 or 1.0499999999999999e-19 < p Initial program 93.8%
Taylor expanded in x around 0 87.6%
if -4.4000000000000003e-11 < p < -1.10000000000000008e-306 or 8.9999999999999995e-105 < p < 1.0499999999999999e-19Initial program 68.6%
Taylor expanded in x around inf 54.5%
if -1.10000000000000008e-306 < p < 8.9999999999999995e-105Initial program 57.0%
Taylor expanded in x around -inf 28.1%
unpow228.1%
unpow228.1%
times-frac39.2%
Simplified39.2%
Taylor expanded in p around -inf 62.6%
neg-mul-162.6%
distribute-frac-neg62.6%
Simplified62.6%
Final simplification72.1%
(FPCore (p x) :precision binary64 (if (<= p -4.6e-71) (sqrt 0.5) (if (<= p -1.15e-290) (/ p x) (if (<= p 9e-101) (/ (- p) x) (sqrt 0.5)))))
double code(double p, double x) {
double tmp;
if (p <= -4.6e-71) {
tmp = sqrt(0.5);
} else if (p <= -1.15e-290) {
tmp = p / x;
} else if (p <= 9e-101) {
tmp = -p / x;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= (-4.6d-71)) then
tmp = sqrt(0.5d0)
else if (p <= (-1.15d-290)) then
tmp = p / x
else if (p <= 9d-101) then
tmp = -p / x
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double p, double x) {
double tmp;
if (p <= -4.6e-71) {
tmp = Math.sqrt(0.5);
} else if (p <= -1.15e-290) {
tmp = p / x;
} else if (p <= 9e-101) {
tmp = -p / x;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
def code(p, x): tmp = 0 if p <= -4.6e-71: tmp = math.sqrt(0.5) elif p <= -1.15e-290: tmp = p / x elif p <= 9e-101: tmp = -p / x else: tmp = math.sqrt(0.5) return tmp
function code(p, x) tmp = 0.0 if (p <= -4.6e-71) tmp = sqrt(0.5); elseif (p <= -1.15e-290) tmp = Float64(p / x); elseif (p <= 9e-101) tmp = Float64(Float64(-p) / x); else tmp = sqrt(0.5); end return tmp end
function tmp_2 = code(p, x) tmp = 0.0; if (p <= -4.6e-71) tmp = sqrt(0.5); elseif (p <= -1.15e-290) tmp = p / x; elseif (p <= 9e-101) tmp = -p / x; else tmp = sqrt(0.5); end tmp_2 = tmp; end
code[p_, x_] := If[LessEqual[p, -4.6e-71], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[p, -1.15e-290], N[(p / x), $MachinePrecision], If[LessEqual[p, 9e-101], N[((-p) / x), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;p \leq -4.6 \cdot 10^{-71}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;p \leq -1.15 \cdot 10^{-290}:\\
\;\;\;\;\frac{p}{x}\\
\mathbf{elif}\;p \leq 9 \cdot 10^{-101}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < -4.5999999999999997e-71 or 8.9999999999999997e-101 < p Initial program 92.2%
Taylor expanded in x around 0 78.8%
if -4.5999999999999997e-71 < p < -1.15e-290Initial program 60.7%
Taylor expanded in x around -inf 27.3%
unpow227.3%
unpow227.3%
times-frac34.5%
Simplified34.5%
Taylor expanded in p around 0 49.4%
if -1.15e-290 < p < 8.9999999999999997e-101Initial program 57.5%
Taylor expanded in x around -inf 26.9%
unpow226.9%
unpow226.9%
times-frac37.6%
Simplified37.6%
Taylor expanded in p around -inf 61.4%
neg-mul-161.4%
distribute-frac-neg61.4%
Simplified61.4%
Final simplification69.1%
(FPCore (p x) :precision binary64 (if (<= p -5.7e-291) (/ p x) (/ (- p) x)))
double code(double p, double x) {
double tmp;
if (p <= -5.7e-291) {
tmp = p / x;
} else {
tmp = -p / x;
}
return tmp;
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= (-5.7d-291)) then
tmp = p / x
else
tmp = -p / x
end if
code = tmp
end function
public static double code(double p, double x) {
double tmp;
if (p <= -5.7e-291) {
tmp = p / x;
} else {
tmp = -p / x;
}
return tmp;
}
def code(p, x): tmp = 0 if p <= -5.7e-291: tmp = p / x else: tmp = -p / x return tmp
function code(p, x) tmp = 0.0 if (p <= -5.7e-291) tmp = Float64(p / x); else tmp = Float64(Float64(-p) / x); end return tmp end
function tmp_2 = code(p, x) tmp = 0.0; if (p <= -5.7e-291) tmp = p / x; else tmp = -p / x; end tmp_2 = tmp; end
code[p_, x_] := If[LessEqual[p, -5.7e-291], N[(p / x), $MachinePrecision], N[((-p) / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;p \leq -5.7 \cdot 10^{-291}:\\
\;\;\;\;\frac{p}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{-p}{x}\\
\end{array}
\end{array}
if p < -5.70000000000000034e-291Initial program 79.2%
Taylor expanded in x around -inf 19.3%
unpow219.3%
unpow219.3%
times-frac22.3%
Simplified22.3%
Taylor expanded in p around 0 26.9%
if -5.70000000000000034e-291 < p Initial program 76.5%
Taylor expanded in x around -inf 19.0%
unpow219.0%
unpow219.0%
times-frac24.1%
Simplified24.1%
Taylor expanded in p around -inf 33.9%
neg-mul-133.9%
distribute-frac-neg33.9%
Simplified33.9%
Final simplification30.8%
(FPCore (p x) :precision binary64 (/ p x))
double code(double p, double x) {
return p / x;
}
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = p / x
end function
public static double code(double p, double x) {
return p / x;
}
def code(p, x): return p / x
function code(p, x) return Float64(p / x) end
function tmp = code(p, x) tmp = p / x; end
code[p_, x_] := N[(p / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{p}{x}
\end{array}
Initial program 77.7%
Taylor expanded in x around -inf 19.2%
unpow219.2%
unpow219.2%
times-frac23.3%
Simplified23.3%
Taylor expanded in p around 0 17.8%
Final simplification17.8%
(FPCore (p x) :precision binary64 (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x))))))
double code(double p, double x) {
return sqrt((0.5 + (copysign(0.5, x) / hypot(1.0, ((2.0 * p) / x)))));
}
public static double code(double p, double x) {
return Math.sqrt((0.5 + (Math.copySign(0.5, x) / Math.hypot(1.0, ((2.0 * p) / x)))));
}
def code(p, x): return math.sqrt((0.5 + (math.copysign(0.5, x) / math.hypot(1.0, ((2.0 * p) / x)))))
function code(p, x) return sqrt(Float64(0.5 + Float64(copysign(0.5, x) / hypot(1.0, Float64(Float64(2.0 * p) / x))))) end
function tmp = code(p, x) tmp = sqrt((0.5 + ((sign(x) * abs(0.5)) / hypot(1.0, ((2.0 * p) / x))))); end
code[p_, x_] := N[Sqrt[N[(0.5 + N[(N[With[{TMP1 = Abs[0.5], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(2.0 * p), $MachinePrecision] / x), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.5 + \frac{\mathsf{copysign}\left(0.5, x\right)}{\mathsf{hypot}\left(1, \frac{2 \cdot p}{x}\right)}}
\end{array}
herbie shell --seed 2023182
(FPCore (p x)
:name "Given's Rotation SVD example"
:precision binary64
:pre (and (< 1e-150 (fabs x)) (< (fabs x) 1e+150))
:herbie-target
(sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))
(sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))