(FPCore (x) :precision binary64 (sqrt (- 1.0 (sqrt (- 1.0 (pow x 2.0))))))
double code(double x) { return sqrt((1.0 - sqrt((1.0 - pow(x, 2.0))))); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((1.0d0 - sqrt((1.0d0 - (x ** 2.0d0))))) end function
public static double code(double x) { return Math.sqrt((1.0 - Math.sqrt((1.0 - Math.pow(x, 2.0))))); }
def code(x): return math.sqrt((1.0 - math.sqrt((1.0 - math.pow(x, 2.0)))))
function code(x) return sqrt(Float64(1.0 - sqrt(Float64(1.0 - (x ^ 2.0))))) end
function tmp = code(x) tmp = sqrt((1.0 - sqrt((1.0 - (x ^ 2.0))))); end
code[x_] := N[Sqrt[N[(1.0 - N[Sqrt[N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sqrt{1 - \sqrt{1 - {x}^{2}}} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (sqrt (- 1.0 (sqrt (- 1.0 (pow x 2.0))))))
double code(double x) { return sqrt((1.0 - sqrt((1.0 - pow(x, 2.0))))); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((1.0d0 - sqrt((1.0d0 - (x ** 2.0d0))))) end function
public static double code(double x) { return Math.sqrt((1.0 - Math.sqrt((1.0 - Math.pow(x, 2.0))))); }
def code(x): return math.sqrt((1.0 - math.sqrt((1.0 - math.pow(x, 2.0)))))
function code(x) return sqrt(Float64(1.0 - sqrt(Float64(1.0 - (x ^ 2.0))))) end
function tmp = code(x) tmp = sqrt((1.0 - sqrt((1.0 - (x ^ 2.0))))); end
code[x_] := N[Sqrt[N[(1.0 - N[Sqrt[N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sqrt{1 - \sqrt{1 - {x}^{2}}} \end{array}
(FPCore (x) :precision binary64 (* (sqrt 0.5) x))
double code(double x) { return sqrt(0.5) * x; }
real(8) function code(x) real(8), intent (in) :: x code = sqrt(0.5d0) * x end function
public static double code(double x) { return Math.sqrt(0.5) * x; }
def code(x): return math.sqrt(0.5) * x
function code(x) return Float64(sqrt(0.5) * x) end
function tmp = code(x) tmp = sqrt(0.5) * x; end
code[x_] := N[(N[Sqrt[0.5], $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l} \\ \sqrt{0.5} \cdot x \end{array}
Initial program 7.1%
Taylor expanded in x around 0
*-commutative
N/A
lower-*.f64
N/A
lower-sqrt.f64
98.4
Applied rewrites98.4%
(FPCore (x) :precision binary64 (sqrt (- 1.0 1.0)))
double code(double x) { return sqrt((1.0 - 1.0)); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((1.0d0 - 1.0d0)) end function
public static double code(double x) { return Math.sqrt((1.0 - 1.0)); }
def code(x): return math.sqrt((1.0 - 1.0))
function code(x) return sqrt(Float64(1.0 - 1.0)) end
function tmp = code(x) tmp = sqrt((1.0 - 1.0)); end
code[x_] := N[Sqrt[N[(1.0 - 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sqrt{1 - 1} \end{array}
Initial program 7.1%
Taylor expanded in x around 0
Applied rewrites5.3%
herbie shell --seed 1
(FPCore (x)
:name "sqrt(1-sqrt(1-x^2))"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1.0))
(sqrt (- 1.0 (sqrt (- 1.0 (pow x 2.0))))))