Average Error: 0.5 → 0.4
Time: 3.6min
Precision: binary64
Cost: 59008
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
\[\cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{-2.6666666666666665} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{-2.6666666666666665} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)
(FPCore (a1 a2 th)
 :precision binary64
 (+
  (* (/ (cos th) (sqrt 2.0)) (* a1 a1))
  (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))
(FPCore (a1 a2 th)
 :precision binary64
 (*
  (cos th)
  (*
   (pow (cbrt (sqrt 2.0)) -2.6666666666666665)
   (/
    (sqrt (+ (* a1 a1) (* a2 a2)))
    (/ (cbrt (cbrt (sqrt 2.0))) (sqrt (+ (* a1 a1) (* a2 a2))))))))
double code(double a1, double a2, double th) {
	return ((cos(th) / sqrt(2.0)) * (a1 * a1)) + ((cos(th) / sqrt(2.0)) * (a2 * a2));
}
double code(double a1, double a2, double th) {
	return cos(th) * (pow(cbrt(sqrt(2.0)), -2.6666666666666665) * (sqrt((a1 * a1) + (a2 * a2)) / (cbrt(cbrt(sqrt(2.0))) / sqrt((a1 * a1) + (a2 * a2)))));
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.4
Cost45696
\[\cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{-2.6666666666666665} \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)\]
Alternative 2
Error0.4
Cost32960
\[\cos th \cdot \frac{\left(a1 \cdot a1 + a2 \cdot a2\right) \cdot \sqrt{\frac{1}{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\]
Alternative 3
Error0.5
Cost13504
\[\frac{\cos th \cdot \left(a1 \cdot a1 + a2 \cdot a2\right)}{\sqrt{2}}\]
Alternative 4
Error0.5
Cost13504
\[\cos th \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\]
Alternative 5
Error14.8
Cost15816
\[\begin{array}{l} \mathbf{if}\;th \leq -1.396748572538971 \cdot 10^{+196}:\\ \;\;\;\;\left(a2 \cdot a2\right) \cdot \frac{\cos th}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -2.097684956701027 \cdot 10^{+157}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.3375262572834487 \cdot 10^{+127}:\\ \;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -0.00039981306424906863:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1519180.782663387:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 7.318441367217523 \cdot 10^{+118}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1.6840039292590713 \cdot 10^{+242}:\\ \;\;\;\;\left(a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1.7458776498391287 \cdot 10^{+277}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos th \cdot \left(a1 \cdot a1\right)}{\sqrt{2}}\\ \end{array}\]
Alternative 6
Error14.8
Cost15816
\[\begin{array}{l} \mathbf{if}\;th \leq -4.250718062989372 \cdot 10^{+196}:\\ \;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -8.902223559338374 \cdot 10^{+156}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.0803526696915391 \cdot 10^{+127}:\\ \;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -0.00029275651192601257:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1519180.782663387:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 2.7965817193996825 \cdot 10^{+119}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 4.172189751567742 \cdot 10^{+241}:\\ \;\;\;\;\left(a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 5.3321329053114234 \cdot 10^{+275}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos th \cdot \left(a1 \cdot a1\right)}{\sqrt{2}}\\ \end{array}\]
Alternative 7
Error14.8
Cost15313
\[\begin{array}{l} \mathbf{if}\;th \leq -3.6287283703331125 \cdot 10^{+196}:\\ \;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.7085491702412823 \cdot 10^{+155}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.1815892469836605 \cdot 10^{+127}:\\ \;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.2502234148944674 \cdot 10^{-05}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1519180.782663387:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 3.43126569877621 \cdot 10^{+118} \lor \neg \left(th \leq 3.457235633603687 \cdot 10^{+242}\right) \land th \leq 1.2314859590874055 \cdot 10^{+277}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos th \cdot \left(a1 \cdot a1\right)}{\sqrt{2}}\\ \end{array}\]
Alternative 8
Error14.8
Cost15313
\[\begin{array}{l} \mathbf{if}\;th \leq -2.313265553030464 \cdot 10^{+196}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -4.5031110560155425 \cdot 10^{+156}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.3895052607167113 \cdot 10^{+127}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -0.0008894502610426399:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1519180.782663387:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 7.558580221874034 \cdot 10^{+114} \lor \neg \left(th \leq 2.1286024079804908 \cdot 10^{+242}\right) \land th \leq 7.027912282012141 \cdot 10^{+276}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos th \cdot \left(a1 \cdot a1\right)}{\sqrt{2}}\\ \end{array}\]
Alternative 9
Error14.8
Cost15313
\[\begin{array}{l} \mathbf{if}\;th \leq -1.7256142768646329 \cdot 10^{+196}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -3.3339300267181208 \cdot 10^{+156}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.1296102435503977 \cdot 10^{+127}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq -1.7473884097604331 \cdot 10^{-06}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 1519180.782663387:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \mathbf{elif}\;th \leq 2.94626308986263 \cdot 10^{+116} \lor \neg \left(th \leq 1.2764553237644365 \cdot 10^{+242}\right) \land th \leq 2.505310759126052 \cdot 10^{+275}:\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}}\\ \end{array}\]
Alternative 10
Error14.7
Cost13576
\[\begin{array}{l} \mathbf{if}\;th \leq -5.437364826985349 \lor \neg \left(th \leq 1519180.782663387\right):\\ \;\;\;\;\cos th \cdot \frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\\ \end{array}\]
Alternative 11
Error26.2
Cost6976
\[\frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}\]
Alternative 12
Error33.1
Cost7753
\[\begin{array}{l} \mathbf{if}\;a2 \cdot a2 \leq 5.4300749712775135 \cdot 10^{-226}:\\ \;\;\;\;\frac{a1 \cdot a1}{\sqrt{2}}\\ \mathbf{elif}\;a2 \cdot a2 \leq 1.8986556719066702 \cdot 10^{-128} \lor \neg \left(a2 \cdot a2 \leq 5.371209810553784 \cdot 10^{-95}\right):\\ \;\;\;\;\frac{a2 \cdot a2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{a1}{\sqrt{2}}\\ \end{array}\]
Alternative 13
Error40.9
Cost6720
\[\frac{a1 \cdot a1}{\sqrt{2}}\]
Alternative 14
Error40.9
Cost6720
\[a1 \cdot \frac{a1}{\sqrt{2}}\]
Alternative 15
Error54.9
Cost64
\[0\]
Alternative 16
Error61.3
Cost64
\[1\]

Error

Time

Derivation

  1. Initial program 0.5

    \[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  2. Simplified0.5

    \[\leadsto \color{blue}{\cos th \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt{2}}}\]
  3. Using strategy rm
  4. Applied add-cube-cbrt_binary64_7950.5

    \[\leadsto \cos th \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\color{blue}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}}}\]
  5. Applied *-un-lft-identity_binary64_7600.5

    \[\leadsto \cos th \cdot \frac{\color{blue}{1 \cdot \left(a1 \cdot a1 + a2 \cdot a2\right)}}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}}\]
  6. Applied times-frac_binary64_7660.6

    \[\leadsto \cos th \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt[3]{\sqrt{2}}}\right)}\]
  7. Using strategy rm
  8. Applied add-cube-cbrt_binary64_7950.6

    \[\leadsto \cos th \cdot \left(\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\color{blue}{\left(\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}\right) \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}}}\right)\]
  9. Applied *-un-lft-identity_binary64_7600.6

    \[\leadsto \cos th \cdot \left(\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{\color{blue}{1 \cdot \left(a1 \cdot a1 + a2 \cdot a2\right)}}{\left(\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}\right) \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)\]
  10. Applied times-frac_binary64_7660.5

    \[\leadsto \cos th \cdot \left(\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}} \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)}\right)\]
  11. Applied associate-*r*_binary64_7000.4

    \[\leadsto \cos th \cdot \color{blue}{\left(\left(\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{1}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right) \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)}\]
  12. Simplified0.4

    \[\leadsto \cos th \cdot \left(\color{blue}{\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}}} \cdot \frac{a1 \cdot a1 + a2 \cdot a2}{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)\]
  13. Using strategy rm
  14. Applied add-sqr-sqrt_binary64_7820.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}} \cdot \frac{\color{blue}{\sqrt{a1 \cdot a1 + a2 \cdot a2} \cdot \sqrt{a1 \cdot a1 + a2 \cdot a2}}}{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}\right)\]
  15. Applied associate-/l*_binary64_7050.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}} \cdot \color{blue}{\frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}}\right)\]
  16. Using strategy rm
  17. Applied pow1/3_binary64_8420.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{0.3333333333333333}}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  18. Applied pow1/3_binary64_8420.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{0.3333333333333333}} \cdot {\left(\sqrt[3]{\sqrt{2}}\right)}^{0.3333333333333333}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  19. Applied pow-prod-up_binary64_8300.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{\left(0.3333333333333333 + 0.3333333333333333\right)}}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  20. Applied pow2_binary64_8410.4

    \[\leadsto \cos th \cdot \left(\frac{\frac{1}{\color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{2}}}}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{\left(0.3333333333333333 + 0.3333333333333333\right)}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  21. Applied pow-flip_binary64_8340.4

    \[\leadsto \cos th \cdot \left(\frac{\color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{\left(-2\right)}}}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{\left(0.3333333333333333 + 0.3333333333333333\right)}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  22. Applied pow-div_binary64_8350.4

    \[\leadsto \cos th \cdot \left(\color{blue}{{\left(\sqrt[3]{\sqrt{2}}\right)}^{\left(\left(-2\right) - \left(0.3333333333333333 + 0.3333333333333333\right)\right)}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  23. Simplified0.4

    \[\leadsto \cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{\color{blue}{-2.6666666666666665}} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]
  24. Simplified0.4

    \[\leadsto \color{blue}{\cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{-2.6666666666666665} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)}\]
  25. Final simplification0.4

    \[\leadsto \cos th \cdot \left({\left(\sqrt[3]{\sqrt{2}}\right)}^{-2.6666666666666665} \cdot \frac{\sqrt{a1 \cdot a1 + a2 \cdot a2}}{\frac{\sqrt[3]{\sqrt[3]{\sqrt{2}}}}{\sqrt{a1 \cdot a1 + a2 \cdot a2}}}\right)\]

Reproduce

herbie shell --seed 2021065 
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  :precision binary64
  (+ (* (/ (cos th) (sqrt 2.0)) (* a1 a1)) (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))