(FPCore (x) :precision binary64 (* 0.9897218787411787 (pow (- 1.0 (pow x 2.0)) (/ 29.0 2.0))))
double code(double x) { return 0.9897218787411787 * pow((1.0 - pow(x, 2.0)), (29.0 / 2.0)); }
real(8) function code(x) real(8), intent (in) :: x code = 0.9897218787411787d0 * ((1.0d0 - (x ** 2.0d0)) ** (29.0d0 / 2.0d0)) end function
public static double code(double x) { return 0.9897218787411787 * Math.pow((1.0 - Math.pow(x, 2.0)), (29.0 / 2.0)); }
def code(x): return 0.9897218787411787 * math.pow((1.0 - math.pow(x, 2.0)), (29.0 / 2.0))
function code(x) return Float64(0.9897218787411787 * (Float64(1.0 - (x ^ 2.0)) ^ Float64(29.0 / 2.0))) end
function tmp = code(x) tmp = 0.9897218787411787 * ((1.0 - (x ^ 2.0)) ^ (29.0 / 2.0)); end
code[x_] := N[(0.9897218787411787 * N[Power[N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], N[(29.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 0.9897218787411787 \cdot {\left(1 - {x}^{2}\right)}^{\left(\frac{29}{2}\right)} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (* 0.9897218787411787 (pow (- 1.0 (pow x 2.0)) (/ 29.0 2.0))))
double code(double x) { return 0.9897218787411787 * pow((1.0 - pow(x, 2.0)), (29.0 / 2.0)); }
real(8) function code(x) real(8), intent (in) :: x code = 0.9897218787411787d0 * ((1.0d0 - (x ** 2.0d0)) ** (29.0d0 / 2.0d0)) end function
public static double code(double x) { return 0.9897218787411787 * Math.pow((1.0 - Math.pow(x, 2.0)), (29.0 / 2.0)); }
def code(x): return 0.9897218787411787 * math.pow((1.0 - math.pow(x, 2.0)), (29.0 / 2.0))
function code(x) return Float64(0.9897218787411787 * (Float64(1.0 - (x ^ 2.0)) ^ Float64(29.0 / 2.0))) end
function tmp = code(x) tmp = 0.9897218787411787 * ((1.0 - (x ^ 2.0)) ^ (29.0 / 2.0)); end
code[x_] := N[(0.9897218787411787 * N[Power[N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], N[(29.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 0.9897218787411787 \cdot {\left(1 - {x}^{2}\right)}^{\left(\frac{29}{2}\right)} \end{array}
(FPCore (x) :precision binary64 (* 0.9897218787411787 (pow (fma (- x) x 1.0) 14.5)))
double code(double x) { return 0.9897218787411787 * pow(fma(-x, x, 1.0), 14.5); }
function code(x) return Float64(0.9897218787411787 * (fma(Float64(-x), x, 1.0) ^ 14.5)) end
code[x_] := N[(0.9897218787411787 * N[Power[N[((-x) * x + 1.0), $MachinePrecision], 14.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 0.9897218787411787 \cdot {\left(\mathsf{fma}\left(-x, x, 1\right)\right)}^{14.5} \end{array}
Initial program 99.9%
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
lift-pow.f64
N/A
unpow2
N/A
distribute-lft-neg-in
N/A
lower-fma.f64
N/A
lower-neg.f64
99.9
Applied rewrites99.9%
lift-/.f64
N/A
metadata-eval
99.9
Applied rewrites99.9%
(FPCore (x) :precision binary64 (fma (fma (fma -403.62095367413696 (* x x) 96.86902888179286) (* x x) -14.35096724174709) (* x x) 0.9897218787411787))
double code(double x) { return fma(fma(fma(-403.62095367413696, (x * x), 96.86902888179286), (x * x), -14.35096724174709), (x * x), 0.9897218787411787); }
function code(x) return fma(fma(fma(-403.62095367413696, Float64(x * x), 96.86902888179286), Float64(x * x), -14.35096724174709), Float64(x * x), 0.9897218787411787) end
code[x_] := N[(N[(N[(-403.62095367413696 * N[(x * x), $MachinePrecision] + 96.86902888179286), $MachinePrecision] * N[(x * x), $MachinePrecision] + -14.35096724174709), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.9897218787411787), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-403.62095367413696, x \cdot x, 96.86902888179286\right), x \cdot x, -14.35096724174709\right), x \cdot x, 0.9897218787411787\right) \end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
*-commutative
N/A
metadata-eval
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
unpow2
N/A
lower-*.f64
N/A
unpow2
N/A
lower-*.f64
N/A
unpow2
N/A
lower-*.f64
99.2
Applied rewrites99.2%
(FPCore (x) :precision binary64 (fma (fma 96.86902888179286 (* x x) -14.35096724174709) (* x x) 0.9897218787411787))
double code(double x) { return fma(fma(96.86902888179286, (x * x), -14.35096724174709), (x * x), 0.9897218787411787); }
function code(x) return fma(fma(96.86902888179286, Float64(x * x), -14.35096724174709), Float64(x * x), 0.9897218787411787) end
code[x_] := N[(N[(96.86902888179286 * N[(x * x), $MachinePrecision] + -14.35096724174709), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.9897218787411787), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(96.86902888179286, x \cdot x, -14.35096724174709\right), x \cdot x, 0.9897218787411787\right) \end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
metadata-eval
N/A
lower-fma.f64
N/A
unpow2
N/A
lower-*.f64
N/A
unpow2
N/A
lower-*.f64
99.2
Applied rewrites99.2%
(FPCore (x) :precision binary64 (fma (* x x) -14.35096724174709 0.9897218787411787))
double code(double x) { return fma((x * x), -14.35096724174709, 0.9897218787411787); }
function code(x) return fma(Float64(x * x), -14.35096724174709, 0.9897218787411787) end
code[x_] := N[(N[(x * x), $MachinePrecision] * -14.35096724174709 + 0.9897218787411787), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(x \cdot x, -14.35096724174709, 0.9897218787411787\right) \end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
unpow2
N/A
lower-*.f64
98.9
Applied rewrites98.9%
(FPCore (x) :precision binary64 0.9897218787411787)
double code(double x) { return 0.9897218787411787; }
real(8) function code(x) real(8), intent (in) :: x code = 0.9897218787411787d0 end function
public static double code(double x) { return 0.9897218787411787; }
def code(x): return 0.9897218787411787
function code(x) return 0.9897218787411787 end
function tmp = code(x) tmp = 0.9897218787411787; end
code[x_] := 0.9897218787411787
\begin{array}{l} \\ 0.9897218787411787 \end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites98.3%
herbie shell --seed 1
(FPCore (x)
:name "0.9897218787411787*pow(1 - pow(x, 2), 29.0/2.0);"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
(* 0.9897218787411787 (pow (- 1.0 (pow x 2.0)) (/ 29.0 2.0))))