
(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}
NOTE: p should be positive before calling this function (FPCore (p x) :precision binary64 (if (<= (/ x (sqrt (+ (* p (* 4.0 p)) (* x x)))) -0.5) (/ (- p) x) (sqrt (* 0.5 (+ 1.0 (/ x (hypot (* p 2.0) x)))))))
p = abs(p);
double code(double p, double x) {
double tmp;
if ((x / sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.5) {
tmp = -p / x;
} else {
tmp = sqrt((0.5 * (1.0 + (x / hypot((p * 2.0), x)))));
}
return tmp;
}
p = Math.abs(p);
public static double code(double p, double x) {
double tmp;
if ((x / Math.sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.5) {
tmp = -p / x;
} else {
tmp = Math.sqrt((0.5 * (1.0 + (x / Math.hypot((p * 2.0), x)))));
}
return tmp;
}
p = abs(p) def code(p, x): tmp = 0 if (x / math.sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.5: tmp = -p / x else: tmp = math.sqrt((0.5 * (1.0 + (x / math.hypot((p * 2.0), x))))) return tmp
p = abs(p) function code(p, x) tmp = 0.0 if (Float64(x / sqrt(Float64(Float64(p * Float64(4.0 * p)) + Float64(x * x)))) <= -0.5) tmp = Float64(Float64(-p) / x); else tmp = sqrt(Float64(0.5 * Float64(1.0 + Float64(x / hypot(Float64(p * 2.0), x))))); end return tmp end
p = abs(p) function tmp_2 = code(p, x) tmp = 0.0; if ((x / sqrt(((p * (4.0 * p)) + (x * x)))) <= -0.5) tmp = -p / x; else tmp = sqrt((0.5 * (1.0 + (x / hypot((p * 2.0), x))))); end tmp_2 = tmp; end
NOTE: p should be positive before calling this function 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.5], N[((-p) / x), $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}
p = |p|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}} \leq -0.5:\\
\;\;\;\;\frac{-p}{x}\\
\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.5Initial program 16.6%
Taylor expanded in x around -inf 41.4%
unpow241.4%
unpow241.4%
Simplified41.4%
Taylor expanded in p around -inf 53.2%
associate-*r/53.2%
neg-mul-153.2%
Simplified53.2%
if -0.5 < (/.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-unprod46.3%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification87.9%
NOTE: p should be positive before calling this function
(FPCore (p x)
:precision binary64
(if (<= p 1.25e-136)
(/ (- p) x)
(if (<= p 3.9e-94)
1.0
(if (<= p 9.5e-76)
(sqrt 0.5)
(if (<= p 1.9e-5) 1.0 (sqrt (+ 0.5 (* 0.25 (/ x p)))))))))p = abs(p);
double code(double p, double x) {
double tmp;
if (p <= 1.25e-136) {
tmp = -p / x;
} else if (p <= 3.9e-94) {
tmp = 1.0;
} else if (p <= 9.5e-76) {
tmp = sqrt(0.5);
} else if (p <= 1.9e-5) {
tmp = 1.0;
} else {
tmp = sqrt((0.5 + (0.25 * (x / p))));
}
return tmp;
}
NOTE: p should be positive before calling this function
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= 1.25d-136) then
tmp = -p / x
else if (p <= 3.9d-94) then
tmp = 1.0d0
else if (p <= 9.5d-76) then
tmp = sqrt(0.5d0)
else if (p <= 1.9d-5) then
tmp = 1.0d0
else
tmp = sqrt((0.5d0 + (0.25d0 * (x / p))))
end if
code = tmp
end function
p = Math.abs(p);
public static double code(double p, double x) {
double tmp;
if (p <= 1.25e-136) {
tmp = -p / x;
} else if (p <= 3.9e-94) {
tmp = 1.0;
} else if (p <= 9.5e-76) {
tmp = Math.sqrt(0.5);
} else if (p <= 1.9e-5) {
tmp = 1.0;
} else {
tmp = Math.sqrt((0.5 + (0.25 * (x / p))));
}
return tmp;
}
p = abs(p) def code(p, x): tmp = 0 if p <= 1.25e-136: tmp = -p / x elif p <= 3.9e-94: tmp = 1.0 elif p <= 9.5e-76: tmp = math.sqrt(0.5) elif p <= 1.9e-5: tmp = 1.0 else: tmp = math.sqrt((0.5 + (0.25 * (x / p)))) return tmp
p = abs(p) function code(p, x) tmp = 0.0 if (p <= 1.25e-136) tmp = Float64(Float64(-p) / x); elseif (p <= 3.9e-94) tmp = 1.0; elseif (p <= 9.5e-76) tmp = sqrt(0.5); elseif (p <= 1.9e-5) tmp = 1.0; else tmp = sqrt(Float64(0.5 + Float64(0.25 * Float64(x / p)))); end return tmp end
p = abs(p) function tmp_2 = code(p, x) tmp = 0.0; if (p <= 1.25e-136) tmp = -p / x; elseif (p <= 3.9e-94) tmp = 1.0; elseif (p <= 9.5e-76) tmp = sqrt(0.5); elseif (p <= 1.9e-5) tmp = 1.0; else tmp = sqrt((0.5 + (0.25 * (x / p)))); end tmp_2 = tmp; end
NOTE: p should be positive before calling this function code[p_, x_] := If[LessEqual[p, 1.25e-136], N[((-p) / x), $MachinePrecision], If[LessEqual[p, 3.9e-94], 1.0, If[LessEqual[p, 9.5e-76], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[p, 1.9e-5], 1.0, N[Sqrt[N[(0.5 + N[(0.25 * N[(x / p), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
p = |p|\\
\\
\begin{array}{l}
\mathbf{if}\;p \leq 1.25 \cdot 10^{-136}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{elif}\;p \leq 3.9 \cdot 10^{-94}:\\
\;\;\;\;1\\
\mathbf{elif}\;p \leq 9.5 \cdot 10^{-76}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;p \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 + 0.25 \cdot \frac{x}{p}}\\
\end{array}
\end{array}
if p < 1.25e-136Initial program 74.3%
Taylor expanded in x around -inf 14.9%
unpow214.9%
unpow214.9%
Simplified14.9%
Taylor expanded in p around -inf 16.9%
associate-*r/16.9%
neg-mul-116.9%
Simplified16.9%
if 1.25e-136 < p < 3.9000000000000002e-94 or 9.49999999999999984e-76 < p < 1.9000000000000001e-5Initial program 75.0%
add-sqr-sqrt75.0%
hypot-def75.0%
associate-*l*75.0%
sqrt-prod75.0%
metadata-eval75.0%
sqrt-unprod75.0%
add-sqr-sqrt75.0%
Applied egg-rr75.0%
add-sqr-sqrt74.7%
pow274.7%
pow1/274.7%
sqrt-pow174.7%
distribute-lft-in74.7%
metadata-eval74.7%
associate-*r/74.7%
metadata-eval74.7%
Applied egg-rr74.7%
Taylor expanded in x around inf 54.5%
if 3.9000000000000002e-94 < p < 9.49999999999999984e-76Initial program 52.3%
Taylor expanded in x around 0 52.6%
if 1.9000000000000001e-5 < p Initial program 98.1%
add-sqr-sqrt98.1%
hypot-def98.1%
associate-*l*98.1%
sqrt-prod98.1%
metadata-eval98.1%
sqrt-unprod98.1%
add-sqr-sqrt98.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 88.4%
Final simplification35.1%
NOTE: p should be positive before calling this function
(FPCore (p x)
:precision binary64
(if (<= p 1.35e-136)
(/ (- p) x)
(if (<= p 3.9e-94)
1.0
(if (<= p 1.2e-75) (sqrt 0.5) (if (<= p 1.8e-24) 1.0 (sqrt 0.5))))))p = abs(p);
double code(double p, double x) {
double tmp;
if (p <= 1.35e-136) {
tmp = -p / x;
} else if (p <= 3.9e-94) {
tmp = 1.0;
} else if (p <= 1.2e-75) {
tmp = sqrt(0.5);
} else if (p <= 1.8e-24) {
tmp = 1.0;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
NOTE: p should be positive before calling this function
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= 1.35d-136) then
tmp = -p / x
else if (p <= 3.9d-94) then
tmp = 1.0d0
else if (p <= 1.2d-75) then
tmp = sqrt(0.5d0)
else if (p <= 1.8d-24) then
tmp = 1.0d0
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
p = Math.abs(p);
public static double code(double p, double x) {
double tmp;
if (p <= 1.35e-136) {
tmp = -p / x;
} else if (p <= 3.9e-94) {
tmp = 1.0;
} else if (p <= 1.2e-75) {
tmp = Math.sqrt(0.5);
} else if (p <= 1.8e-24) {
tmp = 1.0;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p = abs(p) def code(p, x): tmp = 0 if p <= 1.35e-136: tmp = -p / x elif p <= 3.9e-94: tmp = 1.0 elif p <= 1.2e-75: tmp = math.sqrt(0.5) elif p <= 1.8e-24: tmp = 1.0 else: tmp = math.sqrt(0.5) return tmp
p = abs(p) function code(p, x) tmp = 0.0 if (p <= 1.35e-136) tmp = Float64(Float64(-p) / x); elseif (p <= 3.9e-94) tmp = 1.0; elseif (p <= 1.2e-75) tmp = sqrt(0.5); elseif (p <= 1.8e-24) tmp = 1.0; else tmp = sqrt(0.5); end return tmp end
p = abs(p) function tmp_2 = code(p, x) tmp = 0.0; if (p <= 1.35e-136) tmp = -p / x; elseif (p <= 3.9e-94) tmp = 1.0; elseif (p <= 1.2e-75) tmp = sqrt(0.5); elseif (p <= 1.8e-24) tmp = 1.0; else tmp = sqrt(0.5); end tmp_2 = tmp; end
NOTE: p should be positive before calling this function code[p_, x_] := If[LessEqual[p, 1.35e-136], N[((-p) / x), $MachinePrecision], If[LessEqual[p, 3.9e-94], 1.0, If[LessEqual[p, 1.2e-75], N[Sqrt[0.5], $MachinePrecision], If[LessEqual[p, 1.8e-24], 1.0, N[Sqrt[0.5], $MachinePrecision]]]]]
\begin{array}{l}
p = |p|\\
\\
\begin{array}{l}
\mathbf{if}\;p \leq 1.35 \cdot 10^{-136}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{elif}\;p \leq 3.9 \cdot 10^{-94}:\\
\;\;\;\;1\\
\mathbf{elif}\;p \leq 1.2 \cdot 10^{-75}:\\
\;\;\;\;\sqrt{0.5}\\
\mathbf{elif}\;p \leq 1.8 \cdot 10^{-24}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 1.3499999999999999e-136Initial program 74.3%
Taylor expanded in x around -inf 14.9%
unpow214.9%
unpow214.9%
Simplified14.9%
Taylor expanded in p around -inf 16.9%
associate-*r/16.9%
neg-mul-116.9%
Simplified16.9%
if 1.3499999999999999e-136 < p < 3.9000000000000002e-94 or 1.2000000000000001e-75 < p < 1.8e-24Initial program 77.4%
add-sqr-sqrt77.4%
hypot-def77.4%
associate-*l*77.4%
sqrt-prod77.4%
metadata-eval77.4%
sqrt-unprod77.4%
add-sqr-sqrt77.4%
Applied egg-rr77.4%
add-sqr-sqrt77.3%
pow277.3%
pow1/277.3%
sqrt-pow177.3%
distribute-lft-in77.3%
metadata-eval77.3%
associate-*r/77.3%
metadata-eval77.3%
Applied egg-rr77.3%
Taylor expanded in x around inf 63.7%
if 3.9000000000000002e-94 < p < 1.2000000000000001e-75 or 1.8e-24 < p Initial program 90.8%
Taylor expanded in x around 0 81.2%
Final simplification35.6%
NOTE: p should be positive before calling this function (FPCore (p x) :precision binary64 (if (<= p 5.5e-109) (/ (- p) x) (sqrt 0.5)))
p = abs(p);
double code(double p, double x) {
double tmp;
if (p <= 5.5e-109) {
tmp = -p / x;
} else {
tmp = sqrt(0.5);
}
return tmp;
}
NOTE: p should be positive before calling this function
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (p <= 5.5d-109) then
tmp = -p / x
else
tmp = sqrt(0.5d0)
end if
code = tmp
end function
p = Math.abs(p);
public static double code(double p, double x) {
double tmp;
if (p <= 5.5e-109) {
tmp = -p / x;
} else {
tmp = Math.sqrt(0.5);
}
return tmp;
}
p = abs(p) def code(p, x): tmp = 0 if p <= 5.5e-109: tmp = -p / x else: tmp = math.sqrt(0.5) return tmp
p = abs(p) function code(p, x) tmp = 0.0 if (p <= 5.5e-109) tmp = Float64(Float64(-p) / x); else tmp = sqrt(0.5); end return tmp end
p = abs(p) function tmp_2 = code(p, x) tmp = 0.0; if (p <= 5.5e-109) tmp = -p / x; else tmp = sqrt(0.5); end tmp_2 = tmp; end
NOTE: p should be positive before calling this function code[p_, x_] := If[LessEqual[p, 5.5e-109], N[((-p) / x), $MachinePrecision], N[Sqrt[0.5], $MachinePrecision]]
\begin{array}{l}
p = |p|\\
\\
\begin{array}{l}
\mathbf{if}\;p \leq 5.5 \cdot 10^{-109}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5}\\
\end{array}
\end{array}
if p < 5.5000000000000003e-109Initial program 74.2%
Taylor expanded in x around -inf 15.6%
unpow215.6%
unpow215.6%
Simplified15.6%
Taylor expanded in p around -inf 17.5%
associate-*r/17.5%
neg-mul-117.5%
Simplified17.5%
if 5.5000000000000003e-109 < p Initial program 89.4%
Taylor expanded in x around 0 73.4%
Final simplification33.2%
NOTE: p should be positive before calling this function (FPCore (p x) :precision binary64 (if (<= x -2e-310) (/ (- p) x) (/ p x)))
p = abs(p);
double code(double p, double x) {
double tmp;
if (x <= -2e-310) {
tmp = -p / x;
} else {
tmp = p / x;
}
return tmp;
}
NOTE: p should be positive before calling this function
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2d-310)) then
tmp = -p / x
else
tmp = p / x
end if
code = tmp
end function
p = Math.abs(p);
public static double code(double p, double x) {
double tmp;
if (x <= -2e-310) {
tmp = -p / x;
} else {
tmp = p / x;
}
return tmp;
}
p = abs(p) def code(p, x): tmp = 0 if x <= -2e-310: tmp = -p / x else: tmp = p / x return tmp
p = abs(p) function code(p, x) tmp = 0.0 if (x <= -2e-310) tmp = Float64(Float64(-p) / x); else tmp = Float64(p / x); end return tmp end
p = abs(p) function tmp_2 = code(p, x) tmp = 0.0; if (x <= -2e-310) tmp = -p / x; else tmp = p / x; end tmp_2 = tmp; end
NOTE: p should be positive before calling this function code[p_, x_] := If[LessEqual[x, -2e-310], N[((-p) / x), $MachinePrecision], N[(p / x), $MachinePrecision]]
\begin{array}{l}
p = |p|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-p}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{p}{x}\\
\end{array}
\end{array}
if x < -1.999999999999994e-310Initial program 51.3%
Taylor expanded in x around -inf 26.4%
unpow226.4%
unpow226.4%
Simplified26.4%
Taylor expanded in p around -inf 32.7%
associate-*r/32.7%
neg-mul-132.7%
Simplified32.7%
if -1.999999999999994e-310 < x Initial program 100.0%
Taylor expanded in x around -inf 4.8%
unpow24.8%
unpow24.8%
Simplified4.8%
Taylor expanded in p around 0 3.4%
Final simplification16.3%
NOTE: p should be positive before calling this function (FPCore (p x) :precision binary64 (/ p x))
p = abs(p);
double code(double p, double x) {
return p / x;
}
NOTE: p should be positive before calling this function
real(8) function code(p, x)
real(8), intent (in) :: p
real(8), intent (in) :: x
code = p / x
end function
p = Math.abs(p);
public static double code(double p, double x) {
return p / x;
}
p = abs(p) def code(p, x): return p / x
p = abs(p) function code(p, x) return Float64(p / x) end
p = abs(p) function tmp = code(p, x) tmp = p / x; end
NOTE: p should be positive before calling this function code[p_, x_] := N[(p / x), $MachinePrecision]
\begin{array}{l}
p = |p|\\
\\
\frac{p}{x}
\end{array}
Initial program 78.5%
Taylor expanded in x around -inf 14.4%
unpow214.4%
unpow214.4%
Simplified14.4%
Taylor expanded in p around 0 18.2%
Final simplification18.2%
(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 2023214
(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))))))))