(FPCore (y x) :precision binary64 (/ (atan (/ y x)) (* 2.0 PI)))
double code(double y, double x) { return atan((y / x)) / (2.0 * ((double) M_PI)); }
public static double code(double y, double x) { return Math.atan((y / x)) / (2.0 * Math.PI); }
def code(y, x): return math.atan((y / x)) / (2.0 * math.pi)
function code(y, x) return Float64(atan(Float64(y / x)) / Float64(2.0 * pi)) end
function tmp = code(y, x) tmp = atan((y / x)) / (2.0 * pi); end
code[y_, x_] := N[(N[ArcTan[N[(y / x), $MachinePrecision]], $MachinePrecision] / N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{\tan^{-1} \left(\frac{y}{x}\right)}{2 \cdot \pi} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (y x) :precision binary64 (/ (atan (/ y x)) (* 2.0 PI)))
double code(double y, double x) { return atan((y / x)) / (2.0 * ((double) M_PI)); }
public static double code(double y, double x) { return Math.atan((y / x)) / (2.0 * Math.PI); }
def code(y, x): return math.atan((y / x)) / (2.0 * math.pi)
function code(y, x) return Float64(atan(Float64(y / x)) / Float64(2.0 * pi)) end
function tmp = code(y, x) tmp = atan((y / x)) / (2.0 * pi); end
code[y_, x_] := N[(N[ArcTan[N[(y / x), $MachinePrecision]], $MachinePrecision] / N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{\tan^{-1} \left(\frac{y}{x}\right)}{2 \cdot \pi} \end{array}
(FPCore (y x) :precision binary64 (/ (atan (/ y x)) (* 2.0 PI)))
double code(double y, double x) { return atan((y / x)) / (2.0 * ((double) M_PI)); }
public static double code(double y, double x) { return Math.atan((y / x)) / (2.0 * Math.PI); }
def code(y, x): return math.atan((y / x)) / (2.0 * math.pi)
function code(y, x) return Float64(atan(Float64(y / x)) / Float64(2.0 * pi)) end
function tmp = code(y, x) tmp = atan((y / x)) / (2.0 * pi); end
code[y_, x_] := N[(N[ArcTan[N[(y / x), $MachinePrecision]], $MachinePrecision] / N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{\tan^{-1} \left(\frac{y}{x}\right)}{2 \cdot \pi} \end{array}
Initial program 99.7%
(FPCore (y x) :precision binary64 (* (atan (/ y x)) (/ 0.5 PI)))
double code(double y, double x) { return atan((y / x)) * (0.5 / ((double) M_PI)); }
public static double code(double y, double x) { return Math.atan((y / x)) * (0.5 / Math.PI); }
def code(y, x): return math.atan((y / x)) * (0.5 / math.pi)
function code(y, x) return Float64(atan(Float64(y / x)) * Float64(0.5 / pi)) end
function tmp = code(y, x) tmp = atan((y / x)) * (0.5 / pi); end
code[y_, x_] := N[(N[ArcTan[N[(y / x), $MachinePrecision]], $MachinePrecision] * N[(0.5 / Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \tan^{-1} \left(\frac{y}{x}\right) \cdot \frac{0.5}{\pi} \end{array}
Initial program 99.7%
Taylor expanded in y around 0
*-commutative
N/A
associate-*l/
N/A
associate-/l*
N/A
lower-*.f64
N/A
lower-atan.f64
N/A
lower-/.f64
N/A
lower-/.f64
N/A
lower-PI.f64
99.7
Applied rewrites99.7%
(FPCore (y x) :precision binary64 (* (atan (/ y x)) 0.5))
double code(double y, double x) { return atan((y / x)) * 0.5; }
real(8) function code(y, x) real(8), intent (in) :: y real(8), intent (in) :: x code = atan((y / x)) * 0.5d0 end function
public static double code(double y, double x) { return Math.atan((y / x)) * 0.5; }
def code(y, x): return math.atan((y / x)) * 0.5
function code(y, x) return Float64(atan(Float64(y / x)) * 0.5) end
function tmp = code(y, x) tmp = atan((y / x)) * 0.5; end
code[y_, x_] := N[(N[ArcTan[N[(y / x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l} \\ \tan^{-1} \left(\frac{y}{x}\right) \cdot 0.5 \end{array}
Initial program 99.7%
Applied rewrites17.7%
herbie shell --seed 5
(FPCore (y x)
:name "atan(y / x) / (2*PI)"
:precision binary64
:pre (and (and (<= -6.0 y) (<= y 6.0)) (and (<= -6.0 x) (<= x 6.0)))
(/ (atan (/ y x)) (* 2.0 PI)))