
(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 16 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 (/ x (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-6)
(*
(+
(/ 0.5 x)
(-
(/ 0.3125 (pow x 3.0))
(+ (/ 0.375 (* x x)) (/ 0.2734375 (pow x 4.0)))))
(pow x -0.5))
(*
(pow x -0.5)
(/
(/ (- 1.0 (* t_0 (* t_0 t_0))) (+ 1.0 (pow t_0 1.5)))
(+ 1.0 (+ t_0 (sqrt t_0))))))))
double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / pow(x, 4.0))))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (((1.0 - (t_0 * (t_0 * t_0))) / (1.0 + pow(t_0, 1.5))) / (1.0 + (t_0 + sqrt(t_0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x / (1.0d0 + x)
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 1d-6) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - ((0.375d0 / (x * x)) + (0.2734375d0 / (x ** 4.0d0))))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (((1.0d0 - (t_0 * (t_0 * t_0))) / (1.0d0 + (t_0 ** 1.5d0))) / (1.0d0 + (t_0 + sqrt(t_0))))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / Math.pow(x, 4.0))))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (((1.0 - (t_0 * (t_0 * t_0))) / (1.0 + Math.pow(t_0, 1.5))) / (1.0 + (t_0 + Math.sqrt(t_0))));
}
return tmp;
}
def code(x): t_0 = x / (1.0 + x) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-6: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / math.pow(x, 4.0))))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (((1.0 - (t_0 * (t_0 * t_0))) / (1.0 + math.pow(t_0, 1.5))) / (1.0 + (t_0 + math.sqrt(t_0)))) return tmp
function code(x) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-6) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(Float64(0.375 / Float64(x * x)) + Float64(0.2734375 / (x ^ 4.0))))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(Float64(Float64(1.0 - Float64(t_0 * Float64(t_0 * t_0))) / Float64(1.0 + (t_0 ^ 1.5))) / Float64(1.0 + Float64(t_0 + sqrt(t_0))))); end return tmp end
function tmp_2 = code(x) t_0 = x / (1.0 + x); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - ((0.375 / (x * x)) + (0.2734375 / (x ^ 4.0))))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (((1.0 - (t_0 * (t_0 * t_0))) / (1.0 + (t_0 ^ 1.5))) / (1.0 + (t_0 + sqrt(t_0)))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, 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-6], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.2734375 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(N[(1.0 - N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[t$95$0, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{\frac{1 - t_0 \cdot \left(t_0 \cdot t_0\right)}{1 + {t_0}^{1.5}}}{1 + \left(t_0 + \sqrt{t_0}\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
flip3--99.7%
div-inv99.7%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
flip--99.8%
metadata-eval99.8%
pow-prod-up99.8%
metadata-eval99.8%
+-commutative99.8%
+-commutative99.8%
Applied egg-rr99.8%
cube-mult99.8%
Applied egg-rr99.8%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-6)
(*
(+
(/ 0.5 x)
(-
(/ 0.3125 (pow x 3.0))
(+ (/ 0.375 (* x x)) (/ 0.2734375 (pow x 4.0)))))
(pow x -0.5))
(* (pow x -0.5) (/ (- 1.0 (pow t_0 1.5)) (+ 1.0 (+ t_0 (sqrt t_0))))))))
double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / pow(x, 4.0))))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * ((1.0 - pow(t_0, 1.5)) / (1.0 + (t_0 + sqrt(t_0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x / (1.0d0 + x)
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 1d-6) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - ((0.375d0 / (x * x)) + (0.2734375d0 / (x ** 4.0d0))))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * ((1.0d0 - (t_0 ** 1.5d0)) / (1.0d0 + (t_0 + sqrt(t_0))))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / Math.pow(x, 4.0))))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * ((1.0 - Math.pow(t_0, 1.5)) / (1.0 + (t_0 + Math.sqrt(t_0))));
}
return tmp;
}
def code(x): t_0 = x / (1.0 + x) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-6: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / math.pow(x, 4.0))))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * ((1.0 - math.pow(t_0, 1.5)) / (1.0 + (t_0 + math.sqrt(t_0)))) return tmp
function code(x) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-6) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(Float64(0.375 / Float64(x * x)) + Float64(0.2734375 / (x ^ 4.0))))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(Float64(1.0 - (t_0 ^ 1.5)) / Float64(1.0 + Float64(t_0 + sqrt(t_0))))); end return tmp end
function tmp_2 = code(x) t_0 = x / (1.0 + x); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - ((0.375 / (x * x)) + (0.2734375 / (x ^ 4.0))))) * (x ^ -0.5); else tmp = (x ^ -0.5) * ((1.0 - (t_0 ^ 1.5)) / (1.0 + (t_0 + sqrt(t_0)))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, 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-6], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.2734375 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(1.0 - N[Power[t$95$0, 1.5], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 - {t_0}^{1.5}}{1 + \left(t_0 + \sqrt{t_0}\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
flip3--99.7%
div-inv99.7%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 1e-6)
(*
(+
(/ 0.5 x)
(-
(/ 0.3125 (pow x 3.0))
(+ (/ 0.375 (* x x)) (/ 0.2734375 (pow x 4.0)))))
(pow x -0.5))
(* (pow x -0.5) (- 1.0 (/ (sqrt x) t_0))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / pow(x, 4.0))))) * pow(x, -0.5);
} else {
tmp = pow(x, -0.5) * (1.0 - (sqrt(x) / t_0));
}
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)) <= 1d-6) then
tmp = ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - ((0.375d0 / (x * x)) + (0.2734375d0 / (x ** 4.0d0))))) * (x ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - (sqrt(x) / t_0))
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)) <= 1e-6) {
tmp = ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / Math.pow(x, 4.0))))) * Math.pow(x, -0.5);
} else {
tmp = Math.pow(x, -0.5) * (1.0 - (Math.sqrt(x) / t_0));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 1e-6: tmp = ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - ((0.375 / (x * x)) + (0.2734375 / math.pow(x, 4.0))))) * math.pow(x, -0.5) else: tmp = math.pow(x, -0.5) * (1.0 - (math.sqrt(x) / t_0)) 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)) <= 1e-6) tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(Float64(0.375 / Float64(x * x)) + Float64(0.2734375 / (x ^ 4.0))))) * (x ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(1.0 - Float64(sqrt(x) / t_0))); 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)) <= 1e-6) tmp = ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - ((0.375 / (x * x)) + (0.2734375 / (x ^ 4.0))))) * (x ^ -0.5); else tmp = (x ^ -0.5) * (1.0 - (sqrt(x) / t_0)); 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], 1e-6], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.2734375 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] / t$95$0), $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 10^{-6}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)\right)\right) \cdot {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \frac{\sqrt{x}}{t_0}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
associate-*r/99.6%
metadata-eval99.6%
unpow299.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 1e-6)
(*
(pow x -0.5)
(+ (+ (/ 0.5 x) (/ 0.3125 (pow x 3.0))) (/ -0.375 (* x x))))
(* (pow x -0.5) (- 1.0 (/ (sqrt x) t_0))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 1e-6) {
tmp = pow(x, -0.5) * (((0.5 / x) + (0.3125 / pow(x, 3.0))) + (-0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - (sqrt(x) / t_0));
}
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)) <= 1d-6) then
tmp = (x ** (-0.5d0)) * (((0.5d0 / x) + (0.3125d0 / (x ** 3.0d0))) + ((-0.375d0) / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - (sqrt(x) / t_0))
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)) <= 1e-6) {
tmp = Math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / Math.pow(x, 3.0))) + (-0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - (Math.sqrt(x) / t_0));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 1e-6: tmp = math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / math.pow(x, 3.0))) + (-0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - (math.sqrt(x) / t_0)) 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)) <= 1e-6) tmp = Float64((x ^ -0.5) * Float64(Float64(Float64(0.5 / x) + Float64(0.3125 / (x ^ 3.0))) + Float64(-0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - Float64(sqrt(x) / t_0))); 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)) <= 1e-6) tmp = (x ^ -0.5) * (((0.5 / x) + (0.3125 / (x ^ 3.0))) + (-0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - (sqrt(x) / t_0)); 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], 1e-6], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(N[(0.5 / x), $MachinePrecision] + N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] / t$95$0), $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 10^{-6}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) + \frac{-0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \frac{\sqrt{x}}{t_0}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.4%
associate--l+99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef35.3%
*-commutative35.3%
Applied egg-rr35.3%
expm1-def99.3%
expm1-log1p99.3%
+-lft-identity99.3%
sub-neg99.3%
associate-+r+99.4%
+-commutative99.4%
+-lft-identity99.4%
unpow299.4%
distribute-neg-frac99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-6) (* (pow x -0.5) (+ (/ 0.5 x) (- (/ 0.3125 (pow x 3.0)) (/ 0.375 (* x x))))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) {
tmp = pow(x, -0.5) * ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - (0.375 / (x * x))));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
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-6) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) + ((0.3125d0 / (x ** 3.0d0)) - (0.375d0 / (x * x))))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
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-6) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) + ((0.3125 / Math.pow(x, 3.0)) - (0.375 / (x * x))));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-6: tmp = math.pow(x, -0.5) * ((0.5 / x) + ((0.3125 / math.pow(x, 3.0)) - (0.375 / (x * x)))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-6) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(0.375 / Float64(x * x))))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) tmp = (x ^ -0.5) * ((0.5 / x) + ((0.3125 / (x ^ 3.0)) - (0.375 / (x * x)))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); 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-6], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.4%
associate--l+99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
*-un-lft-identity99.8%
sqrt-undiv99.8%
+-commutative99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 1e-6) (* (pow x -0.5) (+ (+ (/ 0.5 x) (/ 0.3125 (pow x 3.0))) (/ -0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) {
tmp = pow(x, -0.5) * (((0.5 / x) + (0.3125 / pow(x, 3.0))) + (-0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
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-6) then
tmp = (x ** (-0.5d0)) * (((0.5d0 / x) + (0.3125d0 / (x ** 3.0d0))) + ((-0.375d0) / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
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-6) {
tmp = Math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / Math.pow(x, 3.0))) + (-0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 1e-6: tmp = math.pow(x, -0.5) * (((0.5 / x) + (0.3125 / math.pow(x, 3.0))) + (-0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 1e-6) tmp = Float64((x ^ -0.5) * Float64(Float64(Float64(0.5 / x) + Float64(0.3125 / (x ^ 3.0))) + Float64(-0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 1e-6) tmp = (x ^ -0.5) * (((0.5 / x) + (0.3125 / (x ^ 3.0))) + (-0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); 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-6], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(N[(0.5 / x), $MachinePrecision] + N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) + \frac{-0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7Initial program 37.2%
frac-sub37.3%
div-inv37.3%
*-un-lft-identity37.3%
+-commutative37.3%
*-rgt-identity37.3%
metadata-eval37.3%
frac-times37.3%
un-div-inv37.3%
pow1/237.3%
pow-flip37.3%
metadata-eval37.3%
+-commutative37.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-rgt-identity37.3%
times-frac37.3%
div-sub37.2%
*-inverses37.2%
/-rgt-identity37.2%
Simplified37.2%
Taylor expanded in x around inf 99.4%
associate--l+99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef35.3%
*-commutative35.3%
Applied egg-rr35.3%
expm1-def99.3%
expm1-log1p99.3%
+-lft-identity99.3%
sub-neg99.3%
associate-+r+99.4%
+-commutative99.4%
+-lft-identity99.4%
unpow299.4%
distribute-neg-frac99.4%
metadata-eval99.4%
unpow299.4%
Simplified99.4%
if 9.99999999999999955e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
frac-sub99.4%
div-inv99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-rgt-identity99.5%
metadata-eval99.5%
frac-times99.5%
un-div-inv99.5%
pow1/299.5%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
times-frac99.8%
div-sub99.8%
*-inverses99.8%
/-rgt-identity99.8%
Simplified99.8%
*-un-lft-identity99.8%
sqrt-undiv99.8%
+-commutative99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 5e-9) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x)))) (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 5e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
}
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)))) <= 5d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
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)))) <= 5e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 5e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x)))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 5e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 5e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x)))); 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], 5e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 5.0000000000000001e-9Initial program 36.6%
frac-sub36.6%
div-inv36.6%
*-un-lft-identity36.6%
+-commutative36.6%
*-rgt-identity36.6%
metadata-eval36.6%
frac-times36.6%
un-div-inv36.6%
pow1/236.6%
pow-flip36.6%
metadata-eval36.6%
+-commutative36.6%
Applied egg-rr36.6%
associate-*r/36.6%
*-rgt-identity36.6%
times-frac36.6%
div-sub36.5%
*-inverses36.5%
/-rgt-identity36.5%
Simplified36.5%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
if 5.0000000000000001e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.1%
frac-sub99.1%
div-inv99.2%
*-un-lft-identity99.2%
+-commutative99.2%
*-rgt-identity99.2%
metadata-eval99.2%
frac-times99.2%
un-div-inv99.2%
pow1/299.2%
pow-flip99.4%
metadata-eval99.4%
+-commutative99.4%
Applied egg-rr99.4%
associate-*r/99.4%
*-rgt-identity99.4%
times-frac99.5%
div-sub99.5%
*-inverses99.5%
/-rgt-identity99.5%
Simplified99.5%
*-un-lft-identity99.5%
sqrt-undiv99.4%
+-commutative99.4%
Applied egg-rr99.4%
*-lft-identity99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (sqrt (+ 1.0 x)))))
(if (<= (+ (/ 1.0 (sqrt x)) t_0) 5e-9)
(* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))
(+ (pow x -0.5) t_0))))
double code(double x) {
double t_0 = -1.0 / sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + t_0) <= 5e-9) {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = pow(x, -0.5) + t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) / sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + t_0) <= 5d-9) then
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
else
tmp = (x ** (-0.5d0)) + t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = -1.0 / Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + t_0) <= 5e-9) {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
} else {
tmp = Math.pow(x, -0.5) + t_0;
}
return tmp;
}
def code(x): t_0 = -1.0 / math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + t_0) <= 5e-9: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) else: tmp = math.pow(x, -0.5) + t_0 return tmp
function code(x) t_0 = Float64(-1.0 / sqrt(Float64(1.0 + x))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + t_0) <= 5e-9) tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); else tmp = Float64((x ^ -0.5) + t_0); end return tmp end
function tmp_2 = code(x) t_0 = -1.0 / sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + t_0) <= 5e-9) tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); else tmp = (x ^ -0.5) + t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], 5e-9], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_0 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} + t_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 5.0000000000000001e-9Initial program 36.6%
frac-sub36.6%
div-inv36.6%
*-un-lft-identity36.6%
+-commutative36.6%
*-rgt-identity36.6%
metadata-eval36.6%
frac-times36.6%
un-div-inv36.6%
pow1/236.6%
pow-flip36.6%
metadata-eval36.6%
+-commutative36.6%
Applied egg-rr36.6%
associate-*r/36.6%
*-rgt-identity36.6%
times-frac36.6%
div-sub36.5%
*-inverses36.5%
/-rgt-identity36.5%
Simplified36.5%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
if 5.0000000000000001e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.1%
add-log-exp5.8%
*-un-lft-identity5.8%
log-prod5.8%
metadata-eval5.8%
add-log-exp95.7%
pow1/295.7%
pow-flip96.0%
metadata-eval96.0%
Applied egg-rr99.4%
+-lft-identity96.0%
Simplified99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 150000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 150000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 150000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 150000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 150000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 150000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 150000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 150000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 150000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\end{array}
\end{array}
if x < 1.5e5Initial program 99.1%
*-un-lft-identity99.1%
clear-num99.1%
associate-/r/99.1%
prod-diff99.1%
*-un-lft-identity99.1%
fma-neg99.1%
*-un-lft-identity99.1%
inv-pow99.1%
sqrt-pow299.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.4%
+-commutative99.4%
metadata-eval99.4%
Applied egg-rr99.4%
fma-udef99.4%
distribute-lft1-in99.4%
metadata-eval99.4%
mul0-lft99.4%
+-rgt-identity99.4%
Simplified99.4%
if 1.5e5 < x Initial program 36.6%
frac-sub36.6%
div-inv36.6%
*-un-lft-identity36.6%
+-commutative36.6%
*-rgt-identity36.6%
metadata-eval36.6%
frac-times36.6%
un-div-inv36.6%
pow1/236.6%
pow-flip36.6%
metadata-eval36.6%
+-commutative36.6%
Applied egg-rr36.6%
associate-*r/36.6%
*-rgt-identity36.6%
times-frac36.6%
div-sub36.5%
*-inverses36.5%
/-rgt-identity36.5%
Simplified36.5%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
associate-*r/99.3%
metadata-eval99.3%
unpow299.3%
Simplified99.3%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 1.45) (+ (pow x -0.5) (/ -1.0 (+ 1.0 (* x 0.5)))) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.45) {
tmp = pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.45d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) / (1.0d0 + (x * 0.5d0)))
else
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.45) {
tmp = Math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5)));
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.45: tmp = math.pow(x, -0.5) + (-1.0 / (1.0 + (x * 0.5))) else: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.45) tmp = Float64((x ^ -0.5) + Float64(-1.0 / Float64(1.0 + Float64(x * 0.5)))); else tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.45) tmp = (x ^ -0.5) + (-1.0 / (1.0 + (x * 0.5))); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.45], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.45:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\end{array}
\end{array}
if x < 1.44999999999999996Initial program 99.7%
Taylor expanded in x around 0 98.3%
add-log-exp5.6%
*-un-lft-identity5.6%
log-prod5.6%
metadata-eval5.6%
add-log-exp98.3%
pow1/298.3%
pow-flip98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
if 1.44999999999999996 < x Initial program 38.0%
frac-sub38.0%
div-inv38.0%
*-un-lft-identity38.0%
+-commutative38.0%
*-rgt-identity38.0%
metadata-eval38.0%
frac-times38.0%
un-div-inv38.0%
pow1/238.0%
pow-flip38.0%
metadata-eval38.0%
+-commutative38.0%
Applied egg-rr38.0%
associate-*r/38.0%
*-rgt-identity38.0%
times-frac38.0%
div-sub38.0%
*-inverses38.0%
/-rgt-identity38.0%
Simplified38.0%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
associate-*r/98.0%
metadata-eval98.0%
unpow298.0%
Simplified98.0%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x 1.7) (+ (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.7) {
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.7d0) 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.7) {
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.7: 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.7) 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.7) 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.7], 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.7:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.7%
Taylor expanded in x around 0 98.3%
add-log-exp5.6%
*-un-lft-identity5.6%
log-prod5.6%
metadata-eval5.6%
add-log-exp98.3%
pow1/298.3%
pow-flip98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
if 1.69999999999999996 < x Initial program 38.0%
*-un-lft-identity38.0%
clear-num38.0%
associate-/r/38.0%
prod-diff38.0%
*-un-lft-identity38.0%
fma-neg38.0%
*-un-lft-identity38.0%
inv-pow38.0%
sqrt-pow231.2%
metadata-eval31.2%
pow1/231.2%
pow-flip38.1%
+-commutative38.1%
metadata-eval38.1%
Applied egg-rr38.1%
fma-udef38.1%
distribute-lft1-in38.1%
metadata-eval38.1%
mul0-lft38.1%
+-rgt-identity38.1%
Simplified38.1%
Taylor expanded in x around inf 65.8%
expm1-log1p-u65.8%
expm1-udef34.8%
pow-flip34.8%
metadata-eval34.8%
Applied egg-rr34.8%
expm1-def66.8%
expm1-log1p66.8%
unpow1/266.8%
exp-to-pow64.4%
*-commutative64.4%
exp-prod90.3%
*-commutative90.3%
associate-*l*90.3%
metadata-eval90.3%
exp-to-pow96.2%
Simplified96.2%
Final simplification97.4%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) + (-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.0d0) then
tmp = (x ** (-0.5d0)) + ((-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.0) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} 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) + (-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.0) tmp = Float64((x ^ -0.5) + 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.0) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.7%
*-un-lft-identity99.7%
clear-num99.7%
associate-/r/99.7%
prod-diff99.7%
*-un-lft-identity99.7%
fma-neg99.7%
*-un-lft-identity99.7%
inv-pow99.7%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 38.0%
*-un-lft-identity38.0%
clear-num38.0%
associate-/r/38.0%
prod-diff38.0%
*-un-lft-identity38.0%
fma-neg38.0%
*-un-lft-identity38.0%
inv-pow38.0%
sqrt-pow231.2%
metadata-eval31.2%
pow1/231.2%
pow-flip38.1%
+-commutative38.1%
metadata-eval38.1%
Applied egg-rr38.1%
fma-udef38.1%
distribute-lft1-in38.1%
metadata-eval38.1%
mul0-lft38.1%
+-rgt-identity38.1%
Simplified38.1%
Taylor expanded in x around inf 65.8%
expm1-log1p-u65.8%
expm1-udef34.8%
pow-flip34.8%
metadata-eval34.8%
Applied egg-rr34.8%
expm1-def66.8%
expm1-log1p66.8%
unpow1/266.8%
exp-to-pow64.4%
*-commutative64.4%
exp-prod90.3%
*-commutative90.3%
associate-*l*90.3%
metadata-eval90.3%
exp-to-pow96.2%
Simplified96.2%
Final simplification97.4%
(FPCore (x) :precision binary64 (if (<= x 0.25) (* (pow x -0.5) 2.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.25) {
tmp = pow(x, -0.5) * 2.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.25d0) then
tmp = (x ** (-0.5d0)) * 2.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.25) {
tmp = Math.pow(x, -0.5) * 2.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.25: tmp = math.pow(x, -0.5) * 2.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.25) tmp = Float64((x ^ -0.5) * 2.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.25) tmp = (x ^ -0.5) * 2.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.25], N[(N[Power[x, -0.5], $MachinePrecision] * 2.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.25:\\
\;\;\;\;{x}^{-0.5} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.25Initial program 99.7%
frac-sub99.7%
div-inv99.7%
*-un-lft-identity99.7%
+-commutative99.7%
*-rgt-identity99.7%
metadata-eval99.7%
frac-times99.7%
un-div-inv99.7%
pow1/299.7%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around -inf 0.0%
unpow20.0%
rem-square-sqrt18.7%
metadata-eval18.7%
Simplified18.7%
if 0.25 < x Initial program 38.0%
*-un-lft-identity38.0%
clear-num38.0%
associate-/r/38.0%
prod-diff38.0%
*-un-lft-identity38.0%
fma-neg38.0%
*-un-lft-identity38.0%
inv-pow38.0%
sqrt-pow231.2%
metadata-eval31.2%
pow1/231.2%
pow-flip38.1%
+-commutative38.1%
metadata-eval38.1%
Applied egg-rr38.1%
fma-udef38.1%
distribute-lft1-in38.1%
metadata-eval38.1%
mul0-lft38.1%
+-rgt-identity38.1%
Simplified38.1%
Taylor expanded in x around inf 65.8%
expm1-log1p-u65.8%
expm1-udef34.8%
pow-flip34.8%
metadata-eval34.8%
Applied egg-rr34.8%
expm1-def66.8%
expm1-log1p66.8%
unpow1/266.8%
exp-to-pow64.4%
*-commutative64.4%
exp-prod90.3%
*-commutative90.3%
associate-*l*90.3%
metadata-eval90.3%
exp-to-pow96.2%
Simplified96.2%
Final simplification58.1%
(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}
if x < 0.680000000000000049Initial program 99.7%
*-un-lft-identity99.7%
clear-num99.7%
associate-/r/99.7%
prod-diff99.7%
*-un-lft-identity99.7%
fma-neg99.7%
*-un-lft-identity99.7%
inv-pow99.7%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
if 0.680000000000000049 < x Initial program 38.0%
*-un-lft-identity38.0%
clear-num38.0%
associate-/r/38.0%
prod-diff38.0%
*-un-lft-identity38.0%
fma-neg38.0%
*-un-lft-identity38.0%
inv-pow38.0%
sqrt-pow231.2%
metadata-eval31.2%
pow1/231.2%
pow-flip38.1%
+-commutative38.1%
metadata-eval38.1%
Applied egg-rr38.1%
fma-udef38.1%
distribute-lft1-in38.1%
metadata-eval38.1%
mul0-lft38.1%
+-rgt-identity38.1%
Simplified38.1%
Taylor expanded in x around inf 65.8%
expm1-log1p-u65.8%
expm1-udef34.8%
pow-flip34.8%
metadata-eval34.8%
Applied egg-rr34.8%
expm1-def66.8%
expm1-log1p66.8%
unpow1/266.8%
exp-to-pow64.4%
*-commutative64.4%
exp-prod90.3%
*-commutative90.3%
associate-*l*90.3%
metadata-eval90.3%
exp-to-pow96.2%
Simplified96.2%
Final simplification97.1%
(FPCore (x) :precision binary64 (* 0.5 (pow x -1.5)))
double code(double x) {
return 0.5 * pow(x, -1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * (x ** (-1.5d0))
end function
public static double code(double x) {
return 0.5 * Math.pow(x, -1.5);
}
def code(x): return 0.5 * math.pow(x, -1.5)
function code(x) return Float64(0.5 * (x ^ -1.5)) end
function tmp = code(x) tmp = 0.5 * (x ^ -1.5); end
code[x_] := N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot {x}^{-1.5}
\end{array}
Initial program 68.3%
*-un-lft-identity68.3%
clear-num68.3%
associate-/r/68.3%
prod-diff68.3%
*-un-lft-identity68.3%
fma-neg68.3%
*-un-lft-identity68.3%
inv-pow68.3%
sqrt-pow265.0%
metadata-eval65.0%
pow1/265.0%
pow-flip68.5%
+-commutative68.5%
metadata-eval68.5%
Applied egg-rr68.5%
fma-udef68.5%
distribute-lft1-in68.5%
metadata-eval68.5%
mul0-lft68.5%
+-rgt-identity68.5%
Simplified68.5%
Taylor expanded in x around inf 36.0%
expm1-log1p-u36.0%
expm1-udef20.3%
pow-flip20.3%
metadata-eval20.3%
Applied egg-rr20.3%
expm1-def36.5%
expm1-log1p36.5%
unpow1/236.5%
exp-to-pow35.3%
*-commutative35.3%
exp-prod48.6%
*-commutative48.6%
associate-*l*48.6%
metadata-eval48.6%
exp-to-pow51.6%
Simplified51.6%
Final simplification51.6%
(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}
Initial program 68.3%
Taylor expanded in x around 0 49.4%
Taylor expanded in x around inf 1.9%
Final simplification1.9%
(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 2023229
(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)))))