
(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 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 1e-10)
(* (pow (+ 1.0 x) -0.5) (/ 1.0 (- (+ 0.5 (* x 2.0)) (/ 0.125 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-10) {
tmp = pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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-10) then
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / ((0.5d0 + (x * 2.0d0)) - (0.125d0 / 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-10) {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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-10: tmp = math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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-10) tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(Float64(0.5 + Float64(x * 2.0)) - Float64(0.125 / 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-10) tmp = ((1.0 + x) ^ -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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-10], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(N[(0.5 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] - N[(0.125 / 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^{-10}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{\left(0.5 + x \cdot 2\right) - \frac{0.125}{x}}\\
\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)))) < 1.00000000000000004e-10Initial program 41.9%
frac-sub42.0%
associate-/r*42.0%
*-un-lft-identity42.0%
*-rgt-identity42.0%
+-commutative42.0%
+-commutative42.0%
Applied egg-rr42.0%
flip--42.7%
div-inv42.7%
add-sqr-sqrt24.7%
+-commutative24.7%
add-sqr-sqrt44.4%
associate--l+44.4%
+-commutative44.4%
+-commutative44.4%
Applied egg-rr44.4%
associate-*r/44.4%
*-rgt-identity44.4%
associate-+r-44.4%
+-commutative44.4%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod82.9%
+-commutative82.9%
Applied egg-rr82.9%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
if 1.00000000000000004e-10 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.5%
frac-sub99.5%
*-un-lft-identity99.5%
*-rgt-identity99.5%
+-commutative99.5%
sqrt-unprod99.5%
+-commutative99.5%
Applied egg-rr99.5%
*-un-lft-identity99.5%
sqrt-prod99.5%
times-frac99.6%
pow1/299.6%
pow-flip99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
Applied egg-rr99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0) (* 0.5 (pow x -1.5)) (* (pow (+ 1.0 x) -0.5) (/ 1.0 (+ x (sqrt (* x (+ 1.0 x))))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = pow((1.0 + x), -0.5) * (1.0 / (x + 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)))) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / (x + 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)))) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / (x + 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)))) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = math.pow((1.0 + x), -0.5) * (1.0 / (x + 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)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(x + 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)))) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = ((1.0 + x) ^ -0.5) * (1.0 / (x + 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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(x + N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{x + \sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 41.8%
*-un-lft-identity41.8%
clear-num41.8%
associate-/r/41.8%
prod-diff41.8%
*-un-lft-identity41.8%
fma-neg41.8%
*-un-lft-identity41.8%
pow1/241.8%
pow-flip31.3%
metadata-eval31.3%
pow1/231.3%
pow-flip41.8%
+-commutative41.8%
metadata-eval41.8%
Applied egg-rr41.8%
+-commutative41.8%
sub-neg41.8%
fma-udef41.8%
distribute-lft1-in41.8%
metadata-eval41.8%
mul0-lft41.8%
+-commutative41.8%
associate-+r+41.8%
sub-neg41.8%
neg-sub041.8%
+-commutative41.8%
sub-neg41.8%
Simplified41.8%
add-exp-log5.5%
log-pow5.5%
log1p-udef5.5%
Applied egg-rr5.5%
Taylor expanded in x around inf 74.7%
unpow-174.7%
exp-to-pow72.1%
*-commutative72.1%
log-pow72.1%
associate-*r*72.1%
metadata-eval72.1%
*-commutative72.1%
exp-to-pow75.0%
metadata-eval75.0%
pow-sqr75.1%
rem-sqrt-square100.0%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 96.9%
frac-sub97.0%
associate-/r*97.0%
*-un-lft-identity97.0%
*-rgt-identity97.0%
+-commutative97.0%
+-commutative97.0%
Applied egg-rr97.0%
flip--97.8%
div-inv97.8%
add-sqr-sqrt98.7%
+-commutative98.7%
add-sqr-sqrt99.6%
associate--l+99.6%
+-commutative99.6%
+-commutative99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
associate-+r-99.6%
+-commutative99.6%
associate--l+99.6%
Simplified99.6%
clear-num99.5%
+-commutative99.5%
associate-/r/99.6%
inv-pow99.6%
sqrt-pow299.6%
metadata-eval99.6%
+-commutative99.6%
associate-/l/99.6%
+-inverses99.6%
metadata-eval99.6%
distribute-lft-in99.6%
add-sqr-sqrt99.6%
sqrt-unprod99.6%
+-commutative99.6%
Applied egg-rr99.6%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0) (* 0.5 (pow x -1.5)) (/ (pow (+ 1.0 x) -0.5) (+ x (sqrt (* x (+ 1.0 x)))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = pow((1.0 + x), -0.5) / (x + 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)))) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = ((1.0d0 + x) ** (-0.5d0)) / (x + 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)))) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = Math.pow((1.0 + x), -0.5) / (x + 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)))) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = math.pow((1.0 + x), -0.5) / (x + 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)))) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64((Float64(1.0 + x) ^ -0.5) / Float64(x + 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)))) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = ((1.0 + x) ^ -0.5) / (x + 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], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x + 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 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(1 + x\right)}^{-0.5}}{x + \sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 41.8%
*-un-lft-identity41.8%
clear-num41.8%
associate-/r/41.8%
prod-diff41.8%
*-un-lft-identity41.8%
fma-neg41.8%
*-un-lft-identity41.8%
pow1/241.8%
pow-flip31.3%
metadata-eval31.3%
pow1/231.3%
pow-flip41.8%
+-commutative41.8%
metadata-eval41.8%
Applied egg-rr41.8%
+-commutative41.8%
sub-neg41.8%
fma-udef41.8%
distribute-lft1-in41.8%
metadata-eval41.8%
mul0-lft41.8%
+-commutative41.8%
associate-+r+41.8%
sub-neg41.8%
neg-sub041.8%
+-commutative41.8%
sub-neg41.8%
Simplified41.8%
add-exp-log5.5%
log-pow5.5%
log1p-udef5.5%
Applied egg-rr5.5%
Taylor expanded in x around inf 74.7%
unpow-174.7%
exp-to-pow72.1%
*-commutative72.1%
log-pow72.1%
associate-*r*72.1%
metadata-eval72.1%
*-commutative72.1%
exp-to-pow75.0%
metadata-eval75.0%
pow-sqr75.1%
rem-sqrt-square100.0%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 96.9%
frac-sub97.0%
associate-/r*97.0%
*-un-lft-identity97.0%
*-rgt-identity97.0%
+-commutative97.0%
+-commutative97.0%
Applied egg-rr97.0%
flip--97.8%
div-inv97.8%
add-sqr-sqrt98.7%
+-commutative98.7%
add-sqr-sqrt99.6%
associate--l+99.6%
+-commutative99.6%
+-commutative99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
associate-+r-99.6%
+-commutative99.6%
associate--l+99.6%
Simplified99.6%
expm1-log1p-u92.6%
expm1-udef88.7%
Applied egg-rr88.7%
expm1-def92.6%
expm1-log1p99.6%
+-commutative99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (sqrt (+ 1.0 x)))))
(if (<= (+ (/ 1.0 (sqrt x)) t_0) 1e-10)
(* (pow (+ 1.0 x) -0.5) (/ 1.0 (- (+ 0.5 (* x 2.0)) (/ 0.125 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) <= 1e-10) {
tmp = pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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) <= 1d-10) then
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / ((0.5d0 + (x * 2.0d0)) - (0.125d0 / 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) <= 1e-10) {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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) <= 1e-10: tmp = math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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) <= 1e-10) tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(Float64(0.5 + Float64(x * 2.0)) - Float64(0.125 / 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) <= 1e-10) tmp = ((1.0 + x) ^ -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / 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], 1e-10], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(N[(0.5 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] - N[(0.125 / 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 10^{-10}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{\left(0.5 + x \cdot 2\right) - \frac{0.125}{x}}\\
\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)))) < 1.00000000000000004e-10Initial program 41.9%
frac-sub42.0%
associate-/r*42.0%
*-un-lft-identity42.0%
*-rgt-identity42.0%
+-commutative42.0%
+-commutative42.0%
Applied egg-rr42.0%
flip--42.7%
div-inv42.7%
add-sqr-sqrt24.7%
+-commutative24.7%
add-sqr-sqrt44.4%
associate--l+44.4%
+-commutative44.4%
+-commutative44.4%
Applied egg-rr44.4%
associate-*r/44.4%
*-rgt-identity44.4%
associate-+r-44.4%
+-commutative44.4%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod82.9%
+-commutative82.9%
Applied egg-rr82.9%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
if 1.00000000000000004e-10 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.5%
expm1-log1p-u92.2%
expm1-udef92.1%
pow1/292.1%
pow-flip92.1%
metadata-eval92.1%
Applied egg-rr92.1%
expm1-def92.2%
expm1-log1p99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ 1.0 x)))) (/ (/ (/ (+ 1.0 (- x x)) (+ (sqrt x) t_0)) (sqrt x)) t_0)))
double code(double x) {
double t_0 = sqrt((1.0 + x));
return (((1.0 + (x - x)) / (sqrt(x) + t_0)) / sqrt(x)) / t_0;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sqrt((1.0d0 + x))
code = (((1.0d0 + (x - x)) / (sqrt(x) + t_0)) / sqrt(x)) / t_0
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
return (((1.0 + (x - x)) / (Math.sqrt(x) + t_0)) / Math.sqrt(x)) / t_0;
}
def code(x): t_0 = math.sqrt((1.0 + x)) return (((1.0 + (x - x)) / (math.sqrt(x) + t_0)) / math.sqrt(x)) / t_0
function code(x) t_0 = sqrt(Float64(1.0 + x)) return Float64(Float64(Float64(Float64(1.0 + Float64(x - x)) / Float64(sqrt(x) + t_0)) / sqrt(x)) / t_0) end
function tmp = code(x) t_0 = sqrt((1.0 + x)); tmp = (((1.0 + (x - x)) / (sqrt(x) + t_0)) / sqrt(x)) / t_0; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\frac{\frac{\frac{1 + \left(x - x\right)}{\sqrt{x} + t_0}}{\sqrt{x}}}{t_0}
\end{array}
\end{array}
Initial program 69.3%
frac-sub69.4%
associate-/r*69.4%
*-un-lft-identity69.4%
*-rgt-identity69.4%
+-commutative69.4%
+-commutative69.4%
Applied egg-rr69.4%
flip--69.8%
div-inv69.8%
add-sqr-sqrt60.4%
+-commutative60.4%
add-sqr-sqrt70.7%
associate--l+70.7%
+-commutative70.7%
+-commutative70.7%
Applied egg-rr70.7%
associate-*r/70.7%
*-rgt-identity70.7%
associate-+r-70.7%
+-commutative70.7%
associate--l+99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (+ 1.0 x) -0.5)))
(if (<= x 4500.0)
(- (pow x -0.5) t_0)
(* t_0 (/ 1.0 (- (+ 0.5 (* x 2.0)) (/ 0.125 x)))))))
double code(double x) {
double t_0 = pow((1.0 + x), -0.5);
double tmp;
if (x <= 4500.0) {
tmp = pow(x, -0.5) - t_0;
} else {
tmp = t_0 * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + x) ** (-0.5d0)
if (x <= 4500.0d0) then
tmp = (x ** (-0.5d0)) - t_0
else
tmp = t_0 * (1.0d0 / ((0.5d0 + (x * 2.0d0)) - (0.125d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.pow((1.0 + x), -0.5);
double tmp;
if (x <= 4500.0) {
tmp = Math.pow(x, -0.5) - t_0;
} else {
tmp = t_0 * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x)));
}
return tmp;
}
def code(x): t_0 = math.pow((1.0 + x), -0.5) tmp = 0 if x <= 4500.0: tmp = math.pow(x, -0.5) - t_0 else: tmp = t_0 * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x))) return tmp
function code(x) t_0 = Float64(1.0 + x) ^ -0.5 tmp = 0.0 if (x <= 4500.0) tmp = Float64((x ^ -0.5) - t_0); else tmp = Float64(t_0 * Float64(1.0 / Float64(Float64(0.5 + Float64(x * 2.0)) - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) t_0 = (1.0 + x) ^ -0.5; tmp = 0.0; if (x <= 4500.0) tmp = (x ^ -0.5) - t_0; else tmp = t_0 * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[x, 4500.0], N[(N[Power[x, -0.5], $MachinePrecision] - t$95$0), $MachinePrecision], N[(t$95$0 * N[(1.0 / N[(N[(0.5 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + x\right)}^{-0.5}\\
\mathbf{if}\;x \leq 4500:\\
\;\;\;\;{x}^{-0.5} - t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{\left(0.5 + x \cdot 2\right) - \frac{0.125}{x}}\\
\end{array}
\end{array}
if x < 4500Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
pow-flip99.8%
metadata-eval99.8%
pow1/299.8%
pow-flip99.8%
+-commutative99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-commutative99.8%
sub-neg99.8%
fma-udef99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
mul0-lft99.8%
+-commutative99.8%
associate-+r+99.8%
sub-neg99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if 4500 < x Initial program 41.9%
frac-sub42.0%
associate-/r*42.0%
*-un-lft-identity42.0%
*-rgt-identity42.0%
+-commutative42.0%
+-commutative42.0%
Applied egg-rr42.0%
flip--42.7%
div-inv42.7%
add-sqr-sqrt24.7%
+-commutative24.7%
add-sqr-sqrt44.4%
associate--l+44.4%
+-commutative44.4%
+-commutative44.4%
Applied egg-rr44.4%
associate-*r/44.4%
*-rgt-identity44.4%
associate-+r-44.4%
+-commutative44.4%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod82.9%
+-commutative82.9%
Applied egg-rr82.9%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (<= x 0.56) (+ (pow x -0.5) (- -1.0 (* x (+ -0.5 (* x 0.375))))) (* (pow (+ 1.0 x) -0.5) (/ 1.0 (- (+ 0.5 (* x 2.0)) (/ 0.125 x))))))
double code(double x) {
double tmp;
if (x <= 0.56) {
tmp = pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375))));
} else {
tmp = pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.56d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * ((-0.5d0) + (x * 0.375d0))))
else
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / ((0.5d0 + (x * 2.0d0)) - (0.125d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.56) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375))));
} else {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.56: tmp = math.pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375)))) else: tmp = math.pow((1.0 + x), -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x))) return tmp
function code(x) tmp = 0.0 if (x <= 0.56) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * Float64(-0.5 + Float64(x * 0.375))))); else tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(Float64(0.5 + Float64(x * 2.0)) - Float64(0.125 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.56) tmp = (x ^ -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375)))); else tmp = ((1.0 + x) ^ -0.5) * (1.0 / ((0.5 + (x * 2.0)) - (0.125 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.56], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * N[(-0.5 + N[(x * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(N[(0.5 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.56:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot \left(-0.5 + x \cdot 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{\left(0.5 + x \cdot 2\right) - \frac{0.125}{x}}\\
\end{array}
\end{array}
if x < 0.56000000000000005Initial program 99.6%
expm1-log1p-u92.2%
expm1-udef92.2%
pow1/292.2%
pow-flip92.2%
metadata-eval92.2%
Applied egg-rr92.2%
expm1-def92.2%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
*-commutative98.8%
unpow298.8%
associate-*l*98.8%
distribute-lft-out98.8%
Simplified98.8%
if 0.56000000000000005 < x Initial program 42.6%
frac-sub42.8%
associate-/r*42.8%
*-un-lft-identity42.8%
*-rgt-identity42.8%
+-commutative42.8%
+-commutative42.8%
Applied egg-rr42.8%
flip--43.6%
div-inv43.6%
add-sqr-sqrt25.8%
+-commutative25.8%
add-sqr-sqrt45.2%
associate--l+45.2%
+-commutative45.2%
+-commutative45.2%
Applied egg-rr45.2%
associate-*r/45.2%
*-rgt-identity45.2%
associate-+r-45.2%
+-commutative45.2%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod83.1%
+-commutative83.1%
Applied egg-rr83.1%
Taylor expanded in x around inf 99.1%
*-commutative99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (<= x 0.48) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (* (pow (+ 1.0 x) -0.5) (/ 1.0 (+ x (+ x 0.5))))))
double code(double x) {
double tmp;
if (x <= 0.48) {
tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.48d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
else
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / (x + (x + 0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.48) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
} else {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.48: tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5)) else: tmp = math.pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5))) return tmp
function code(x) tmp = 0.0 if (x <= 0.48) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5))); else tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(x + Float64(x + 0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.48) tmp = (x ^ -0.5) + (-1.0 - (x * -0.5)); else tmp = ((1.0 + x) ^ -0.5) * (1.0 / (x + (x + 0.5))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.48], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(x + N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.48:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{x + \left(x + 0.5\right)}\\
\end{array}
\end{array}
if x < 0.47999999999999998Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
Simplified98.7%
if 0.47999999999999998 < x Initial program 42.6%
frac-sub42.8%
associate-/r*42.8%
*-un-lft-identity42.8%
*-rgt-identity42.8%
+-commutative42.8%
+-commutative42.8%
Applied egg-rr42.8%
flip--43.6%
div-inv43.6%
add-sqr-sqrt25.8%
+-commutative25.8%
add-sqr-sqrt45.2%
associate--l+45.2%
+-commutative45.2%
+-commutative45.2%
Applied egg-rr45.2%
associate-*r/45.2%
*-rgt-identity45.2%
associate-+r-45.2%
+-commutative45.2%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod83.1%
+-commutative83.1%
Applied egg-rr83.1%
Taylor expanded in x around inf 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (if (<= x 0.56) (+ (pow x -0.5) (- -1.0 (* x (+ -0.5 (* x 0.375))))) (* (pow (+ 1.0 x) -0.5) (/ 1.0 (+ x (+ x 0.5))))))
double code(double x) {
double tmp;
if (x <= 0.56) {
tmp = pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375))));
} else {
tmp = pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.56d0) then
tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * ((-0.5d0) + (x * 0.375d0))))
else
tmp = ((1.0d0 + x) ** (-0.5d0)) * (1.0d0 / (x + (x + 0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.56) {
tmp = Math.pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375))));
} else {
tmp = Math.pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.56: tmp = math.pow(x, -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375)))) else: tmp = math.pow((1.0 + x), -0.5) * (1.0 / (x + (x + 0.5))) return tmp
function code(x) tmp = 0.0 if (x <= 0.56) tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * Float64(-0.5 + Float64(x * 0.375))))); else tmp = Float64((Float64(1.0 + x) ^ -0.5) * Float64(1.0 / Float64(x + Float64(x + 0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.56) tmp = (x ^ -0.5) + (-1.0 - (x * (-0.5 + (x * 0.375)))); else tmp = ((1.0 + x) ^ -0.5) * (1.0 / (x + (x + 0.5))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.56], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * N[(-0.5 + N[(x * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(x + N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.56:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot \left(-0.5 + x \cdot 0.375\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(1 + x\right)}^{-0.5} \cdot \frac{1}{x + \left(x + 0.5\right)}\\
\end{array}
\end{array}
if x < 0.56000000000000005Initial program 99.6%
expm1-log1p-u92.2%
expm1-udef92.2%
pow1/292.2%
pow-flip92.2%
metadata-eval92.2%
Applied egg-rr92.2%
expm1-def92.2%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
*-commutative98.8%
unpow298.8%
associate-*l*98.8%
distribute-lft-out98.8%
Simplified98.8%
if 0.56000000000000005 < x Initial program 42.6%
frac-sub42.8%
associate-/r*42.8%
*-un-lft-identity42.8%
*-rgt-identity42.8%
+-commutative42.8%
+-commutative42.8%
Applied egg-rr42.8%
flip--43.6%
div-inv43.6%
add-sqr-sqrt25.8%
+-commutative25.8%
add-sqr-sqrt45.2%
associate--l+45.2%
+-commutative45.2%
+-commutative45.2%
Applied egg-rr45.2%
associate-*r/45.2%
*-rgt-identity45.2%
associate-+r-45.2%
+-commutative45.2%
associate--l+99.3%
Simplified99.3%
clear-num98.7%
+-commutative98.7%
associate-/r/99.3%
inv-pow99.3%
sqrt-pow299.4%
metadata-eval99.4%
+-commutative99.4%
associate-/l/99.3%
+-inverses99.3%
metadata-eval99.3%
distribute-lft-in99.3%
add-sqr-sqrt99.5%
sqrt-unprod83.1%
+-commutative83.1%
Applied egg-rr83.1%
Taylor expanded in x around inf 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.8%
(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.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
*-commutative98.1%
Simplified98.1%
if 1 < x Initial program 42.2%
*-un-lft-identity42.2%
clear-num42.2%
associate-/r/42.2%
prod-diff42.2%
*-un-lft-identity42.2%
fma-neg42.2%
*-un-lft-identity42.2%
pow1/242.2%
pow-flip32.2%
metadata-eval32.2%
pow1/232.2%
pow-flip42.2%
+-commutative42.2%
metadata-eval42.2%
Applied egg-rr42.2%
+-commutative42.2%
sub-neg42.2%
fma-udef42.2%
distribute-lft1-in42.2%
metadata-eval42.2%
mul0-lft42.2%
+-commutative42.2%
associate-+r+42.2%
sub-neg42.2%
neg-sub042.2%
+-commutative42.2%
sub-neg42.2%
Simplified42.2%
add-exp-log7.5%
log-pow7.6%
log1p-udef7.5%
Applied egg-rr7.5%
Taylor expanded in x around inf 74.5%
unpow-174.5%
exp-to-pow72.0%
*-commutative72.0%
log-pow72.0%
associate-*r*72.0%
metadata-eval72.0%
*-commutative72.0%
exp-to-pow74.8%
metadata-eval74.8%
pow-sqr74.9%
rem-sqrt-square98.5%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification98.3%
(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}
if x < 0.5Initial program 99.6%
expm1-log1p-u92.2%
expm1-udef92.2%
pow1/292.2%
pow-flip92.2%
metadata-eval92.2%
Applied egg-rr92.2%
expm1-def92.2%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around inf 96.3%
sqrt-div96.2%
metadata-eval96.2%
expm1-log1p-u89.0%
expm1-udef89.0%
inv-pow89.0%
sqrt-pow289.0%
metadata-eval89.0%
Applied egg-rr89.0%
expm1-def89.0%
expm1-log1p96.5%
Simplified96.5%
if 0.5 < x Initial program 42.6%
*-un-lft-identity42.6%
clear-num42.6%
associate-/r/42.6%
prod-diff42.6%
*-un-lft-identity42.6%
fma-neg42.6%
*-un-lft-identity42.6%
pow1/242.6%
pow-flip32.7%
metadata-eval32.7%
pow1/232.7%
pow-flip42.6%
+-commutative42.6%
metadata-eval42.6%
Applied egg-rr42.6%
+-commutative42.6%
sub-neg42.6%
fma-udef42.6%
distribute-lft1-in42.6%
metadata-eval42.6%
mul0-lft42.6%
+-commutative42.6%
associate-+r+42.6%
sub-neg42.6%
neg-sub042.6%
+-commutative42.6%
sub-neg42.6%
Simplified42.6%
add-exp-log8.2%
log-pow8.3%
log1p-udef8.2%
Applied egg-rr8.2%
Taylor expanded in x around inf 74.1%
unpow-174.1%
exp-to-pow71.6%
*-commutative71.6%
log-pow71.6%
associate-*r*71.6%
metadata-eval71.6%
*-commutative71.6%
exp-to-pow74.4%
metadata-eval74.4%
pow-sqr74.4%
rem-sqrt-square97.9%
rem-square-sqrt97.4%
fabs-sqr97.4%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification97.2%
(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.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.5%
if 0.680000000000000049 < x Initial program 42.6%
*-un-lft-identity42.6%
clear-num42.6%
associate-/r/42.6%
prod-diff42.6%
*-un-lft-identity42.6%
fma-neg42.6%
*-un-lft-identity42.6%
pow1/242.6%
pow-flip32.7%
metadata-eval32.7%
pow1/232.7%
pow-flip42.6%
+-commutative42.6%
metadata-eval42.6%
Applied egg-rr42.6%
+-commutative42.6%
sub-neg42.6%
fma-udef42.6%
distribute-lft1-in42.6%
metadata-eval42.6%
mul0-lft42.6%
+-commutative42.6%
associate-+r+42.6%
sub-neg42.6%
neg-sub042.6%
+-commutative42.6%
sub-neg42.6%
Simplified42.6%
add-exp-log8.2%
log-pow8.3%
log1p-udef8.2%
Applied egg-rr8.2%
Taylor expanded in x around inf 74.1%
unpow-174.1%
exp-to-pow71.6%
*-commutative71.6%
log-pow71.6%
associate-*r*71.6%
metadata-eval71.6%
*-commutative71.6%
exp-to-pow74.4%
metadata-eval74.4%
pow-sqr74.4%
rem-sqrt-square97.9%
rem-square-sqrt97.4%
fabs-sqr97.4%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification98.2%
(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}
Initial program 69.3%
expm1-log1p-u65.9%
expm1-udef46.2%
pow1/246.2%
pow-flip46.2%
metadata-eval46.2%
Applied egg-rr46.2%
expm1-def60.6%
expm1-log1p64.3%
Simplified64.3%
Taylor expanded in x around inf 48.2%
sqrt-div48.1%
metadata-eval48.1%
expm1-log1p-u44.8%
expm1-udef63.2%
inv-pow63.2%
sqrt-pow263.2%
metadata-eval63.2%
Applied egg-rr63.2%
expm1-def44.8%
expm1-log1p48.3%
Simplified48.3%
Final simplification48.3%
(FPCore (x) :precision binary64 (- (+ (* x 0.1875) (* 0.5 (/ 1.0 x))) 0.25))
double code(double x) {
return ((x * 0.1875) + (0.5 * (1.0 / x))) - 0.25;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * 0.1875d0) + (0.5d0 * (1.0d0 / x))) - 0.25d0
end function
public static double code(double x) {
return ((x * 0.1875) + (0.5 * (1.0 / x))) - 0.25;
}
def code(x): return ((x * 0.1875) + (0.5 * (1.0 / x))) - 0.25
function code(x) return Float64(Float64(Float64(x * 0.1875) + Float64(0.5 * Float64(1.0 / x))) - 0.25) end
function tmp = code(x) tmp = ((x * 0.1875) + (0.5 * (1.0 / x))) - 0.25; end
code[x_] := N[(N[(N[(x * 0.1875), $MachinePrecision] + N[(0.5 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.25), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.1875 + 0.5 \cdot \frac{1}{x}\right) - 0.25
\end{array}
Initial program 69.3%
frac-sub69.4%
associate-/r*69.4%
*-un-lft-identity69.4%
*-rgt-identity69.4%
+-commutative69.4%
+-commutative69.4%
Applied egg-rr69.4%
flip--69.8%
div-inv69.8%
add-sqr-sqrt60.4%
+-commutative60.4%
add-sqr-sqrt70.7%
associate--l+70.7%
+-commutative70.7%
+-commutative70.7%
Applied egg-rr70.7%
associate-*r/70.7%
*-rgt-identity70.7%
associate-+r-70.7%
+-commutative70.7%
associate--l+99.4%
Simplified99.4%
Taylor expanded in x around inf 55.1%
Taylor expanded in x around 0 5.1%
Final simplification5.1%
(FPCore (x) :precision binary64 (+ (/ 0.5 x) -0.25))
double code(double x) {
return (0.5 / x) + -0.25;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 / x) + (-0.25d0)
end function
public static double code(double x) {
return (0.5 / x) + -0.25;
}
def code(x): return (0.5 / x) + -0.25
function code(x) return Float64(Float64(0.5 / x) + -0.25) end
function tmp = code(x) tmp = (0.5 / x) + -0.25; end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] + -0.25), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{x} + -0.25
\end{array}
Initial program 69.3%
frac-sub69.4%
associate-/r*69.4%
*-un-lft-identity69.4%
*-rgt-identity69.4%
+-commutative69.4%
+-commutative69.4%
Applied egg-rr69.4%
flip--69.8%
div-inv69.8%
add-sqr-sqrt60.4%
+-commutative60.4%
add-sqr-sqrt70.7%
associate--l+70.7%
+-commutative70.7%
+-commutative70.7%
Applied egg-rr70.7%
associate-*r/70.7%
*-rgt-identity70.7%
associate-+r-70.7%
+-commutative70.7%
associate--l+99.4%
Simplified99.4%
Taylor expanded in x around inf 55.1%
Taylor expanded in x around 0 4.7%
sub-neg4.7%
associate-*r/4.7%
metadata-eval4.7%
metadata-eval4.7%
Simplified4.7%
Final simplification4.7%
(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 69.3%
Taylor expanded in x around 0 47.4%
Taylor expanded in x around inf 2.0%
Final simplification2.0%
(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 2023302
(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)))))