(FPCore (x) :precision binary64 (/ x (sqrt (+ 1.0 (pow x 2.0)))))
double code(double x) { return x / sqrt((1.0 + pow(x, 2.0))); }
real(8) function code(x) real(8), intent (in) :: x code = x / sqrt((1.0d0 + (x ** 2.0d0))) end function
public static double code(double x) { return x / Math.sqrt((1.0 + Math.pow(x, 2.0))); }
def code(x): return x / math.sqrt((1.0 + math.pow(x, 2.0)))
function code(x) return Float64(x / sqrt(Float64(1.0 + (x ^ 2.0)))) end
function tmp = code(x) tmp = x / sqrt((1.0 + (x ^ 2.0))); end
code[x_] := N[(x / N[Sqrt[N[(1.0 + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{x}{\sqrt{1 + {x}^{2}}} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (/ x (sqrt (+ 1.0 (pow x 2.0)))))
double code(double x) { return x / sqrt((1.0 + pow(x, 2.0))); }
real(8) function code(x) real(8), intent (in) :: x code = x / sqrt((1.0d0 + (x ** 2.0d0))) end function
public static double code(double x) { return x / Math.sqrt((1.0 + Math.pow(x, 2.0))); }
def code(x): return x / math.sqrt((1.0 + math.pow(x, 2.0)))
function code(x) return Float64(x / sqrt(Float64(1.0 + (x ^ 2.0)))) end
function tmp = code(x) tmp = x / sqrt((1.0 + (x ^ 2.0))); end
code[x_] := N[(x / N[Sqrt[N[(1.0 + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{x}{\sqrt{1 + {x}^{2}}} \end{array}
(FPCore (x) :precision binary64 (sqrt (* (/ x (fma x x 1.0)) x)))
double code(double x) { return sqrt(((x / fma(x, x, 1.0)) * x)); }
function code(x) return sqrt(Float64(Float64(x / fma(x, x, 1.0)) * x)) end
code[x_] := N[Sqrt[N[(N[(x / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sqrt{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x} \end{array}
Initial program 99.5%
lift-+.f64
N/A
+-commutative
N/A
lift-pow.f64
N/A
unpow2
N/A
lower-fma.f64
99.5
Applied rewrites99.5%
lift-/.f64
N/A
rem-square-sqrt
N/A
sqrt-unprod
N/A
lift-*.f64
N/A
lift-sqrt.f64
N/A
sqrt-div
N/A
lift-*.f64
N/A
associate-*r/
N/A
lift-/.f64
N/A
lower-sqrt.f64
N/A
*-commutative
N/A
lower-*.f64
99.6
Applied rewrites99.6%
(FPCore (x) :precision binary64 (/ x (sqrt (fma x x 1.0))))
double code(double x) { return x / sqrt(fma(x, x, 1.0)); }
function code(x) return Float64(x / sqrt(fma(x, x, 1.0))) end
code[x_] := N[(x / N[Sqrt[N[(x * x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \end{array}
Initial program 99.5%
lift-+.f64
N/A
+-commutative
N/A
lift-pow.f64
N/A
unpow2
N/A
lower-fma.f64
99.5
Applied rewrites99.5%
(FPCore (x) :precision binary64 (/ x (- x (/ -0.5 x))))
double code(double x) { return x / (x - (-0.5 / x)); }
real(8) function code(x) real(8), intent (in) :: x code = x / (x - ((-0.5d0) / x)) end function
public static double code(double x) { return x / (x - (-0.5 / x)); }
def code(x): return x / (x - (-0.5 / x))
function code(x) return Float64(x / Float64(x - Float64(-0.5 / x))) end
function tmp = code(x) tmp = x / (x - (-0.5 / x)); end
code[x_] := N[(x / N[(x - N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{x}{x - \frac{-0.5}{x}} \end{array}
Initial program 99.5%
Taylor expanded in x around inf
distribute-lft-in
N/A
*-rgt-identity
N/A
cancel-sign-sub
N/A
mul-1-neg
N/A
lower--.f64
N/A
associate-*r*
N/A
*-commutative
N/A
associate-*l*
N/A
associate-*r*
N/A
metadata-eval
N/A
associate-*l/
N/A
*-lft-identity
N/A
unpow2
N/A
associate-/r*
N/A
*-inverses
N/A
associate-*r/
N/A
metadata-eval
N/A
lower-/.f64
53.3
Applied rewrites53.3%
(FPCore (x) :precision binary64 (- 1.0 (/ 0.5 (* x x))))
double code(double x) { return 1.0 - (0.5 / (x * x)); }
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 - (0.5d0 / (x * x)) end function
public static double code(double x) { return 1.0 - (0.5 / (x * x)); }
def code(x): return 1.0 - (0.5 / (x * x))
function code(x) return Float64(1.0 - Float64(0.5 / Float64(x * x))) end
function tmp = code(x) tmp = 1.0 - (0.5 / (x * x)); end
code[x_] := N[(1.0 - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \frac{0.5}{x \cdot x} \end{array}
Initial program 99.5%
Taylor expanded in x around inf
lower--.f64
N/A
associate-*r/
N/A
metadata-eval
N/A
lower-/.f64
N/A
unpow2
N/A
lower-*.f64
50.7
Applied rewrites50.7%
(FPCore (x) :precision binary64 (* (/ -1.0 x) (- x)))
double code(double x) { return (-1.0 / x) * -x; }
real(8) function code(x) real(8), intent (in) :: x code = ((-1.0d0) / x) * -x end function
public static double code(double x) { return (-1.0 / x) * -x; }
def code(x): return (-1.0 / x) * -x
function code(x) return Float64(Float64(-1.0 / x) * Float64(-x)) end
function tmp = code(x) tmp = (-1.0 / x) * -x; end
code[x_] := N[(N[(-1.0 / x), $MachinePrecision] * (-x)), $MachinePrecision]
\begin{array}{l} \\ \frac{-1}{x} \cdot \left(-x\right) \end{array}
Initial program 99.5%
lift-/.f64
N/A
clear-num
N/A
frac-2neg
N/A
associate-/r/
N/A
lower-*.f64
N/A
metadata-eval
N/A
frac-2neg
N/A
lower-/.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-pow.f64
N/A
unpow2
N/A
lower-fma.f64
N/A
lower-neg.f64
99.3
Applied rewrites99.3%
Taylor expanded in x around inf
lower-/.f64
34.5
Applied rewrites34.5%
(FPCore (x) :precision binary64 (* -1.0 (- x)))
double code(double x) { return -1.0 * -x; }
real(8) function code(x) real(8), intent (in) :: x code = (-1.0d0) * -x end function
public static double code(double x) { return -1.0 * -x; }
def code(x): return -1.0 * -x
function code(x) return Float64(-1.0 * Float64(-x)) end
function tmp = code(x) tmp = -1.0 * -x; end
code[x_] := N[(-1.0 * (-x)), $MachinePrecision]
\begin{array}{l} \\ -1 \cdot \left(-x\right) \end{array}
Initial program 99.5%
lift-/.f64
N/A
clear-num
N/A
frac-2neg
N/A
associate-/r/
N/A
lower-*.f64
N/A
metadata-eval
N/A
frac-2neg
N/A
lower-/.f64
N/A
lift-+.f64
N/A
+-commutative
N/A
lift-pow.f64
N/A
unpow2
N/A
lower-fma.f64
N/A
lower-neg.f64
99.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites15.6%
(FPCore (x) :precision binary64 -1.0)
double code(double x) { return -1.0; }
real(8) function code(x) real(8), intent (in) :: x code = -1.0d0 end function
public static double code(double x) { return -1.0; }
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l} \\ -1 \end{array}
Initial program 99.5%
Taylor expanded in x around -inf
Applied rewrites1.6%
herbie shell --seed 1
(FPCore (x)
:name "x / sqrt(1 + pow(x, 2))"
:precision binary64
:pre (and (<= 1.0 x) (<= x 1000.0))
(/ x (sqrt (+ 1.0 (pow x 2.0)))))