(FPCore (x y z a) :precision binary64 (- 1.0 (* (* (* (/ 0.44 y) 1.333333) (* 1.259921 (/ 1.0 z))) (+ (* (* x a) 0.125) (atan2 1.0 (* 0.5 x))))))
double code(double x, double y, double z, double a) { return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + atan2(1.0, (0.5 * x)))); }
real(8) function code(x, y, z, a) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z real(8), intent (in) :: a code = 1.0d0 - ((((0.44d0 / y) * 1.333333d0) * (1.259921d0 * (1.0d0 / z))) * (((x * a) * 0.125d0) + atan2(1.0d0, (0.5d0 * x)))) end function
public static double code(double x, double y, double z, double a) { return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + Math.atan2(1.0, (0.5 * x)))); }
def code(x, y, z, a): return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + math.atan2(1.0, (0.5 * x))))
function code(x, y, z, a) return Float64(1.0 - Float64(Float64(Float64(Float64(0.44 / y) * 1.333333) * Float64(1.259921 * Float64(1.0 / z))) * Float64(Float64(Float64(x * a) * 0.125) + atan(1.0, Float64(0.5 * x))))) end
function tmp = code(x, y, z, a) tmp = 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + atan2(1.0, (0.5 * x)))); end
code[x_, y_, z_, a_] := N[(1.0 - N[(N[(N[(N[(0.44 / y), $MachinePrecision] * 1.333333), $MachinePrecision] * N[(1.259921 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * a), $MachinePrecision] * 0.125), $MachinePrecision] + N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \left(\left(\frac{0.44}{y} \cdot 1.333333\right) \cdot \left(1.259921 \cdot \frac{1}{z}\right)\right) \cdot \left(\left(x \cdot a\right) \cdot 0.125 + \tan^{-1}_* \frac{1}{0.5 \cdot x}\right) \end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y z a) :precision binary64 (- 1.0 (* (* (* (/ 0.44 y) 1.333333) (* 1.259921 (/ 1.0 z))) (+ (* (* x a) 0.125) (atan2 1.0 (* 0.5 x))))))
double code(double x, double y, double z, double a) { return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + atan2(1.0, (0.5 * x)))); }
real(8) function code(x, y, z, a) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z real(8), intent (in) :: a code = 1.0d0 - ((((0.44d0 / y) * 1.333333d0) * (1.259921d0 * (1.0d0 / z))) * (((x * a) * 0.125d0) + atan2(1.0d0, (0.5d0 * x)))) end function
public static double code(double x, double y, double z, double a) { return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + Math.atan2(1.0, (0.5 * x)))); }
def code(x, y, z, a): return 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + math.atan2(1.0, (0.5 * x))))
function code(x, y, z, a) return Float64(1.0 - Float64(Float64(Float64(Float64(0.44 / y) * 1.333333) * Float64(1.259921 * Float64(1.0 / z))) * Float64(Float64(Float64(x * a) * 0.125) + atan(1.0, Float64(0.5 * x))))) end
function tmp = code(x, y, z, a) tmp = 1.0 - ((((0.44 / y) * 1.333333) * (1.259921 * (1.0 / z))) * (((x * a) * 0.125) + atan2(1.0, (0.5 * x)))); end
code[x_, y_, z_, a_] := N[(1.0 - N[(N[(N[(N[(0.44 / y), $MachinePrecision] * 1.333333), $MachinePrecision] * N[(1.259921 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * a), $MachinePrecision] * 0.125), $MachinePrecision] + N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \left(\left(\frac{0.44}{y} \cdot 1.333333\right) \cdot \left(1.259921 \cdot \frac{1}{z}\right)\right) \cdot \left(\left(x \cdot a\right) \cdot 0.125 + \tan^{-1}_* \frac{1}{0.5 \cdot x}\right) \end{array}
(FPCore (x y z a) :precision binary64 (fma (/ 1.259921 z) (* (/ -0.5866665200000001 y) (fma 0.125 (* a x) (atan2 1.0 (* 0.5 x)))) 1.0))
double code(double x, double y, double z, double a) { return fma((1.259921 / z), ((-0.5866665200000001 / y) * fma(0.125, (a * x), atan2(1.0, (0.5 * x)))), 1.0); }
function code(x, y, z, a) return fma(Float64(1.259921 / z), Float64(Float64(-0.5866665200000001 / y) * fma(0.125, Float64(a * x), atan(1.0, Float64(0.5 * x)))), 1.0) end
code[x_, y_, z_, a_] := N[(N[(1.259921 / z), $MachinePrecision] * N[(N[(-0.5866665200000001 / y), $MachinePrecision] * N[(0.125 * N[(a * x), $MachinePrecision] + N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\frac{1.259921}{z}, \frac{-0.5866665200000001}{y} \cdot \mathsf{fma}\left(0.125, a \cdot x, \tan^{-1}_* \frac{1}{0.5 \cdot x}\right), 1\right) \end{array}
Initial program 99.9%
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
lift-*.f64
N/A
distribute-lft-neg-in
N/A
lift-*.f64
N/A
*-commutative
N/A
distribute-rgt-neg-in
N/A
associate-*l*
N/A
lower-fma.f64
N/A
Applied rewrites100.0%
(FPCore (x y z a) :precision binary64 (- 1.0 (/ (* (fma 0.125 (* a x) (atan2 1.0 (* 0.5 x))) 0.7391534685449201) (* z y))))
double code(double x, double y, double z, double a) { return 1.0 - ((fma(0.125, (a * x), atan2(1.0, (0.5 * x))) * 0.7391534685449201) / (z * y)); }
function code(x, y, z, a) return Float64(1.0 - Float64(Float64(fma(0.125, Float64(a * x), atan(1.0, Float64(0.5 * x))) * 0.7391534685449201) / Float64(z * y))) end
code[x_, y_, z_, a_] := N[(1.0 - N[(N[(N[(0.125 * N[(a * x), $MachinePrecision] + N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.7391534685449201), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \frac{\mathsf{fma}\left(0.125, a \cdot x, \tan^{-1}_* \frac{1}{0.5 \cdot x}\right) \cdot 0.7391534685449201}{z \cdot y} \end{array}
Initial program 99.9%
lift-*.f64
N/A
*-commutative
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lift-/.f64
N/A
associate-*l/
N/A
lift-*.f64
N/A
lift-/.f64
N/A
un-div-inv
N/A
frac-times
N/A
associate-*r/
N/A
lower-/.f64
N/A
Applied rewrites100.0%
(FPCore (x y z a) :precision binary64 (fma (fma 0.125 (* a x) (atan2 1.0 (* 0.5 x))) (/ -0.7391534685449201 (* z y)) 1.0))
double code(double x, double y, double z, double a) { return fma(fma(0.125, (a * x), atan2(1.0, (0.5 * x))), (-0.7391534685449201 / (z * y)), 1.0); }
function code(x, y, z, a) return fma(fma(0.125, Float64(a * x), atan(1.0, Float64(0.5 * x))), Float64(-0.7391534685449201 / Float64(z * y)), 1.0) end
code[x_, y_, z_, a_] := N[(N[(0.125 * N[(a * x), $MachinePrecision] + N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.7391534685449201 / N[(z * y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(0.125, a \cdot x, \tan^{-1}_* \frac{1}{0.5 \cdot x}\right), \frac{-0.7391534685449201}{z \cdot y}, 1\right) \end{array}
Initial program 99.9%
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
lift-*.f64
N/A
*-commutative
N/A
distribute-rgt-neg-in
N/A
lower-fma.f64
N/A
Applied rewrites99.9%
(FPCore (x y z a) :precision binary64 (- 1.0 (* 0.7391534685449201 (/ (atan2 1.0 (* 0.5 x)) (* y z)))))
double code(double x, double y, double z, double a) { return 1.0 - (0.7391534685449201 * (atan2(1.0, (0.5 * x)) / (y * z))); }
real(8) function code(x, y, z, a) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z real(8), intent (in) :: a code = 1.0d0 - (0.7391534685449201d0 * (atan2(1.0d0, (0.5d0 * x)) / (y * z))) end function
public static double code(double x, double y, double z, double a) { return 1.0 - (0.7391534685449201 * (Math.atan2(1.0, (0.5 * x)) / (y * z))); }
def code(x, y, z, a): return 1.0 - (0.7391534685449201 * (math.atan2(1.0, (0.5 * x)) / (y * z)))
function code(x, y, z, a) return Float64(1.0 - Float64(0.7391534685449201 * Float64(atan(1.0, Float64(0.5 * x)) / Float64(y * z)))) end
function tmp = code(x, y, z, a) tmp = 1.0 - (0.7391534685449201 * (atan2(1.0, (0.5 * x)) / (y * z))); end
code[x_, y_, z_, a_] := N[(1.0 - N[(0.7391534685449201 * N[(N[ArcTan[1.0 / N[(0.5 * x), $MachinePrecision]], $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - 0.7391534685449201 \cdot \frac{\tan^{-1}_* \frac{1}{0.5 \cdot x}}{y \cdot z} \end{array}
Initial program 99.9%
Taylor expanded in x around 0
associate-*r/
N/A
*-commutative
N/A
times-frac
N/A
lower-*.f64
N/A
lower-/.f64
N/A
lower-/.f64
N/A
lower-atan2.f64
N/A
lower-*.f64
98.9
Applied rewrites98.9%
Applied rewrites98.9%
(FPCore (x y z a) :precision binary64 (fma (/ 1.259921 z) (* (* (/ x y) -0.07333331500000001) a) 1.0))
double code(double x, double y, double z, double a) { return fma((1.259921 / z), (((x / y) * -0.07333331500000001) * a), 1.0); }
function code(x, y, z, a) return fma(Float64(1.259921 / z), Float64(Float64(Float64(x / y) * -0.07333331500000001) * a), 1.0) end
code[x_, y_, z_, a_] := N[(N[(1.259921 / z), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] * -0.07333331500000001), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\frac{1.259921}{z}, \left(\frac{x}{y} \cdot -0.07333331500000001\right) \cdot a, 1\right) \end{array}
Initial program 99.9%
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
lift-*.f64
N/A
distribute-lft-neg-in
N/A
lift-*.f64
N/A
*-commutative
N/A
distribute-rgt-neg-in
N/A
associate-*l*
N/A
lower-fma.f64
N/A
Applied rewrites100.0%
Taylor expanded in x around inf
associate-/l*
N/A
*-commutative
N/A
associate-*l*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-/.f64
88.2
Applied rewrites88.2%
(FPCore (x y z a) :precision binary64 (- 1.0 (* (* (/ x (* z y)) 0.09239418356811502) a)))
double code(double x, double y, double z, double a) { return 1.0 - (((x / (z * y)) * 0.09239418356811502) * a); }
real(8) function code(x, y, z, a) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z real(8), intent (in) :: a code = 1.0d0 - (((x / (z * y)) * 0.09239418356811502d0) * a) end function
public static double code(double x, double y, double z, double a) { return 1.0 - (((x / (z * y)) * 0.09239418356811502) * a); }
def code(x, y, z, a): return 1.0 - (((x / (z * y)) * 0.09239418356811502) * a)
function code(x, y, z, a) return Float64(1.0 - Float64(Float64(Float64(x / Float64(z * y)) * 0.09239418356811502) * a)) end
function tmp = code(x, y, z, a) tmp = 1.0 - (((x / (z * y)) * 0.09239418356811502) * a); end
code[x_, y_, z_, a_] := N[(1.0 - N[(N[(N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.09239418356811502), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \left(\frac{x}{z \cdot y} \cdot 0.09239418356811502\right) \cdot a \end{array}
Initial program 99.9%
Taylor expanded in x around inf
associate-/l*
N/A
*-commutative
N/A
associate-*l*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
88.2
Applied rewrites88.2%
(FPCore (x y z a) :precision binary64 1.0)
double code(double x, double y, double z, double a) { return 1.0; }
real(8) function code(x, y, z, a) real(8), intent (in) :: x real(8), intent (in) :: y real(8), intent (in) :: z real(8), intent (in) :: a code = 1.0d0 end function
public static double code(double x, double y, double z, double a) { return 1.0; }
def code(x, y, z, a): return 1.0
function code(x, y, z, a) return 1.0 end
function tmp = code(x, y, z, a) tmp = 1.0; end
code[x_, y_, z_, a_] := 1.0
\begin{array}{l} \\ 1 \end{array}
Initial program 99.9%
Taylor expanded in y around inf
Applied rewrites88.0%
herbie shell --seed 1
(FPCore (x y z a)
:name "(- 1.0 (* (* (* (/ 0.44 y) 1.333333) (* 1.259921 (/ 1.0 z))) (+ (* (* x a) 0.125) (atan2 1.0 (* 0.5 x)))))"
:precision binary64
:pre (and (and (and (and (<= 2.555357e-104 x) (<= x 6467.788)) (and (<= 2.902009 y) (<= y 3.897777))) (and (<= 2.953531e-5 z) (<= z 5.565798e+102))) (and (<= -1434.343 a) (<= a -2.391224e-7)))
(- 1.0 (* (* (* (/ 0.44 y) 1.333333) (* 1.259921 (/ 1.0 z))) (+ (* (* x a) 0.125) (atan2 1.0 (* 0.5 x))))))