
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (cos t_0))
(t_2 (sin t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_2) t_1) x-scale)
y-scale))
(t_4
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) y-scale) y-scale))
(t_5
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) x-scale) x-scale)))
(*
180.0
(/
(atan
(/ (- (- t_4 t_5) (sqrt (+ (pow (- t_5 t_4) 2.0) (pow t_3 2.0)))) t_3))
(PI)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \cos t\_0\\
t_2 := \sin t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_2\right) \cdot t\_1}{x-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{y-scale}}{y-scale}\\
t_5 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{x-scale}}{x-scale}\\
180 \cdot \frac{\tan^{-1} \left(\frac{\left(t\_4 - t\_5\right) - \sqrt{{\left(t\_5 - t\_4\right)}^{2} + {t\_3}^{2}}}{t\_3}\right)}{\mathsf{PI}\left(\right)}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (cos t_0))
(t_2 (sin t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_2) t_1) x-scale)
y-scale))
(t_4
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) y-scale) y-scale))
(t_5
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) x-scale) x-scale)))
(*
180.0
(/
(atan
(/ (- (- t_4 t_5) (sqrt (+ (pow (- t_5 t_4) 2.0) (pow t_3 2.0)))) t_3))
(PI)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \cos t\_0\\
t_2 := \sin t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_2\right) \cdot t\_1}{x-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{y-scale}}{y-scale}\\
t_5 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{x-scale}}{x-scale}\\
180 \cdot \frac{\tan^{-1} \left(\frac{\left(t\_4 - t\_5\right) - \sqrt{{\left(t\_5 - t\_4\right)}^{2} + {t\_3}^{2}}}{t\_3}\right)}{\mathsf{PI}\left(\right)}
\end{array}
\end{array}
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (sqrt (PI)))
(t_1 (* (PI) angle))
(t_2 (* angle (PI)))
(t_3 (* 0.005555555555555556 t_2))
(t_4 (sin t_3))
(t_5 (cos t_3))
(t_6 (sin (* t_1 0.005555555555555556))))
(if (<= a_m 1.15e-79)
(*
180.0
(/
(atan
(*
0.5
(/
(* -2.0 (/ (* y-scale (pow t_5 2.0)) x-scale))
(* (cos (* (* (* 0.005555555555555556 angle) t_0) t_0)) t_4))))
(PI)))
(if (<= a_m 2.45e-11)
(*
180.0
(/
(atan
(*
-0.5
(*
(*
2.0
(/
(* (* a_m a_m) t_4)
(* x-scale (cos (* -0.005555555555555556 t_2)))))
(/ y-scale (* (- b a_m) (+ b a_m))))))
(PI)))
(if (<= a_m 3.2e+111)
(/
(*
(atan
(*
(* -0.5 (/ y-scale x-scale))
(/
(*
(+
(pow (* t_6 a_m) 2.0)
(pow (* b (cos (* t_1 -0.005555555555555556))) 2.0))
2.0)
(* (* t_6 (- b a_m)) (+ b a_m)))))
180.0)
(PI))
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_4 t_5))) (PI))))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
t_1 := \mathsf{PI}\left(\right) \cdot angle\\
t_2 := angle \cdot \mathsf{PI}\left(\right)\\
t_3 := 0.005555555555555556 \cdot t\_2\\
t_4 := \sin t\_3\\
t_5 := \cos t\_3\\
t_6 := \sin \left(t\_1 \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a\_m \leq 1.15 \cdot 10^{-79}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot {t\_5}^{2}}{x-scale}}{\cos \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_4}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;a\_m \leq 2.45 \cdot 10^{-11}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-0.5 \cdot \left(\left(2 \cdot \frac{\left(a\_m \cdot a\_m\right) \cdot t\_4}{x-scale \cdot \cos \left(-0.005555555555555556 \cdot t\_2\right)}\right) \cdot \frac{y-scale}{\left(b - a\_m\right) \cdot \left(b + a\_m\right)}\right)\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;a\_m \leq 3.2 \cdot 10^{+111}:\\
\;\;\;\;\frac{\tan^{-1} \left(\left(-0.5 \cdot \frac{y-scale}{x-scale}\right) \cdot \frac{\left({\left(t\_6 \cdot a\_m\right)}^{2} + {\left(b \cdot \cos \left(t\_1 \cdot -0.005555555555555556\right)\right)}^{2}\right) \cdot 2}{\left(t\_6 \cdot \left(b - a\_m\right)\right) \cdot \left(b + a\_m\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_4}{t\_5}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if a < 1.15000000000000006e-79Initial program 16.8%
Taylor expanded in b around inf
Applied rewrites27.6%
Taylor expanded in x-scale around 0
Applied rewrites51.5%
Applied rewrites52.5%
if 1.15000000000000006e-79 < a < 2.4499999999999999e-11Initial program 12.6%
Taylor expanded in x-scale around 0
Applied rewrites42.9%
Applied rewrites35.9%
Taylor expanded in a around inf
Applied rewrites49.0%
if 2.4499999999999999e-11 < a < 3.2000000000000001e111Initial program 19.3%
Taylor expanded in x-scale around 0
Applied rewrites50.6%
Taylor expanded in angle around 0
Applied rewrites50.3%
Applied rewrites73.2%
if 3.2000000000000001e111 < a Initial program 0.1%
Taylor expanded in x-scale around 0
Applied rewrites18.8%
Taylor expanded in a around inf
Applied rewrites69.2%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (cos t_0))
(t_2 (* (PI) (PI)))
(t_3 (sin t_0))
(t_4
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a_m 2.0))) t_3) t_1) x-scale)
y-scale))
(t_5
(/ (/ (+ (pow (* a_m t_3) 2.0) (pow (* b t_1) 2.0)) x-scale) x-scale))
(t_6
(/
(/ (+ (pow (* a_m t_1) 2.0) (pow (* b t_3) 2.0)) y-scale)
y-scale)))
(if (<=
(/ (- (- t_6 t_5) (sqrt (+ (pow (- t_5 t_6) 2.0) (pow t_4 2.0)))) t_4)
1e+290)
(*
180.0
(/
(atan
(*
-0.5
(/
(*
y-scale
(*
2.0
(fma
(* angle angle)
(fma
-3.08641975308642e-5
(* (* b b) t_2)
(* 3.08641975308642e-5 (* (* a_m a_m) t_2)))
(* b b))))
(*
x-scale
(*
(sin (* 0.005555555555555556 (* angle (PI))))
(- (* b b) (* a_m a_m)))))))
(PI)))
(*
180.0
(/
(atan
(*
90.0
(*
x-scale
(* -2.0 (/ y-scale (* angle (* (* x-scale x-scale) (PI))))))))
(PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \cos t\_0\\
t_2 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
t_3 := \sin t\_0\\
t_4 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a\_m}^{2}\right)\right) \cdot t\_3\right) \cdot t\_1}{x-scale}}{y-scale}\\
t_5 := \frac{\frac{{\left(a\_m \cdot t\_3\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{x-scale}}{x-scale}\\
t_6 := \frac{\frac{{\left(a\_m \cdot t\_1\right)}^{2} + {\left(b \cdot t\_3\right)}^{2}}{y-scale}}{y-scale}\\
\mathbf{if}\;\frac{\left(t\_6 - t\_5\right) - \sqrt{{\left(t\_5 - t\_6\right)}^{2} + {t\_4}^{2}}}{t\_4} \leq 10^{+290}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-0.5 \cdot \frac{y-scale \cdot \left(2 \cdot \mathsf{fma}\left(angle \cdot angle, \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot t\_2, 3.08641975308642 \cdot 10^{-5} \cdot \left(\left(a\_m \cdot a\_m\right) \cdot t\_2\right)\right), b \cdot b\right)\right)}{x-scale \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(b \cdot b - a\_m \cdot a\_m\right)\right)}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(90 \cdot \left(x-scale \cdot \left(-2 \cdot \frac{y-scale}{angle \cdot \left(\left(x-scale \cdot x-scale\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (-.f64 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (sqrt.f64 (+.f64 (pow.f64 (-.f64 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale)) #s(literal 2 binary64)) (pow.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) #s(literal 2 binary64))))) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) < 1.00000000000000006e290Initial program 47.0%
Taylor expanded in x-scale around 0
Applied rewrites59.3%
Taylor expanded in angle around 0
Applied rewrites52.7%
Taylor expanded in angle around 0
Applied rewrites52.3%
if 1.00000000000000006e290 < (/.f64 (-.f64 (-.f64 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (sqrt.f64 (+.f64 (pow.f64 (-.f64 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale)) #s(literal 2 binary64)) (pow.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) #s(literal 2 binary64))))) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) Initial program 7.3%
Taylor expanded in angle around 0
Applied rewrites9.8%
Taylor expanded in x-scale around inf
Applied rewrites10.8%
Taylor expanded in a around 0
Applied rewrites41.0%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (sqrt (PI)))
(t_1 (* (PI) angle))
(t_2 (* angle (PI)))
(t_3 (* 0.005555555555555556 t_2))
(t_4 (sin t_3))
(t_5 (cos t_3))
(t_6 (sin (* t_1 0.005555555555555556))))
(if (<= a_m 1.15e-79)
(*
180.0
(/
(atan
(*
0.5
(/
(* -2.0 (/ (* y-scale (pow t_5 2.0)) x-scale))
(* (cos (* (* (* 0.005555555555555556 angle) t_0) t_0)) t_4))))
(PI)))
(if (<= a_m 4.4e-13)
(*
180.0
(/
(atan
(*
-0.5
(*
(*
2.0
(/
(* (* a_m a_m) t_4)
(* x-scale (cos (* -0.005555555555555556 t_2)))))
(/ y-scale (* (- b a_m) (+ b a_m))))))
(PI)))
(if (<= a_m 3e+111)
(*
180.0
(/
(atan
(/
(*
(/
(*
(* y-scale 2.0)
(+
(pow (* t_6 a_m) 2.0)
(pow (* b (cos (* t_1 -0.005555555555555556))) 2.0)))
x-scale)
-0.5)
(* (* t_6 (- b a_m)) (+ b a_m))))
(PI)))
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_4 t_5))) (PI))))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
t_1 := \mathsf{PI}\left(\right) \cdot angle\\
t_2 := angle \cdot \mathsf{PI}\left(\right)\\
t_3 := 0.005555555555555556 \cdot t\_2\\
t_4 := \sin t\_3\\
t_5 := \cos t\_3\\
t_6 := \sin \left(t\_1 \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a\_m \leq 1.15 \cdot 10^{-79}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot {t\_5}^{2}}{x-scale}}{\cos \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_4}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;a\_m \leq 4.4 \cdot 10^{-13}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-0.5 \cdot \left(\left(2 \cdot \frac{\left(a\_m \cdot a\_m\right) \cdot t\_4}{x-scale \cdot \cos \left(-0.005555555555555556 \cdot t\_2\right)}\right) \cdot \frac{y-scale}{\left(b - a\_m\right) \cdot \left(b + a\_m\right)}\right)\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;a\_m \leq 3 \cdot 10^{+111}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\frac{\left(y-scale \cdot 2\right) \cdot \left({\left(t\_6 \cdot a\_m\right)}^{2} + {\left(b \cdot \cos \left(t\_1 \cdot -0.005555555555555556\right)\right)}^{2}\right)}{x-scale} \cdot -0.5}{\left(t\_6 \cdot \left(b - a\_m\right)\right) \cdot \left(b + a\_m\right)}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_4}{t\_5}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if a < 1.15000000000000006e-79Initial program 16.8%
Taylor expanded in b around inf
Applied rewrites27.6%
Taylor expanded in x-scale around 0
Applied rewrites51.5%
Applied rewrites52.5%
if 1.15000000000000006e-79 < a < 4.39999999999999993e-13Initial program 12.6%
Taylor expanded in x-scale around 0
Applied rewrites42.9%
Applied rewrites35.9%
Taylor expanded in a around inf
Applied rewrites49.0%
if 4.39999999999999993e-13 < a < 3e111Initial program 19.3%
Taylor expanded in x-scale around 0
Applied rewrites50.6%
Taylor expanded in angle around 0
Applied rewrites50.3%
Applied rewrites73.1%
if 3e111 < a Initial program 0.1%
Taylor expanded in x-scale around 0
Applied rewrites18.8%
Taylor expanded in a around inf
Applied rewrites69.2%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin t_0))
(t_2 (sqrt (PI)))
(t_3 (* (* (* 0.005555555555555556 angle) t_2) t_2))
(t_4 (cos t_0))
(t_5 (fma (* 0.005555555555555556 angle) (PI) (/ (PI) 2.0)))
(t_6 (* (* (PI) angle) 0.005555555555555556)))
(if (<= b 1.1e-80)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_1 t_4))) (PI)))
(if (<= b 7.6e-14)
(*
180.0
(/
(atan
(*
0.5
(/
(*
-2.0
(/
(* y-scale (/ (+ (sin (- t_5 t_6)) (sin (+ t_5 t_6))) 2.0))
x-scale))
(* t_4 (sin t_3)))))
(PI)))
(*
180.0
(/
(atan
(*
0.5
(/
(* -2.0 (/ (* y-scale (pow t_4 2.0)) x-scale))
(* (cos t_3) t_1))))
(PI)))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \sqrt{\mathsf{PI}\left(\right)}\\
t_3 := \left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_2\right) \cdot t\_2\\
t_4 := \cos t\_0\\
t_5 := \mathsf{fma}\left(0.005555555555555556 \cdot angle, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\\
t_6 := \left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\\
\mathbf{if}\;b \leq 1.1 \cdot 10^{-80}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{t\_4}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-14}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot \frac{\sin \left(t\_5 - t\_6\right) + \sin \left(t\_5 + t\_6\right)}{2}}{x-scale}}{t\_4 \cdot \sin t\_3}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot {t\_4}^{2}}{x-scale}}{\cos t\_3 \cdot t\_1}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 1.10000000000000005e-80Initial program 13.1%
Taylor expanded in x-scale around 0
Applied rewrites32.8%
Taylor expanded in a around inf
Applied rewrites45.7%
if 1.10000000000000005e-80 < b < 7.6000000000000004e-14Initial program 54.5%
Taylor expanded in b around inf
Applied rewrites38.9%
Taylor expanded in x-scale around 0
Applied rewrites62.9%
Applied rewrites70.5%
Applied rewrites71.2%
if 7.6000000000000004e-14 < b Initial program 9.7%
Taylor expanded in b around inf
Applied rewrites26.6%
Taylor expanded in x-scale around 0
Applied rewrites54.7%
Applied rewrites56.8%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (sqrt (PI)))
(t_1 (* 0.005555555555555556 (* angle (PI))))
(t_2 (cos t_1))
(t_3 (* (* (* 0.005555555555555556 angle) t_0) t_0))
(t_4 (sin t_1))
(t_5 (* -2.0 (/ (* y-scale (pow t_2 2.0)) x-scale))))
(if (<= b 1.1e-80)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_4 t_2))) (PI)))
(if (<= b 1.4e-20)
(*
180.0
(/
(atan
(*
0.5
(/
t_5
(*
(sin (fma (* 0.005555555555555556 angle) (PI) (/ (PI) 2.0)))
(sin t_3)))))
(PI)))
(* 180.0 (/ (atan (* 0.5 (/ t_5 (* (cos t_3) t_4)))) (PI)))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
t_1 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_2 := \cos t\_1\\
t_3 := \left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_0\right) \cdot t\_0\\
t_4 := \sin t\_1\\
t_5 := -2 \cdot \frac{y-scale \cdot {t\_2}^{2}}{x-scale}\\
\mathbf{if}\;b \leq 1.1 \cdot 10^{-80}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_4}{t\_2}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-20}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{t\_5}{\sin \left(\mathsf{fma}\left(0.005555555555555556 \cdot angle, \mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \sin t\_3}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{t\_5}{\cos t\_3 \cdot t\_4}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 1.10000000000000005e-80Initial program 13.1%
Taylor expanded in x-scale around 0
Applied rewrites32.8%
Taylor expanded in a around inf
Applied rewrites45.7%
if 1.10000000000000005e-80 < b < 1.4000000000000001e-20Initial program 59.0%
Taylor expanded in b around inf
Applied rewrites33.8%
Taylor expanded in x-scale around 0
Applied rewrites67.9%
Applied rewrites76.1%
Applied rewrites77.9%
if 1.4000000000000001e-20 < b Initial program 9.5%
Taylor expanded in b around inf
Applied rewrites27.7%
Taylor expanded in x-scale around 0
Applied rewrites54.0%
Applied rewrites56.0%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3 (sqrt (PI))))
(if (<= b 1.2e-80)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_1 t_2))) (PI)))
(*
180.0
(/
(atan
(*
0.5
(/
(* -2.0 (/ (* y-scale (pow t_2 2.0)) x-scale))
(* (cos (* (* (* 0.005555555555555556 angle) t_3) t_3)) t_1))))
(PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;b \leq 1.2 \cdot 10^{-80}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{t\_2}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot {t\_2}^{2}}{x-scale}}{\cos \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_3\right) \cdot t\_3\right) \cdot t\_1}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 1.2e-80Initial program 13.1%
Taylor expanded in x-scale around 0
Applied rewrites32.8%
Taylor expanded in a around inf
Applied rewrites45.7%
if 1.2e-80 < b Initial program 17.1%
Taylor expanded in b around inf
Applied rewrites28.7%
Taylor expanded in x-scale around 0
Applied rewrites56.1%
Applied rewrites57.8%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin t_0))
(t_2 (cos t_0)))
(if (<= b 7.6e-64)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_1 t_2))) (PI)))
(*
180.0
(/
(atan
(*
0.5
(/
(*
-2.0
(/
(*
y-scale
(pow
(sin (fma (* (PI) angle) 0.005555555555555556 (/ (PI) 2.0)))
2.0))
x-scale))
(* t_2 t_1))))
(PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
\mathbf{if}\;b \leq 7.6 \cdot 10^{-64}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{t\_2}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot {\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot angle, 0.005555555555555556, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}^{2}}{x-scale}}{t\_2 \cdot t\_1}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 7.6000000000000003e-64Initial program 13.9%
Taylor expanded in x-scale around 0
Applied rewrites33.7%
Taylor expanded in a around inf
Applied rewrites46.4%
if 7.6000000000000003e-64 < b Initial program 15.3%
Taylor expanded in b around inf
Applied rewrites28.8%
Taylor expanded in x-scale around 0
Applied rewrites57.7%
Applied rewrites57.7%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin t_0))
(t_2 (cos t_0)))
(if (<= b 7.6e-64)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_1 t_2))) (PI)))
(*
180.0
(/
(atan
(*
0.5
(/
(*
-2.0
(/
(*
y-scale
(-
0.5
(*
0.5
(cos
(*
2.0
(fma (* (PI) angle) 0.005555555555555556 (/ (PI) 2.0)))))))
x-scale))
(* t_2 t_1))))
(PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
\mathbf{if}\;b \leq 7.6 \cdot 10^{-64}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{t\_2}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{-2 \cdot \frac{y-scale \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot angle, 0.005555555555555556, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right)}{x-scale}}{t\_2 \cdot t\_1}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 7.6000000000000003e-64Initial program 13.9%
Taylor expanded in x-scale around 0
Applied rewrites33.7%
Taylor expanded in a around inf
Applied rewrites46.4%
if 7.6000000000000003e-64 < b Initial program 15.3%
Taylor expanded in b around inf
Applied rewrites28.8%
Taylor expanded in x-scale around 0
Applied rewrites57.7%
Applied rewrites57.7%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin t_0))
(t_2 (cos t_0)))
(if (<= b 7.6e-64)
(* 180.0 (/ (atan (* (/ y-scale x-scale) (/ t_1 t_2))) (PI)))
(* 180.0 (/ (atan (* (/ (- y-scale) x-scale) (/ t_2 t_1))) (PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
\mathbf{if}\;b \leq 7.6 \cdot 10^{-64}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{t\_2}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{-y-scale}{x-scale} \cdot \frac{t\_2}{t\_1}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 7.6000000000000003e-64Initial program 13.9%
Taylor expanded in x-scale around 0
Applied rewrites33.7%
Taylor expanded in a around inf
Applied rewrites46.4%
if 7.6000000000000003e-64 < b Initial program 15.3%
Taylor expanded in b around inf
Applied rewrites28.8%
Taylor expanded in x-scale around 0
Applied rewrites57.7%
Applied rewrites56.9%
Taylor expanded in x-scale around 0
Applied rewrites57.7%
Final simplification49.7%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI)))))
(if (<= a_m 9.8e-84)
(*
180.0
(/ (atan (* -180.0 (/ y-scale (* angle (* x-scale (PI)))))) (PI)))
(*
180.0
(/ (atan (* (/ y-scale x-scale) (/ (sin t_0) (cos t_0)))) (PI))))))\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;a\_m \leq 9.8 \cdot 10^{-84}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-180 \cdot \frac{y-scale}{angle \cdot \left(x-scale \cdot \mathsf{PI}\left(\right)\right)}\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{\sin t\_0}{\cos t\_0}\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if a < 9.79999999999999961e-84Initial program 17.0%
Taylor expanded in angle around 0
Applied rewrites15.4%
Taylor expanded in a around 0
Applied rewrites38.9%
if 9.79999999999999961e-84 < a Initial program 8.9%
Taylor expanded in x-scale around 0
Applied rewrites33.7%
Taylor expanded in a around inf
Applied rewrites57.4%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(*
180.0
(/
(atan
(*
90.0
(* x-scale (* -2.0 (/ y-scale (* angle (* (* x-scale x-scale) (PI))))))))
(PI))))\begin{array}{l}
a_m = \left|a\right|
\\
180 \cdot \frac{\tan^{-1} \left(90 \cdot \left(x-scale \cdot \left(-2 \cdot \frac{y-scale}{angle \cdot \left(\left(x-scale \cdot x-scale\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 14.3%
Taylor expanded in angle around 0
Applied rewrites12.7%
Taylor expanded in x-scale around inf
Applied rewrites12.0%
Taylor expanded in a around 0
Applied rewrites40.5%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* 180.0 (/ (atan (* -180.0 (/ y-scale (* angle (* x-scale (PI)))))) (PI))))
\begin{array}{l}
a_m = \left|a\right|
\\
180 \cdot \frac{\tan^{-1} \left(-180 \cdot \frac{y-scale}{angle \cdot \left(x-scale \cdot \mathsf{PI}\left(\right)\right)}\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 14.3%
Taylor expanded in angle around 0
Applied rewrites12.7%
Taylor expanded in a around 0
Applied rewrites35.7%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* 180.0 (/ (atan (* -180.0 (/ x-scale (* angle (* y-scale (PI)))))) (PI))))
\begin{array}{l}
a_m = \left|a\right|
\\
180 \cdot \frac{\tan^{-1} \left(-180 \cdot \frac{x-scale}{angle \cdot \left(y-scale \cdot \mathsf{PI}\left(\right)\right)}\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 14.3%
Taylor expanded in angle around 0
Applied rewrites12.7%
Taylor expanded in a around inf
Applied rewrites13.2%
herbie shell --seed 2025018
(FPCore (a b angle x-scale y-scale)
:name "raw-angle from scale-rotated-ellipse"
:precision binary64
(* 180.0 (/ (atan (/ (- (- (/ (/ (+ (pow (* a (cos (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (sin (* (/ angle 180.0) (PI)))) 2.0)) y-scale) y-scale) (/ (/ (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0)) x-scale) x-scale)) (sqrt (+ (pow (- (/ (/ (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0)) x-scale) x-scale) (/ (/ (+ (pow (* a (cos (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (sin (* (/ angle 180.0) (PI)))) 2.0)) y-scale) y-scale)) 2.0) (pow (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) (PI)))) (cos (* (/ angle 180.0) (PI)))) x-scale) y-scale) 2.0)))) (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) (PI)))) (cos (* (/ angle 180.0) (PI)))) x-scale) y-scale))) (PI))))