
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 t_0)) 0.0)
(* 0.5 (pow x -1.5))
(/ (/ 1.0 (+ (sqrt x) t_0)) (sqrt (* x (+ 1.0 x)))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - (1.0d0 / t_0)) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = (1.0d0 / (sqrt(x) + t_0)) / sqrt((x * (1.0d0 + x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / t_0)) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / Math.sqrt((x * (1.0 + x)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / t_0)) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = (1.0 / (math.sqrt(x) + t_0)) / math.sqrt((x * (1.0 + x))) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / t_0)) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{t_0} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 t_0)) 2e-10)
(/ (/ 1.0 (+ (sqrt x) t_0)) (+ 0.5 (- x (/ 0.125 x))))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (sqrt(x) + t_0)) / (0.5 + (x - (0.125 / x)));
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - (1.0d0 / t_0)) <= 2d-10) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (0.5d0 + (x - (0.125d0 / x)))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (0.5 + (x - (0.125 / x)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / t_0)) <= 2e-10: tmp = (1.0 / (math.sqrt(x) + t_0)) / (0.5 + (x - (0.125 / x))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / t_0)) <= 2e-10) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(0.5 + Float64(x - Float64(0.125 / x)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 2e-10) tmp = (1.0 / (sqrt(x) + t_0)) / (0.5 + (x - (0.125 / x))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-10], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(0.5 + N[(x - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{t_0} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{0.5 + \left(x - \frac{0.125}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 t_0)) 2e-10)
(/ (/ 1.0 (+ (sqrt x) t_0)) (+ x 0.5))
(- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (sqrt(x) + t_0)) / (x + 0.5);
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) - (1.0d0 / t_0)) <= 2d-10) then
tmp = (1.0d0 / (sqrt(x) + t_0)) / (x + 0.5d0)
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / t_0)) <= 2e-10) {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / (x + 0.5);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / t_0)) <= 2e-10: tmp = (1.0 / (math.sqrt(x) + t_0)) / (x + 0.5) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / t_0)) <= 2e-10) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x + 0.5)); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / t_0)) <= 2e-10) tmp = (1.0 / (sqrt(x) + t_0)) / (x + 0.5); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2e-10], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + 0.5), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{t_0} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{x + 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ 1.0 x)))) 1e-19) (* 0.5 (pow x -1.5)) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 1e-19) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((1.0d0 + x)))) <= 1d-19) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((1.0 + x)))) <= 1e-19) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((1.0 + x)))) <= 1e-19: tmp = 0.5 * math.pow(x, -1.5) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(1.0 + x)))) <= 1e-19) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 1e-19) tmp = 0.5 * (x ^ -1.5); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-19], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-19}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (/ (/ 1.0 (hypot (sqrt x) x)) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.hypot(Math.sqrt(x), x)) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return (1.0 / math.hypot(math.sqrt(x), x)) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(1.0 / hypot(sqrt(x), x)) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 1.68) (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5)))) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.68) {
tmp = pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.68d0) then
tmp = (x ** (-0.5d0)) - (1.0d0 / (1.0d0 + (x * 0.5d0)))
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.68) {
tmp = Math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.68: tmp = math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5))) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.68) tmp = Float64((x ^ -0.5) - Float64(1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.68) tmp = (x ^ -0.5) - (1.0 / (1.0 + (x * 0.5))); else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.68], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.68:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.5) (pow x -0.5) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = pow(x, -0.5);
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.5d0) then
tmp = x ** (-0.5d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.5: tmp = math.pow(x, -0.5) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.5) tmp = x ^ -0.5; else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.5) tmp = x ^ -0.5; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.5], N[Power[x, -0.5], $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(x, -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
(FPCore (x) :precision binary64 (* x 0.5))
double code(double x) {
return x * 0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * 0.5d0
end function
public static double code(double x) {
return x * 0.5;
}
def code(x): return x * 0.5
function code(x) return Float64(x * 0.5) end
function tmp = code(x) tmp = x * 0.5; end
code[x_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x): return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x) return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0)))); end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}
herbie shell --seed 2023348
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))