
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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 (if (<= x 1e+15) (/ (- (sqrt (* (- x -1.0) x)) (* x 1.0)) (* x (sqrt (- x -1.0)))) (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x))))
double code(double x) {
double tmp;
if (x <= 1e+15) {
tmp = (sqrt(((x - -1.0) * x)) - (x * 1.0)) / (x * sqrt((x - -1.0)));
} else {
tmp = (0.5 / x) / (sqrt((1.0 / x)) * x);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d+15) then
tmp = (sqrt(((x - (-1.0d0)) * x)) - (x * 1.0d0)) / (x * sqrt((x - (-1.0d0))))
else
tmp = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e+15) {
tmp = (Math.sqrt(((x - -1.0) * x)) - (x * 1.0)) / (x * Math.sqrt((x - -1.0)));
} else {
tmp = (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e+15: tmp = (math.sqrt(((x - -1.0) * x)) - (x * 1.0)) / (x * math.sqrt((x - -1.0))) else: tmp = (0.5 / x) / (math.sqrt((1.0 / x)) * x) return tmp
function code(x) tmp = 0.0 if (x <= 1e+15) tmp = Float64(Float64(sqrt(Float64(Float64(x - -1.0) * x)) - Float64(x * 1.0)) / Float64(x * sqrt(Float64(x - -1.0)))); else tmp = Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e+15) tmp = (sqrt(((x - -1.0) * x)) - (x * 1.0)) / (x * sqrt((x - -1.0))); else tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e+15], N[(N[(N[Sqrt[N[(N[(x - -1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - N[(x * 1.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+15}:\\
\;\;\;\;\frac{\sqrt{\left(x - -1\right) \cdot x} - x \cdot 1}{x \cdot \sqrt{x - -1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}\\
\end{array}
\end{array}
if x < 1e15Initial program 38.0%
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-div-sound-leftN/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
pow-plusN/A
metadata-evalN/A
pow-flipN/A
pow1/2N/A
mult-flipN/A
lower-/.f64N/A
Applied rewrites21.1%
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-subN/A
lower-/.f64N/A
Applied rewrites6.5%
if 1e15 < x Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x) :precision binary64 (if (<= x 86000000.0) (/ (- (sqrt (- x -1.0)) (sqrt x)) (sqrt (* (- x -1.0) x))) (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x))))
double code(double x) {
double tmp;
if (x <= 86000000.0) {
tmp = (sqrt((x - -1.0)) - sqrt(x)) / sqrt(((x - -1.0) * x));
} else {
tmp = (0.5 / x) / (sqrt((1.0 / x)) * x);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 86000000.0d0) then
tmp = (sqrt((x - (-1.0d0))) - sqrt(x)) / sqrt(((x - (-1.0d0)) * x))
else
tmp = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 86000000.0) {
tmp = (Math.sqrt((x - -1.0)) - Math.sqrt(x)) / Math.sqrt(((x - -1.0) * x));
} else {
tmp = (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 86000000.0: tmp = (math.sqrt((x - -1.0)) - math.sqrt(x)) / math.sqrt(((x - -1.0) * x)) else: tmp = (0.5 / x) / (math.sqrt((1.0 / x)) * x) return tmp
function code(x) tmp = 0.0 if (x <= 86000000.0) tmp = Float64(Float64(sqrt(Float64(x - -1.0)) - sqrt(x)) / sqrt(Float64(Float64(x - -1.0) * x))); else tmp = Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 86000000.0) tmp = (sqrt((x - -1.0)) - sqrt(x)) / sqrt(((x - -1.0) * x)); else tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 86000000.0], N[(N[(N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(x - -1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 86000000:\\
\;\;\;\;\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\left(x - -1\right) \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}\\
\end{array}
\end{array}
if x < 8.6e7Initial program 38.0%
lift--.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
frac-subN/A
lower-/.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f64N/A
lift-sqrt.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6438.0
Applied rewrites38.0%
if 8.6e7 < x Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))) 2e-14) (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x)) (/ (- (sqrt (/ (- x -1.0) x)) 1.0) (sqrt (- x -1.0)))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-14) {
tmp = (0.5 / x) / (sqrt((1.0 / x)) * x);
} else {
tmp = (sqrt(((x - -1.0) / x)) - 1.0) / sqrt((x - -1.0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))) <= 2d-14) then
tmp = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
else
tmp = (sqrt(((x - (-1.0d0)) / x)) - 1.0d0) / sqrt((x - (-1.0d0)))
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)))) <= 2e-14) {
tmp = (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
} else {
tmp = (Math.sqrt(((x - -1.0) / x)) - 1.0) / Math.sqrt((x - -1.0));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))) <= 2e-14: tmp = (0.5 / x) / (math.sqrt((1.0 / x)) * x) else: tmp = (math.sqrt(((x - -1.0) / x)) - 1.0) / math.sqrt((x - -1.0)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) <= 2e-14) tmp = Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)); else tmp = Float64(Float64(sqrt(Float64(Float64(x - -1.0) / x)) - 1.0) / sqrt(Float64(x - -1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 2e-14) tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); else tmp = (sqrt(((x - -1.0) / x)) - 1.0) / sqrt((x - -1.0)); 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], 2e-14], N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{x - -1}{x}} - 1}{\sqrt{x - -1}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 2e-14Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 38.0%
lift--.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
frac-subN/A
lower-/.f64N/A
*-lft-identityN/A
*-rgt-identityN/A
lower--.f64N/A
lift-sqrt.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6438.0
Applied rewrites38.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
sqrt-unprodN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift--.f6438.0
Applied rewrites38.0%
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites38.0%
lift-/.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift--.f6438.0
Applied rewrites38.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 x))) (t_1 (/ 1.0 (sqrt (+ x 1.0)))))
(if (<= (- (/ 1.0 (sqrt x)) t_1) 1e-12)
(/ (/ 0.5 x) (* t_0 x))
(- t_0 t_1))))
double code(double x) {
double t_0 = sqrt((1.0 / x));
double t_1 = 1.0 / sqrt((x + 1.0));
double tmp;
if (((1.0 / sqrt(x)) - t_1) <= 1e-12) {
tmp = (0.5 / x) / (t_0 * x);
} else {
tmp = t_0 - t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((1.0d0 / x))
t_1 = 1.0d0 / sqrt((x + 1.0d0))
if (((1.0d0 / sqrt(x)) - t_1) <= 1d-12) then
tmp = (0.5d0 / x) / (t_0 * x)
else
tmp = t_0 - t_1
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 / x));
double t_1 = 1.0 / Math.sqrt((x + 1.0));
double tmp;
if (((1.0 / Math.sqrt(x)) - t_1) <= 1e-12) {
tmp = (0.5 / x) / (t_0 * x);
} else {
tmp = t_0 - t_1;
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 / x)) t_1 = 1.0 / math.sqrt((x + 1.0)) tmp = 0 if ((1.0 / math.sqrt(x)) - t_1) <= 1e-12: tmp = (0.5 / x) / (t_0 * x) else: tmp = t_0 - t_1 return tmp
function code(x) t_0 = sqrt(Float64(1.0 / x)) t_1 = Float64(1.0 / sqrt(Float64(x + 1.0))) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - t_1) <= 1e-12) tmp = Float64(Float64(0.5 / x) / Float64(t_0 * x)); else tmp = Float64(t_0 - t_1); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 / x)); t_1 = 1.0 / sqrt((x + 1.0)); tmp = 0.0; if (((1.0 / sqrt(x)) - t_1) <= 1e-12) tmp = (0.5 / x) / (t_0 * x); else tmp = t_0 - t_1; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 1e-12], N[(N[(0.5 / x), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{x}}\\
t_1 := \frac{1}{\sqrt{x + 1}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - t\_1 \leq 10^{-12}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{t\_0 \cdot x}\\
\mathbf{else}:\\
\;\;\;\;t\_0 - t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 9.9999999999999998e-13Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
if 9.9999999999999998e-13 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 38.0%
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-div-sound-leftN/A
metadata-evalN/A
lower-sqrt.f64N/A
lower-/.f6429.5
Applied rewrites29.5%
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))) 1e-12) (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x)) (- (/ (sqrt x) x) (/ 1.0 (sqrt (- x -1.0))))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 1e-12) {
tmp = (0.5 / x) / (sqrt((1.0 / x)) * x);
} else {
tmp = (sqrt(x) / x) - (1.0 / sqrt((x - -1.0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))) <= 1d-12) then
tmp = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
else
tmp = (sqrt(x) / x) - (1.0d0 / sqrt((x - (-1.0d0))))
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-12) {
tmp = (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
} else {
tmp = (Math.sqrt(x) / x) - (1.0 / Math.sqrt((x - -1.0)));
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))) <= 1e-12: tmp = (0.5 / x) / (math.sqrt((1.0 / x)) * x) else: tmp = (math.sqrt(x) / x) - (1.0 / math.sqrt((x - -1.0))) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) <= 1e-12) tmp = Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)); else tmp = Float64(Float64(sqrt(x) / x) - Float64(1.0 / sqrt(Float64(x - -1.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)))) <= 1e-12) tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); else tmp = (sqrt(x) / x) - (1.0 / sqrt((x - -1.0))); 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-12], N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[x], $MachinePrecision] / x), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \leq 10^{-12}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{x}}{x} - \frac{1}{\sqrt{x - -1}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) < 9.9999999999999998e-13Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
if 9.9999999999999998e-13 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64))))) Initial program 38.0%
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-div-sound-leftN/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
pow-plusN/A
metadata-evalN/A
pow-flipN/A
pow1/2N/A
mult-flipN/A
lower-/.f64N/A
Applied rewrites21.1%
lift-/.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
remove-double-divN/A
lift-sqrt.f6423.3
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lift--.f6423.3
Applied rewrites23.3%
(FPCore (x) :precision binary64 (if (<= x 72000000.0) (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (- x -1.0)))) (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x))))
double code(double x) {
double tmp;
if (x <= 72000000.0) {
tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x - -1.0)));
} else {
tmp = (0.5 / x) / (sqrt((1.0 / x)) * x);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 72000000.0d0) then
tmp = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x - (-1.0d0))))
else
tmp = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 72000000.0) {
tmp = (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x - -1.0)));
} else {
tmp = (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 72000000.0: tmp = (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x - -1.0))) else: tmp = (0.5 / x) / (math.sqrt((1.0 / x)) * x) return tmp
function code(x) tmp = 0.0 if (x <= 72000000.0) tmp = Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x - -1.0)))); else tmp = Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 72000000.0) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x - -1.0))); else tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 72000000.0], N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 72000000:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x - -1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}\\
\end{array}
\end{array}
if x < 7.2e7Initial program 38.0%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6438.0
Applied rewrites38.0%
if 7.2e7 < x Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x) :precision binary64 (/ (/ 0.5 x) (* (sqrt (/ 1.0 x)) x)))
double code(double x) {
return (0.5 / x) / (sqrt((1.0 / x)) * x);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (0.5d0 / x) / (sqrt((1.0d0 / x)) * x)
end function
public static double code(double x) {
return (0.5 / x) / (Math.sqrt((1.0 / x)) * x);
}
def code(x): return (0.5 / x) / (math.sqrt((1.0 / x)) * x)
function code(x) return Float64(Float64(0.5 / x) / Float64(sqrt(Float64(1.0 / x)) * x)) end
function tmp = code(x) tmp = (0.5 / x) / (sqrt((1.0 / x)) * x); end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{x}}{\sqrt{\frac{1}{x}} \cdot x}
\end{array}
Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x) :precision binary64 (/ (/ 0.5 x) (sqrt x)))
double code(double x) {
return (0.5 / x) / sqrt(x);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (0.5d0 / x) / sqrt(x)
end function
public static double code(double x) {
return (0.5 / x) / Math.sqrt(x);
}
def code(x): return (0.5 / x) / math.sqrt(x)
function code(x) return Float64(Float64(0.5 / x) / sqrt(x)) end
function tmp = code(x) tmp = (0.5 / x) / sqrt(x); end
code[x_] := N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5}{x}}{\sqrt{x}}
\end{array}
Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-/r*N/A
mult-flip-revN/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift-sqrt.f6497.6
Applied rewrites97.6%
(FPCore (x) :precision binary64 (/ 0.5 (* (sqrt x) x)))
double code(double x) {
return 0.5 / (sqrt(x) * x);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.5d0 / (sqrt(x) * x)
end function
public static double code(double x) {
return 0.5 / (Math.sqrt(x) * x);
}
def code(x): return 0.5 / (math.sqrt(x) * x)
function code(x) return Float64(0.5 / Float64(sqrt(x) * x)) end
function tmp = code(x) tmp = 0.5 / (sqrt(x) * x); end
code[x_] := N[(0.5 / N[(N[Sqrt[x], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{\sqrt{x} \cdot x}
\end{array}
Initial program 38.0%
Taylor expanded in x around inf
unpow3N/A
rem-square-sqrtN/A
associate-*r*N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-/.f64N/A
fabs-pow2-revN/A
rem-sqrt-square-revN/A
pow-prod-upN/A
metadata-evalN/A
sqrt-unprodN/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
lower-sqrt.f64N/A
unpow3N/A
Applied rewrites64.5%
pow1/264.5
pow-flip64.5
metadata-eval64.5
metadata-eval64.5
pow-prod-up64.5
pow1/264.5
inv-pow64.5
mult-flip64.5
remove-double-div64.5
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fabs-pow2-revN/A
sqrt-prod-soundN/A
fabs-pow2-revN/A
pow2N/A
sqrt-unprodN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f6496.3
Applied rewrites96.3%
(FPCore (x) :precision binary64 (sqrt (/ 1.0 x)))
double code(double x) {
return sqrt((1.0 / x));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = sqrt((1.0d0 / x))
end function
public static double code(double x) {
return Math.sqrt((1.0 / x));
}
def code(x): return math.sqrt((1.0 / x))
function code(x) return sqrt(Float64(1.0 / x)) end
function tmp = code(x) tmp = sqrt((1.0 / x)); end
code[x_] := N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{x}}
\end{array}
Initial program 38.0%
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-div-sound-leftN/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
pow-plusN/A
metadata-evalN/A
pow-flipN/A
pow1/2N/A
mult-flipN/A
lower-/.f64N/A
Applied rewrites21.1%
Taylor expanded in x around 0
lower-/.f64N/A
lift-sqrt.f645.6
Applied rewrites5.6%
Taylor expanded in x around inf
lower-sqrt.f64N/A
lower-/.f645.6
Applied rewrites5.6%
(FPCore (x) :precision binary64 (fma 0.5 x -1.0))
double code(double x) {
return fma(0.5, x, -1.0);
}
function code(x) return fma(0.5, x, -1.0) end
code[x_] := N[(0.5 * x + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.5, x, -1\right)
\end{array}
Initial program 38.0%
lift--.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
sub-flipN/A
metadata-evalN/A
metadata-evalN/A
sqrt-div-sound-leftN/A
metadata-evalN/A
rem-square-sqrtN/A
sqrt-fabs-revN/A
sqrt-prod-soundN/A
sqrt-fabs-revN/A
lower-fma.f64N/A
Applied rewrites7.4%
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
pow1/2N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-divN/A
sqrt-pow2N/A
mult-flipN/A
Applied rewrites5.1%
Taylor expanded in x around 0
sub-flipN/A
metadata-evalN/A
lower-fma.f643.4
Applied rewrites3.4%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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 38.0%
lift--.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
sub-flipN/A
metadata-evalN/A
metadata-evalN/A
sqrt-div-sound-leftN/A
metadata-evalN/A
rem-square-sqrtN/A
sqrt-fabs-revN/A
sqrt-prod-soundN/A
sqrt-fabs-revN/A
lower-fma.f64N/A
Applied rewrites7.4%
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
pow1/2N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-divN/A
sqrt-pow2N/A
mult-flipN/A
Applied rewrites5.1%
Taylor expanded in x around 0
Applied rewrites2.5%
(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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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}
(FPCore (x) :precision binary64 (- (pow x -0.5) (pow (+ x 1.0) -0.5)))
double code(double x) {
return pow(x, -0.5) - pow((x + 1.0), -0.5);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
}
def code(x): return math.pow(x, -0.5) - math.pow((x + 1.0), -0.5)
function code(x) return Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}
\end{array}
herbie shell --seed 2025136
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform c (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
:alt
(! :herbie-platform c (- (pow x -1/2) (pow (+ x 1) -1/2)))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))