
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0
\end{array}
\end{array}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) angle)))
(*
(* (+ a b) (* (- b a) (* (sin (/ t_0 180.0)) 2.0)))
(cos (* -0.005555555555555556 t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot angle\\
\left(\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \left(\sin \left(\frac{t\_0}{180}\right) \cdot 2\right)\right)\right) \cdot \cos \left(-0.005555555555555556 \cdot t\_0\right)
\end{array}
\end{array}
Initial program 53.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift--.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
difference-of-squaresN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in angle around inf
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6467.7
Applied rewrites67.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) angle)))
(*
(* (+ a b) (* (- b a) (* (sin (* t_0 0.005555555555555556)) 2.0)))
(cos (* -0.005555555555555556 t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot angle\\
\left(\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \left(\sin \left(t\_0 \cdot 0.005555555555555556\right) \cdot 2\right)\right)\right) \cdot \cos \left(-0.005555555555555556 \cdot t\_0\right)
\end{array}
\end{array}
Initial program 53.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift--.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
difference-of-squaresN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in angle around inf
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6467.7
Applied rewrites67.7%
Taylor expanded in angle around inf
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6468.8
Applied rewrites68.8%
(FPCore (a b angle) :precision binary64 (if (<= (* 2.0 (- (pow b 2.0) (pow a 2.0))) 2e-276) (* (* (* (PI) angle) (* -0.011111111111111112 a)) a) (* (* (* (PI) (* b b)) angle) 0.011111111111111112)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot \left({b}^{2} - {a}^{2}\right) \leq 2 \cdot 10^{-276}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot \left(-0.011111111111111112 \cdot a\right)\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot \left(b \cdot b\right)\right) \cdot angle\right) \cdot 0.011111111111111112\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) < 2e-276Initial program 57.2%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6454.0
Applied rewrites54.0%
Taylor expanded in a around inf
Applied rewrites54.2%
Applied rewrites61.4%
if 2e-276 < (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) Initial program 48.1%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6448.8
Applied rewrites48.8%
Taylor expanded in a around 0
Applied rewrites50.2%
(FPCore (a b angle) :precision binary64 (if (<= angle 2e+177) (* (+ a b) (* (- b a) (sin (* 2.0 (* (/ angle 180.0) (PI)))))) (* (sin (* 0.011111111111111112 (* (PI) angle))) (fma (- a) a (* b b)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 2 \cdot 10^{+177}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.011111111111111112 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right) \cdot \mathsf{fma}\left(-a, a, b \cdot b\right)\\
\end{array}
\end{array}
if angle < 2e177Initial program 56.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift--.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
difference-of-squaresN/A
lift-sin.f64N/A
lift-cos.f64N/A
Applied rewrites69.9%
if 2e177 < angle Initial program 26.0%
Applied rewrites2.6%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
unpow2N/A
difference-of-squares-revN/A
+-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
Applied rewrites43.8%
(FPCore (a b angle) :precision binary64 (if (<= angle 1e-17) (* (- b a) (* (* (* 0.011111111111111112 angle) (PI)) (+ b a))) (* (sin (* 0.011111111111111112 (* (PI) angle))) (fma (- a) a (* b b)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 10^{-17}:\\
\;\;\;\;\left(b - a\right) \cdot \left(\left(\left(0.011111111111111112 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(b + a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.011111111111111112 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right) \cdot \mathsf{fma}\left(-a, a, b \cdot b\right)\\
\end{array}
\end{array}
if angle < 1.00000000000000007e-17Initial program 59.0%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6459.4
Applied rewrites59.4%
Applied rewrites73.1%
if 1.00000000000000007e-17 < angle Initial program 36.2%
Applied rewrites2.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
unpow2N/A
difference-of-squares-revN/A
+-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
Applied rewrites42.9%
(FPCore (a b angle) :precision binary64 (if (<= a 2.2e+152) (* angle (* 0.011111111111111112 (* (* (PI) (- b a)) (+ b a)))) (* (* -0.011111111111111112 a) (* a (* (PI) angle)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.2 \cdot 10^{+152}:\\
\;\;\;\;angle \cdot \left(0.011111111111111112 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(b - a\right)\right) \cdot \left(b + a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-0.011111111111111112 \cdot a\right) \cdot \left(a \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 2.1999999999999998e152Initial program 55.3%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6453.7
Applied rewrites53.7%
Applied rewrites53.3%
if 2.1999999999999998e152 < a Initial program 39.6%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6439.6
Applied rewrites39.6%
Taylor expanded in a around inf
Applied rewrites42.3%
Applied rewrites62.0%
(FPCore (a b angle) :precision binary64 (* (- b a) (* (* (* 0.011111111111111112 angle) (PI)) (+ b a))))
\begin{array}{l}
\\
\left(b - a\right) \cdot \left(\left(\left(0.011111111111111112 \cdot angle\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(b + a\right)\right)
\end{array}
Initial program 53.0%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6451.6
Applied rewrites51.6%
Applied rewrites61.7%
(FPCore (a b angle) :precision binary64 (* (* (* (PI) angle) (* -0.011111111111111112 a)) a))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot \left(-0.011111111111111112 \cdot a\right)\right) \cdot a
\end{array}
Initial program 53.0%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6451.6
Applied rewrites51.6%
Taylor expanded in a around inf
Applied rewrites34.2%
Applied rewrites39.3%
(FPCore (a b angle) :precision binary64 (* (* -0.011111111111111112 a) (* a (* (PI) angle))))
\begin{array}{l}
\\
\left(-0.011111111111111112 \cdot a\right) \cdot \left(a \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)
\end{array}
Initial program 53.0%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6451.6
Applied rewrites51.6%
Taylor expanded in a around inf
Applied rewrites34.2%
Applied rewrites39.2%
(FPCore (a b angle) :precision binary64 0.0)
double code(double a, double b, double angle) {
return 0.0;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = 0.0d0
end function
public static double code(double a, double b, double angle) {
return 0.0;
}
def code(a, b, angle): return 0.0
function code(a, b, angle) return 0.0 end
function tmp = code(a, b, angle) tmp = 0.0; end
code[a_, b_, angle_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 53.0%
Applied rewrites8.3%
lift-fma.f64N/A
lift-*.f64N/A
flip-+N/A
+-inversesN/A
+-inversesN/A
metadata-evalN/A
associate-*l/N/A
Applied rewrites3.7%
Taylor expanded in a around 0
Applied rewrites11.6%
herbie shell --seed 2024340
(FPCore (a b angle)
:name "ab-angle->ABCF B"
:precision binary64
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (PI) (/ angle 180.0)))) (cos (* (PI) (/ angle 180.0)))))