
(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 8 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 (* (pow x -0.5) (/ (+ 1.0 (* x 0.0)) (+ (+ x 1.0) (* (sqrt x) (sqrt (+ x 1.0)))))))
double code(double x) {
return pow(x, -0.5) * ((1.0 + (x * 0.0)) / ((x + 1.0) + (sqrt(x) * sqrt((x + 1.0)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-0.5d0)) * ((1.0d0 + (x * 0.0d0)) / ((x + 1.0d0) + (sqrt(x) * sqrt((x + 1.0d0)))))
end function
public static double code(double x) {
return Math.pow(x, -0.5) * ((1.0 + (x * 0.0)) / ((x + 1.0) + (Math.sqrt(x) * Math.sqrt((x + 1.0)))));
}
def code(x): return math.pow(x, -0.5) * ((1.0 + (x * 0.0)) / ((x + 1.0) + (math.sqrt(x) * math.sqrt((x + 1.0)))))
function code(x) return Float64((x ^ -0.5) * Float64(Float64(1.0 + Float64(x * 0.0)) / Float64(Float64(x + 1.0) + Float64(sqrt(x) * sqrt(Float64(x + 1.0)))))) end
function tmp = code(x) tmp = (x ^ -0.5) * ((1.0 + (x * 0.0)) / ((x + 1.0) + (sqrt(x) * sqrt((x + 1.0))))); end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(1.0 + N[(x * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}}
\end{array}
Initial program 69.7%
*-un-lft-identity69.7%
clear-num69.7%
associate-/r/69.7%
prod-diff69.7%
*-un-lft-identity69.7%
fma-neg69.7%
*-un-lft-identity69.7%
pow1/269.7%
pow-flip66.0%
metadata-eval66.0%
pow1/266.0%
pow-flip69.9%
+-commutative69.9%
metadata-eval69.9%
Applied egg-rr69.9%
associate-+l-69.9%
expm1-log1p69.9%
expm1-def53.7%
associate--l-53.7%
fma-udef53.7%
distribute-lft1-in53.7%
metadata-eval53.7%
mul0-lft53.7%
metadata-eval53.7%
expm1-def69.9%
expm1-log1p69.9%
Simplified69.9%
metadata-eval69.9%
sqrt-pow265.9%
inv-pow65.9%
metadata-eval65.9%
sqrt-pow269.7%
inv-pow69.7%
clear-num69.7%
frac-sub69.7%
*-un-lft-identity69.7%
/-rgt-identity69.7%
+-commutative69.7%
*-rgt-identity69.7%
/-rgt-identity69.7%
sqrt-unprod69.7%
+-commutative69.7%
Applied egg-rr69.7%
flip--70.1%
add-sqr-sqrt70.4%
add-sqr-sqrt70.6%
Applied egg-rr70.6%
*-un-lft-identity70.6%
sqrt-prod70.5%
times-frac70.6%
pow1/270.6%
pow-flip70.7%
metadata-eval70.7%
associate--l+70.7%
Applied egg-rr70.7%
associate-/l/70.7%
+-commutative70.7%
sub-neg70.7%
associate-+l+99.7%
neg-mul-199.7%
*-lft-identity99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
distribute-rgt-in99.7%
rem-square-sqrt99.7%
+-commutative99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (+ x 1.0))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
(* 0.5 (pow x -1.5))
(/ (/ 1.0 (+ (sqrt x) t_0)) (sqrt (* x (+ x 1.0)))))))
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = (1.0d0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = (1.0 / (Math.sqrt(x) + t_0)) / Math.sqrt((x * (x + 1.0)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = (1.0 / (math.sqrt(x) + t_0)) / math.sqrt((x * (x + 1.0))) return tmp
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(x + 1.0)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\sqrt{x \cdot \left(x + 1\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.3%
*-un-lft-identity38.3%
clear-num38.3%
associate-/r/38.3%
prod-diff38.3%
*-un-lft-identity38.3%
fma-neg38.3%
*-un-lft-identity38.3%
pow1/238.3%
pow-flip30.1%
metadata-eval30.1%
pow1/230.1%
pow-flip38.3%
+-commutative38.3%
metadata-eval38.3%
Applied egg-rr38.3%
associate-+l-38.3%
expm1-log1p38.3%
expm1-def5.0%
associate--l-5.0%
fma-udef5.0%
distribute-lft1-in5.0%
metadata-eval5.0%
mul0-lft5.0%
metadata-eval5.0%
expm1-def38.3%
expm1-log1p38.3%
Simplified38.3%
Taylor expanded in x around inf 64.4%
expm1-log1p-u64.4%
expm1-udef38.3%
pow-flip38.3%
sqrt-pow138.3%
metadata-eval38.3%
metadata-eval38.3%
Applied egg-rr38.3%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 97.8%
*-un-lft-identity97.8%
clear-num97.8%
associate-/r/97.8%
prod-diff97.8%
*-un-lft-identity97.8%
fma-neg97.8%
*-un-lft-identity97.8%
pow1/297.8%
pow-flip98.2%
metadata-eval98.2%
pow1/298.2%
pow-flip98.3%
+-commutative98.3%
metadata-eval98.3%
Applied egg-rr98.3%
associate-+l-98.3%
expm1-log1p98.3%
expm1-def97.4%
associate--l-97.4%
fma-udef97.4%
distribute-lft1-in97.4%
metadata-eval97.4%
mul0-lft97.4%
metadata-eval97.4%
expm1-def98.3%
expm1-log1p98.3%
Simplified98.3%
metadata-eval98.3%
sqrt-pow297.9%
inv-pow97.9%
metadata-eval97.9%
sqrt-pow297.8%
inv-pow97.8%
clear-num97.8%
frac-sub97.8%
*-un-lft-identity97.8%
/-rgt-identity97.8%
+-commutative97.8%
*-rgt-identity97.8%
/-rgt-identity97.8%
sqrt-unprod97.8%
+-commutative97.8%
Applied egg-rr97.8%
flip--98.5%
add-sqr-sqrt99.1%
add-sqr-sqrt99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.5%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ x 1.0)))) 1e-13) (* 0.5 (pow x -1.5)) (- (pow x -0.5) (pow (+ x 1.0) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 1e-13) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((x + 1.0d0)))) <= 1d-13) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((x + 1.0)))) <= 1e-13) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((x + 1.0)))) <= 1e-13: tmp = 0.5 * math.pow(x, -1.5) else: tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(x + 1.0)))) <= 1e-13) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 1e-13) tmp = 0.5 * (x ^ -1.5); else tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-13], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1e-13Initial program 38.5%
*-un-lft-identity38.5%
clear-num38.5%
associate-/r/38.5%
prod-diff38.5%
*-un-lft-identity38.5%
fma-neg38.5%
*-un-lft-identity38.5%
pow1/238.5%
pow-flip30.5%
metadata-eval30.5%
pow1/230.5%
pow-flip38.6%
+-commutative38.6%
metadata-eval38.6%
Applied egg-rr38.6%
associate-+l-38.6%
expm1-log1p38.6%
expm1-def5.3%
associate--l-5.3%
fma-udef5.3%
distribute-lft1-in5.3%
metadata-eval5.3%
mul0-lft5.3%
metadata-eval5.3%
expm1-def38.6%
expm1-log1p38.6%
Simplified38.6%
Taylor expanded in x around inf 64.6%
expm1-log1p-u64.6%
expm1-udef37.7%
pow-flip37.7%
sqrt-pow137.7%
metadata-eval37.7%
metadata-eval37.7%
Applied egg-rr37.7%
expm1-def99.3%
expm1-log1p99.3%
Simplified99.3%
if 1e-13 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.0%
*-un-lft-identity99.0%
clear-num99.0%
associate-/r/99.0%
prod-diff99.0%
*-un-lft-identity99.0%
fma-neg99.0%
*-un-lft-identity99.0%
pow1/299.0%
pow-flip99.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.4%
+-commutative99.4%
metadata-eval99.4%
Applied egg-rr99.4%
associate-+l-99.4%
expm1-log1p99.4%
expm1-def99.2%
associate--l-99.2%
fma-udef99.2%
distribute-lft1-in99.2%
metadata-eval99.2%
mul0-lft99.2%
metadata-eval99.2%
expm1-def99.4%
expm1-log1p99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (/ (/ (+ 1.0 (* x 0.0)) (+ (+ x 1.0) (* (sqrt x) (sqrt (+ x 1.0))))) (sqrt x)))
double code(double x) {
return ((1.0 + (x * 0.0)) / ((x + 1.0) + (sqrt(x) * sqrt((x + 1.0))))) / sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + (x * 0.0d0)) / ((x + 1.0d0) + (sqrt(x) * sqrt((x + 1.0d0))))) / sqrt(x)
end function
public static double code(double x) {
return ((1.0 + (x * 0.0)) / ((x + 1.0) + (Math.sqrt(x) * Math.sqrt((x + 1.0))))) / Math.sqrt(x);
}
def code(x): return ((1.0 + (x * 0.0)) / ((x + 1.0) + (math.sqrt(x) * math.sqrt((x + 1.0))))) / math.sqrt(x)
function code(x) return Float64(Float64(Float64(1.0 + Float64(x * 0.0)) / Float64(Float64(x + 1.0) + Float64(sqrt(x) * sqrt(Float64(x + 1.0))))) / sqrt(x)) end
function tmp = code(x) tmp = ((1.0 + (x * 0.0)) / ((x + 1.0) + (sqrt(x) * sqrt((x + 1.0))))) / sqrt(x); end
code[x_] := N[(N[(N[(1.0 + N[(x * 0.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x}}
\end{array}
Initial program 69.7%
*-un-lft-identity69.7%
clear-num69.7%
associate-/r/69.7%
prod-diff69.7%
*-un-lft-identity69.7%
fma-neg69.7%
*-un-lft-identity69.7%
pow1/269.7%
pow-flip66.0%
metadata-eval66.0%
pow1/266.0%
pow-flip69.9%
+-commutative69.9%
metadata-eval69.9%
Applied egg-rr69.9%
associate-+l-69.9%
expm1-log1p69.9%
expm1-def53.7%
associate--l-53.7%
fma-udef53.7%
distribute-lft1-in53.7%
metadata-eval53.7%
mul0-lft53.7%
metadata-eval53.7%
expm1-def69.9%
expm1-log1p69.9%
Simplified69.9%
metadata-eval69.9%
sqrt-pow265.9%
inv-pow65.9%
metadata-eval65.9%
sqrt-pow269.7%
inv-pow69.7%
clear-num69.7%
frac-sub69.7%
*-un-lft-identity69.7%
/-rgt-identity69.7%
+-commutative69.7%
*-rgt-identity69.7%
/-rgt-identity69.7%
sqrt-unprod69.7%
+-commutative69.7%
Applied egg-rr69.7%
flip--70.1%
add-sqr-sqrt70.4%
add-sqr-sqrt70.6%
Applied egg-rr70.6%
div-inv70.6%
sqrt-prod70.5%
times-frac70.6%
associate--l+70.6%
Applied egg-rr70.6%
associate-*l/70.6%
Simplified99.5%
Final simplification99.5%
(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.6%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
expm1-log1p-u92.1%
expm1-udef92.1%
pow1/292.1%
pow-flip92.1%
metadata-eval92.1%
Applied egg-rr92.1%
expm1-def92.1%
expm1-log1p99.4%
Simplified99.4%
if 1.69999999999999996 < x Initial program 40.2%
*-un-lft-identity40.2%
clear-num40.2%
associate-/r/40.2%
prod-diff40.2%
*-un-lft-identity40.2%
fma-neg40.2%
*-un-lft-identity40.2%
pow1/240.2%
pow-flip32.6%
metadata-eval32.6%
pow1/232.6%
pow-flip40.4%
+-commutative40.4%
metadata-eval40.4%
Applied egg-rr40.4%
associate-+l-40.4%
expm1-log1p40.3%
expm1-def8.2%
associate--l-8.2%
fma-udef8.2%
distribute-lft1-in8.2%
metadata-eval8.2%
mul0-lft8.2%
metadata-eval8.2%
expm1-def40.3%
expm1-log1p40.4%
Simplified40.4%
Taylor expanded in x around inf 63.4%
expm1-log1p-u63.4%
expm1-udef37.5%
pow-flip37.5%
sqrt-pow137.5%
metadata-eval37.5%
metadata-eval37.5%
Applied egg-rr37.5%
expm1-def96.8%
expm1-log1p96.8%
Simplified96.8%
Final simplification98.1%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
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%
associate-+l-100.0%
expm1-log1p100.0%
expm1-def100.0%
associate--l-100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
metadata-eval100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around 0 99.4%
if 1 < x Initial program 40.2%
*-un-lft-identity40.2%
clear-num40.2%
associate-/r/40.2%
prod-diff40.2%
*-un-lft-identity40.2%
fma-neg40.2%
*-un-lft-identity40.2%
pow1/240.2%
pow-flip32.6%
metadata-eval32.6%
pow1/232.6%
pow-flip40.4%
+-commutative40.4%
metadata-eval40.4%
Applied egg-rr40.4%
associate-+l-40.4%
expm1-log1p40.3%
expm1-def8.2%
associate--l-8.2%
fma-udef8.2%
distribute-lft1-in8.2%
metadata-eval8.2%
mul0-lft8.2%
metadata-eval8.2%
expm1-def40.3%
expm1-log1p40.4%
Simplified40.4%
Taylor expanded in x around inf 63.4%
expm1-log1p-u63.4%
expm1-udef37.5%
pow-flip37.5%
sqrt-pow137.5%
metadata-eval37.5%
metadata-eval37.5%
Applied egg-rr37.5%
expm1-def96.8%
expm1-log1p96.8%
Simplified96.8%
Final simplification98.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.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%
associate-+l-100.0%
expm1-log1p100.0%
expm1-def100.0%
associate--l-100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
metadata-eval100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in x around 0 98.9%
if 0.680000000000000049 < x Initial program 40.2%
*-un-lft-identity40.2%
clear-num40.2%
associate-/r/40.2%
prod-diff40.2%
*-un-lft-identity40.2%
fma-neg40.2%
*-un-lft-identity40.2%
pow1/240.2%
pow-flip32.6%
metadata-eval32.6%
pow1/232.6%
pow-flip40.4%
+-commutative40.4%
metadata-eval40.4%
Applied egg-rr40.4%
associate-+l-40.4%
expm1-log1p40.3%
expm1-def8.2%
associate--l-8.2%
fma-udef8.2%
distribute-lft1-in8.2%
metadata-eval8.2%
mul0-lft8.2%
metadata-eval8.2%
expm1-def40.3%
expm1-log1p40.4%
Simplified40.4%
Taylor expanded in x around inf 63.4%
expm1-log1p-u63.4%
expm1-udef37.5%
pow-flip37.5%
sqrt-pow137.5%
metadata-eval37.5%
metadata-eval37.5%
Applied egg-rr37.5%
expm1-def96.8%
expm1-log1p96.8%
Simplified96.8%
Final simplification97.8%
(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 69.7%
*-un-lft-identity69.7%
clear-num69.7%
associate-/r/69.7%
prod-diff69.7%
*-un-lft-identity69.7%
fma-neg69.7%
*-un-lft-identity69.7%
pow1/269.7%
pow-flip66.0%
metadata-eval66.0%
pow1/266.0%
pow-flip69.9%
+-commutative69.9%
metadata-eval69.9%
Applied egg-rr69.9%
associate-+l-69.9%
expm1-log1p69.9%
expm1-def53.7%
associate--l-53.7%
fma-udef53.7%
distribute-lft1-in53.7%
metadata-eval53.7%
mul0-lft53.7%
metadata-eval53.7%
expm1-def69.9%
expm1-log1p69.9%
Simplified69.9%
Taylor expanded in x around inf 34.7%
expm1-log1p-u34.7%
expm1-udef21.7%
pow-flip21.7%
sqrt-pow121.8%
metadata-eval21.8%
metadata-eval21.8%
Applied egg-rr21.8%
expm1-def51.7%
expm1-log1p51.7%
Simplified51.7%
Final simplification51.7%
(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 2023313
(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)))))