
(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 12 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}
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI)))) (t_1 (sin t_0)))
(if (<= b_m 118000.0)
(/ (* (atan (* (/ y-scale x-scale) (/ t_1 (cos t_0)))) 180.0) (PI))
(/
(*
(atan
(/
(fma
(cos (fma (* -0.005555555555555556 (PI)) angle (PI)))
y-scale
0.0)
(* x-scale t_1)))
180.0)
(PI)))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin t\_0\\
\mathbf{if}\;b\_m \leq 118000:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_1}{\cos t\_0}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{\mathsf{fma}\left(\cos \left(\mathsf{fma}\left(-0.005555555555555556 \cdot \mathsf{PI}\left(\right), angle, \mathsf{PI}\left(\right)\right)\right), y-scale, 0\right)}{x-scale \cdot t\_1}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 118000Initial program 15.9%
Taylor expanded in x-scale around 0
Applied rewrites30.2%
Applied rewrites37.6%
Taylor expanded in a around inf
Applied rewrites46.8%
if 118000 < b Initial program 11.6%
Taylor expanded in x-scale around 0
Applied rewrites26.6%
Applied rewrites42.1%
Taylor expanded in b around inf
Applied rewrites55.4%
Applied rewrites59.5%
Final simplification49.4%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (cos t_0))
(t_2 (sin t_0)))
(if (<= a 1.22e-21)
(/ (* (atan (/ (* (- y-scale) t_1) (* x-scale t_2))) 180.0) (PI))
(/ (* (atan (* (/ y-scale x-scale) (/ t_2 t_1))) 180.0) (PI)))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \cos t\_0\\
t_2 := \sin t\_0\\
\mathbf{if}\;a \leq 1.22 \cdot 10^{-21}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{\left(-y-scale\right) \cdot t\_1}{x-scale \cdot t\_2}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{y-scale}{x-scale} \cdot \frac{t\_2}{t\_1}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if a < 1.21999999999999991e-21Initial program 18.4%
Taylor expanded in x-scale around 0
Applied rewrites31.7%
Applied rewrites40.0%
Taylor expanded in b around inf
Applied rewrites51.3%
Taylor expanded in a around 0
Applied rewrites51.3%
if 1.21999999999999991e-21 < a Initial program 6.0%
Taylor expanded in x-scale around 0
Applied rewrites23.4%
Applied rewrites34.6%
Taylor expanded in a around inf
Applied rewrites49.2%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* angle (PI))))
(t_1 (sin (* (* (PI) angle) 0.005555555555555556)))
(t_2 (* (PI) (PI))))
(if (<= a 2.8e-13)
(/
(* (atan (/ (* (- y-scale) (cos t_0)) (* x-scale (sin t_0)))) 180.0)
(PI))
(if (<= a 6.5e+149)
(*
180.0
(/
(atan
(*
(/
(*
2.0
(fma
(* (* angle angle) y-scale)
(fma
(* -3.08641975308642e-5 (* b_m b_m))
t_2
(* (* 3.08641975308642e-5 (* a a)) t_2))
(* (* b_m b_m) y-scale)))
(* (* x-scale 1.0) (* (* (+ b_m a) (- b_m a)) t_1)))
-0.5))
(PI)))
(*
180.0
(/
(atan (* (* (* (/ y-scale x-scale) (/ 1.0 t_1)) 2.0) -0.5))
(PI)))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)\\
t_2 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;a \leq 2.8 \cdot 10^{-13}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{\left(-y-scale\right) \cdot \cos t\_0}{x-scale \cdot \sin t\_0}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;a \leq 6.5 \cdot 10^{+149}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{2 \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot y-scale, \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(b\_m \cdot b\_m\right), t\_2, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot t\_2\right), \left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(x-scale \cdot 1\right) \cdot \left(\left(\left(b\_m + a\right) \cdot \left(b\_m - a\right)\right) \cdot t\_1\right)} \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{1}{t\_1}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if a < 2.8000000000000002e-13Initial program 18.1%
Taylor expanded in x-scale around 0
Applied rewrites31.1%
Applied rewrites39.8%
Taylor expanded in b around inf
Applied rewrites50.9%
Taylor expanded in a around 0
Applied rewrites50.9%
if 2.8000000000000002e-13 < a < 6.50000000000000015e149Initial program 11.3%
Taylor expanded in x-scale around 0
Applied rewrites44.7%
Taylor expanded in angle around 0
Applied rewrites44.1%
Taylor expanded in angle around 0
Applied rewrites54.7%
if 6.50000000000000015e149 < a Initial program 0.0%
Taylor expanded in x-scale around 0
Applied rewrites0.0%
Taylor expanded in a around 0
Applied rewrites31.8%
Taylor expanded in angle around 0
Applied rewrites30.5%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (sin (* (* (PI) angle) 0.005555555555555556)))
(t_1 (* (PI) (PI))))
(if (<= b_m 6.2e-176)
(*
180.0
(/ (atan (* (* (* (/ y-scale x-scale) (/ 1.0 t_0)) 2.0) -0.5)) (PI)))
(if (<= b_m 2.15e+69)
(*
180.0
(/
(atan
(*
(/
(*
2.0
(fma
(* (* angle angle) y-scale)
(fma
(* -3.08641975308642e-5 (* b_m b_m))
t_1
(* (* 3.08641975308642e-5 (* a a)) t_1))
(* (* b_m b_m) y-scale)))
(* (* x-scale 1.0) (* (* (+ b_m a) (- b_m a)) t_0)))
-0.5))
(PI)))
(if (<= b_m 3.3e+190)
(*
180.0
(/
(atan
(*
(*
(*
(/ y-scale x-scale)
(/ (fma (* -1.54320987654321e-5 (* angle angle)) t_1 1.0) t_0))
2.0)
-0.5))
(PI)))
(/
(*
(atan
(/
(- y-scale)
(* x-scale (sin (* 0.005555555555555556 (* angle (PI)))))))
180.0)
(PI)))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;b\_m \leq 6.2 \cdot 10^{-176}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{1}{t\_0}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b\_m \leq 2.15 \cdot 10^{+69}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{2 \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot y-scale, \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(b\_m \cdot b\_m\right), t\_1, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot t\_1\right), \left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(x-scale \cdot 1\right) \cdot \left(\left(\left(b\_m + a\right) \cdot \left(b\_m - a\right)\right) \cdot t\_0\right)} \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b\_m \leq 3.3 \cdot 10^{+190}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{\mathsf{fma}\left(-1.54320987654321 \cdot 10^{-5} \cdot \left(angle \cdot angle\right), t\_1, 1\right)}{t\_0}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-y-scale}{x-scale \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 6.19999999999999983e-176Initial program 15.3%
Taylor expanded in x-scale around 0
Applied rewrites28.3%
Taylor expanded in a around 0
Applied rewrites48.0%
Taylor expanded in angle around 0
Applied rewrites43.6%
if 6.19999999999999983e-176 < b < 2.14999999999999996e69Initial program 20.7%
Taylor expanded in x-scale around 0
Applied rewrites46.1%
Taylor expanded in angle around 0
Applied rewrites44.6%
Taylor expanded in angle around 0
Applied rewrites46.3%
if 2.14999999999999996e69 < b < 3.3e190Initial program 14.0%
Taylor expanded in x-scale around 0
Applied rewrites27.7%
Taylor expanded in a around 0
Applied rewrites52.1%
Taylor expanded in angle around 0
Applied rewrites60.1%
if 3.3e190 < b Initial program 0.0%
Taylor expanded in x-scale around 0
Applied rewrites0.0%
Applied rewrites24.6%
Taylor expanded in b around inf
Applied rewrites60.3%
Taylor expanded in angle around 0
Applied rewrites68.6%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (sin (* (* (PI) angle) 0.005555555555555556))))
(if (<= x-scale -3.3e-38)
(*
180.0
(/ (atan (* (* (* (/ y-scale x-scale) (/ 1.0 t_0)) 2.0) -0.5)) (PI)))
(if (<= x-scale 4.6e+52)
(*
180.0
(/
(atan
(*
(*
(*
(/ y-scale x-scale)
(/
(fma (* -1.54320987654321e-5 (* angle angle)) (* (PI) (PI)) 1.0)
t_0))
2.0)
-0.5))
(PI)))
(/
(*
(atan
(/
(- y-scale)
(* x-scale (sin (* 0.005555555555555556 (* angle (PI)))))))
180.0)
(PI))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathbf{if}\;x-scale \leq -3.3 \cdot 10^{-38}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{1}{t\_0}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;x-scale \leq 4.6 \cdot 10^{+52}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{\mathsf{fma}\left(-1.54320987654321 \cdot 10^{-5} \cdot \left(angle \cdot angle\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)}{t\_0}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-y-scale}{x-scale \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if x-scale < -3.3000000000000002e-38Initial program 11.4%
Taylor expanded in x-scale around 0
Applied rewrites31.8%
Taylor expanded in a around 0
Applied rewrites56.5%
Taylor expanded in angle around 0
Applied rewrites55.4%
if -3.3000000000000002e-38 < x-scale < 4.6e52Initial program 20.4%
Taylor expanded in x-scale around 0
Applied rewrites31.3%
Taylor expanded in a around 0
Applied rewrites45.6%
Taylor expanded in angle around 0
Applied rewrites49.6%
if 4.6e52 < x-scale Initial program 5.0%
Taylor expanded in x-scale around 0
Applied rewrites21.6%
Applied rewrites33.4%
Taylor expanded in b around inf
Applied rewrites40.2%
Taylor expanded in angle around 0
Applied rewrites46.7%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* x-scale (sin (* 0.005555555555555556 (* angle (PI)))))))
(if (<= x-scale -1.15e-80)
(*
180.0
(/
(atan
(*
(*
(*
(/ y-scale x-scale)
(/ 1.0 (sin (* (* (PI) angle) 0.005555555555555556))))
2.0)
-0.5))
(PI)))
(if (<= x-scale 6e+52)
(/
(*
(atan
(/
(fma
(* 1.54320987654321e-5 (* angle angle))
(* y-scale (* (PI) (PI)))
(- y-scale))
t_0))
180.0)
(PI))
(/ (* (atan (/ (- y-scale) t_0)) 180.0) (PI))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := x-scale \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\\
\mathbf{if}\;x-scale \leq -1.15 \cdot 10^{-80}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{1}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;x-scale \leq 6 \cdot 10^{+52}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{\mathsf{fma}\left(1.54320987654321 \cdot 10^{-5} \cdot \left(angle \cdot angle\right), y-scale \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), -y-scale\right)}{t\_0}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-y-scale}{t\_0}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if x-scale < -1.1499999999999999e-80Initial program 10.7%
Taylor expanded in x-scale around 0
Applied rewrites31.5%
Taylor expanded in a around 0
Applied rewrites54.8%
Taylor expanded in angle around 0
Applied rewrites53.7%
if -1.1499999999999999e-80 < x-scale < 6e52Initial program 21.0%
Taylor expanded in x-scale around 0
Applied rewrites31.5%
Applied rewrites41.9%
Taylor expanded in b around inf
Applied rewrites46.1%
Taylor expanded in angle around 0
Applied rewrites50.2%
if 6e52 < x-scale Initial program 5.0%
Taylor expanded in x-scale around 0
Applied rewrites21.6%
Applied rewrites33.4%
Taylor expanded in b around inf
Applied rewrites40.2%
Taylor expanded in angle around 0
Applied rewrites46.7%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (<= b_m 2.6e-119)
(*
180.0
(/
(atan
(*
(*
(*
(/ y-scale x-scale)
(/ 1.0 (sin (* (* (PI) angle) 0.005555555555555556))))
2.0)
-0.5))
(PI)))
(if (<= b_m 1.45e+64)
(*
180.0
(/
(atan
(*
(/
(* -2.0 (* (* b_m b_m) y-scale))
(* (* angle x-scale) (* (* (PI) (+ b_m a)) (- b_m a))))
90.0))
(PI)))
(/
(*
(atan
(/
(- y-scale)
(* x-scale (sin (* 0.005555555555555556 (* angle (PI)))))))
180.0)
(PI)))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 2.6 \cdot 10^{-119}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\left(\frac{y-scale}{x-scale} \cdot \frac{1}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}\right) \cdot 2\right) \cdot -0.5\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b\_m \leq 1.45 \cdot 10^{+64}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{-2 \cdot \left(\left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(angle \cdot x-scale\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(b\_m + a\right)\right) \cdot \left(b\_m - a\right)\right)} \cdot 90\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-y-scale}{x-scale \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 2.60000000000000012e-119Initial program 14.3%
Taylor expanded in x-scale around 0
Applied rewrites29.4%
Taylor expanded in a around 0
Applied rewrites45.4%
Taylor expanded in angle around 0
Applied rewrites41.1%
if 2.60000000000000012e-119 < b < 1.44999999999999997e64Initial program 29.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.9%
Taylor expanded in x-scale around 0
Applied rewrites51.4%
if 1.44999999999999997e64 < b Initial program 7.2%
Taylor expanded in x-scale around 0
Applied rewrites14.2%
Applied rewrites35.7%
Taylor expanded in b around inf
Applied rewrites54.0%
Taylor expanded in angle around 0
Applied rewrites54.3%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (or (<= b_m 2.6e-119) (not (<= b_m 1.45e+64)))
(/
(*
(atan
(/
(- y-scale)
(* x-scale (sin (* 0.005555555555555556 (* angle (PI)))))))
180.0)
(PI))
(*
180.0
(/
(atan
(*
(/
(* -2.0 (* (* b_m b_m) y-scale))
(* (* angle x-scale) (* (* (PI) (+ b_m a)) (- b_m a))))
90.0))
(PI)))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 2.6 \cdot 10^{-119} \lor \neg \left(b\_m \leq 1.45 \cdot 10^{+64}\right):\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-y-scale}{x-scale \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{-2 \cdot \left(\left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(angle \cdot x-scale\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(b\_m + a\right)\right) \cdot \left(b\_m - a\right)\right)} \cdot 90\right)}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if b < 2.60000000000000012e-119 or 1.44999999999999997e64 < b Initial program 12.9%
Taylor expanded in x-scale around 0
Applied rewrites26.5%
Applied rewrites35.7%
Taylor expanded in b around inf
Applied rewrites45.0%
Taylor expanded in angle around 0
Applied rewrites41.6%
if 2.60000000000000012e-119 < b < 1.44999999999999997e64Initial program 29.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.9%
Taylor expanded in x-scale around 0
Applied rewrites51.4%
Final simplification42.8%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (<= b_m 3.5e-170)
(*
180.0
(/
(atan
(*
(* (/ x-scale angle) (* (/ y-scale (* (* x-scale x-scale) (PI))) -2.0))
90.0))
(PI)))
(if (<= b_m 4e+132)
(*
180.0
(/
(atan
(*
(/
(* -2.0 (* (* b_m b_m) y-scale))
(* (* angle x-scale) (* (* (PI) (+ b_m a)) (- b_m a))))
90.0))
(PI)))
(*
180.0
(/ (atan (* -180.0 (/ y-scale (* angle (* x-scale (PI)))))) (PI))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 3.5 \cdot 10^{-170}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\frac{x-scale}{angle} \cdot \left(\frac{y-scale}{\left(x-scale \cdot x-scale\right) \cdot \mathsf{PI}\left(\right)} \cdot -2\right)\right) \cdot 90\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b\_m \leq 4 \cdot 10^{+132}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{-2 \cdot \left(\left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(angle \cdot x-scale\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(b\_m + a\right)\right) \cdot \left(b\_m - a\right)\right)} \cdot 90\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;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}
\end{array}
if b < 3.49999999999999985e-170Initial program 15.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites13.8%
Taylor expanded in a around 0
Applied rewrites30.2%
if 3.49999999999999985e-170 < b < 3.99999999999999996e132Initial program 20.1%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites21.9%
Taylor expanded in x-scale around 0
Applied rewrites38.4%
if 3.99999999999999996e132 < b Initial program 3.2%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites3.3%
Taylor expanded in a around inf
Applied rewrites31.6%
Taylor expanded in a around 0
Applied rewrites59.6%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (<= b_m 3.5e-170)
(*
180.0
(/
(atan
(*
(* (/ x-scale angle) (* (/ y-scale (* (* x-scale x-scale) (PI))) -2.0))
90.0))
(PI)))
(if (<= b_m 4e+132)
(/
(*
(atan
(/
(* -180.0 (* (* b_m b_m) y-scale))
(* (* angle x-scale) (* (* (PI) (+ b_m a)) (- b_m a)))))
180.0)
(PI))
(*
180.0
(/ (atan (* -180.0 (/ y-scale (* angle (* x-scale (PI)))))) (PI))))))\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 3.5 \cdot 10^{-170}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\left(\frac{x-scale}{angle} \cdot \left(\frac{y-scale}{\left(x-scale \cdot x-scale\right) \cdot \mathsf{PI}\left(\right)} \cdot -2\right)\right) \cdot 90\right)}{\mathsf{PI}\left(\right)}\\
\mathbf{elif}\;b\_m \leq 4 \cdot 10^{+132}:\\
\;\;\;\;\frac{\tan^{-1} \left(\frac{-180 \cdot \left(\left(b\_m \cdot b\_m\right) \cdot y-scale\right)}{\left(angle \cdot x-scale\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \left(b\_m + a\right)\right) \cdot \left(b\_m - a\right)\right)}\right) \cdot 180}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;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}
\end{array}
if b < 3.49999999999999985e-170Initial program 15.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites13.8%
Taylor expanded in a around 0
Applied rewrites30.2%
if 3.49999999999999985e-170 < b < 3.99999999999999996e132Initial program 20.1%
Taylor expanded in x-scale around 0
Applied rewrites43.8%
Applied rewrites50.9%
Taylor expanded in angle around 0
Applied rewrites38.4%
if 3.99999999999999996e132 < b Initial program 3.2%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites3.3%
Taylor expanded in a around inf
Applied rewrites31.6%
Taylor expanded in a around 0
Applied rewrites59.6%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (* 180.0 (/ (atan (* -180.0 (/ y-scale (* angle (* x-scale (PI)))))) (PI))))
\begin{array}{l}
b_m = \left|b\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 15.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites14.5%
Taylor expanded in a around inf
Applied rewrites15.1%
Taylor expanded in a around 0
Applied rewrites38.8%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (* 180.0 (/ (atan (* -180.0 (/ x-scale (* angle (* y-scale (PI)))))) (PI))))
\begin{array}{l}
b_m = \left|b\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 15.0%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites14.5%
Taylor expanded in a around inf
Applied rewrites15.1%
Taylor expanded in a around inf
Applied rewrites15.1%
herbie shell --seed 2024358
(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))))