(FPCore (ang) :precision binary64 (fabs (- (/ 1.0 (tan (* (/ ang 180.0) (PI)))) 1.0)))
\begin{array}{l} \\ \left|\frac{1}{\tan \left(\frac{ang}{180} \cdot \mathsf{PI}\left(\right)\right)} - 1\right| \end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (ang) :precision binary64 (fabs (- (/ 1.0 (tan (* (/ ang 180.0) (PI)))) 1.0)))
\begin{array}{l} \\ \left|\frac{1}{\tan \left(\frac{ang}{180} \cdot \mathsf{PI}\left(\right)\right)} - 1\right| \end{array}
(FPCore (ang) :precision binary64 (let* ((t_0 (* (* (PI) 0.005555555555555556) ang))) (fabs (+ -1.0 (/ (cos t_0) (sin t_0))))))
\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot ang\\ \left|-1 + \frac{\cos t\_0}{\sin t\_0}\right| \end{array} \end{array}
Initial program 99.3%
Taylor expanded in ang around inf
lower-/.f64
N/A
*-commutative
N/A
associate-*r*
N/A
*-commutative
N/A
lower-cos.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
N/A
*-commutative
N/A
associate-*r*
N/A
*-commutative
N/A
lower-sin.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
99.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (ang) :precision binary64 (fabs (- -1.0 (/ -1.0 (tan (* (* 0.005555555555555556 ang) (PI)))))))
\begin{array}{l} \\ \left|-1 - \frac{-1}{\tan \left(\left(0.005555555555555556 \cdot ang\right) \cdot \mathsf{PI}\left(\right)\right)}\right| \end{array}
Initial program 99.3%
lift-/.f64
N/A
clear-num
N/A
associate-/r/
N/A
lower-*.f64
N/A
metadata-eval
99.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (ang) :precision binary64 (fabs (/ (fma (fma (* -32400.0 ang) (* (PI) 5.7155921353452215e-8) -1.0) ang (/ 180.0 (PI))) ang)))
\begin{array}{l} \\ \left|\frac{\mathsf{fma}\left(\mathsf{fma}\left(-32400 \cdot ang, \mathsf{PI}\left(\right) \cdot 5.7155921353452215 \cdot 10^{-8}, -1\right), ang, \frac{180}{\mathsf{PI}\left(\right)}\right)}{ang}\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
lower-/.f64
N/A
Applied rewrites99.2%
Final simplification99.2%
(FPCore (ang) :precision binary64 (fabs (+ -1.0 (/ (fma (* (* -0.001851851851851852 (PI)) ang) ang (/ 180.0 (PI))) ang))))
\begin{array}{l} \\ \left|-1 + \frac{\mathsf{fma}\left(\left(-0.001851851851851852 \cdot \mathsf{PI}\left(\right)\right) \cdot ang, ang, \frac{180}{\mathsf{PI}\left(\right)}\right)}{ang}\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around inf
lower-/.f64
N/A
*-commutative
N/A
associate-*r*
N/A
*-commutative
N/A
lower-cos.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
N/A
*-commutative
N/A
associate-*r*
N/A
*-commutative
N/A
lower-sin.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
99.5
Applied rewrites99.5%
Taylor expanded in ang around 0
Applied rewrites99.2%
Final simplification99.2%
(FPCore (ang) :precision binary64 (fabs (/ (- (/ 180.0 (PI)) ang) ang)))
\begin{array}{l} \\ \left|\frac{\frac{180}{\mathsf{PI}\left(\right)} - ang}{ang}\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
lower-/.f64
N/A
+-commutative
N/A
mul-1-neg
N/A
unsub-neg
N/A
lower--.f64
N/A
associate-*r/
N/A
metadata-eval
N/A
lower-/.f64
N/A
lower-PI.f64
98.6
Applied rewrites98.6%
(FPCore (ang) :precision binary64 (fabs (- -1.0 (/ -1.0 (* (* (PI) 0.005555555555555556) ang)))))
\begin{array}{l} \\ \left|-1 - \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot ang}\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
*-commutative
N/A
associate-*r*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
98.5
Applied rewrites98.5%
Final simplification98.5%
(FPCore (ang) :precision binary64 (fabs (- (/ 180.0 (* (PI) ang)) 1.0)))
\begin{array}{l} \\ \left|\frac{180}{\mathsf{PI}\left(\right) \cdot ang} - 1\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
lower-/.f64
N/A
+-commutative
N/A
mul-1-neg
N/A
unsub-neg
N/A
lower--.f64
N/A
associate-*r/
N/A
metadata-eval
N/A
lower-/.f64
N/A
lower-PI.f64
98.6
Applied rewrites98.6%
Applied rewrites98.4%
(FPCore (ang) :precision binary64 (fabs (/ 180.0 (* (PI) ang))))
\begin{array}{l} \\ \left|\frac{180}{\mathsf{PI}\left(\right) \cdot ang}\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
lower-PI.f64
97.8
Applied rewrites97.8%
(FPCore (ang) :precision binary64 (fabs -1.0))
double code(double ang) { return fabs(-1.0); }
real(8) function code(ang) real(8), intent (in) :: ang code = abs((-1.0d0)) end function
public static double code(double ang) { return Math.abs(-1.0); }
def code(ang): return math.fabs(-1.0)
function code(ang) return abs(-1.0) end
function tmp = code(ang) tmp = abs(-1.0); end
code[ang_] := N[Abs[-1.0], $MachinePrecision]
\begin{array}{l} \\ \left|-1\right| \end{array}
Initial program 99.3%
Taylor expanded in ang around 0
lower-/.f64
N/A
+-commutative
N/A
mul-1-neg
N/A
unsub-neg
N/A
lower--.f64
N/A
associate-*r/
N/A
metadata-eval
N/A
lower-/.f64
N/A
lower-PI.f64
98.6
Applied rewrites98.6%
Taylor expanded in ang around inf
Applied rewrites5.1%
herbie shell --seed 1
(FPCore (ang)
:name "abs(1 / tan(ang / 180 * PI) - 1)"
:precision binary64
:pre (and (<= 0.0 ang) (<= ang 90.0))
(fabs (- (/ 1.0 (tan (* (/ ang 180.0) (PI)))) 1.0)))