ab-angle->ABCF C

Percentage Accurate: 79.8% → 79.8%
Time: 19.4s
Alternatives: 4
Speedup: TODO×

Specification

?
\[\begin{array}{l} t_0 := \pi \cdot \frac{angle}{180}\\ {\left(a \cdot \cos t_0\right)}^{2} + {\left(b \cdot \sin t_0\right)}^{2} \end{array} \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Alternative 1?

\[{a}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
Derivation
  1. Initial program 81.4%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 81.8%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Taylor expanded in angle around inf 81.9%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \color{blue}{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} \]
  4. Final simplification81.9%

    \[\leadsto {a}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]

Alternative 2?

\[{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}^{2} \]
Derivation
  1. Initial program 81.4%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 81.8%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Taylor expanded in angle around 0 76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}}^{2} \]
  4. Step-by-step derivation
    1. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \color{blue}{\left(\pi \cdot b\right)}\right)\right)}^{2} \]
  5. Simplified76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)\right)}}^{2} \]
  6. Final simplification76.7%

    \[\leadsto {a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}^{2} \]

Alternative 3?

\[{a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2} \]
Derivation
  1. Initial program 81.4%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 81.8%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Taylor expanded in angle around 0 76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}}^{2} \]
  4. Step-by-step derivation
    1. associate-*r*76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \color{blue}{\left(\left(angle \cdot b\right) \cdot \pi\right)}\right)}^{2} \]
    2. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \color{blue}{\left(\pi \cdot \left(angle \cdot b\right)\right)}\right)}^{2} \]
  5. Simplified76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(\pi \cdot \left(angle \cdot b\right)\right)\right)}}^{2} \]
  6. Final simplification76.7%

    \[\leadsto {a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2} \]

Alternative 4?

\[{a}^{2} + {\left(angle \cdot \left(0.005555555555555556 \cdot \left(b \cdot \pi\right)\right)\right)}^{2} \]
Derivation
  1. Initial program 81.4%

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 81.8%

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Taylor expanded in angle around 0 76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}}^{2} \]
  4. Step-by-step derivation
    1. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \color{blue}{\left(\pi \cdot b\right)}\right)\right)}^{2} \]
  5. Simplified76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)\right)}}^{2} \]
  6. Taylor expanded in angle around 0 76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}}^{2} \]
  7. Step-by-step derivation
    1. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \color{blue}{\left(\pi \cdot b\right)}\right)\right)}^{2} \]
    2. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(\left(angle \cdot \left(\pi \cdot b\right)\right) \cdot 0.005555555555555556\right)}}^{2} \]
    3. associate-*r*76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(angle \cdot \left(\left(\pi \cdot b\right) \cdot 0.005555555555555556\right)\right)}}^{2} \]
    4. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \color{blue}{\left(0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)}\right)}^{2} \]
    5. associate-*r*76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \color{blue}{\left(\left(0.005555555555555556 \cdot \pi\right) \cdot b\right)}\right)}^{2} \]
    6. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \left(\color{blue}{\left(\pi \cdot 0.005555555555555556\right)} \cdot b\right)\right)}^{2} \]
    7. associate-*l*76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \color{blue}{\left(\pi \cdot \left(0.005555555555555556 \cdot b\right)\right)}\right)}^{2} \]
  8. Simplified76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(angle \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot b\right)\right)\right)}}^{2} \]
  9. Taylor expanded in b around 0 76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \color{blue}{\left(0.005555555555555556 \cdot \left(b \cdot \pi\right)\right)}\right)}^{2} \]
  10. Step-by-step derivation
    1. *-commutative76.7%

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \left(0.005555555555555556 \cdot \color{blue}{\left(\pi \cdot b\right)}\right)\right)}^{2} \]
  11. Simplified76.7%

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(angle \cdot \color{blue}{\left(0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)}\right)}^{2} \]
  12. Final simplification76.7%

    \[\leadsto {a}^{2} + {\left(angle \cdot \left(0.005555555555555556 \cdot \left(b \cdot \pi\right)\right)\right)}^{2} \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (a b angle)
  :name "ab-angle->ABCF C"
  :precision binary64
  (+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))