Average Error: 40.0 → 5.3
Time: 1.2min
Precision: binary64
Cost: 13888
\[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale}\]
\[\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot \left(\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot -4\right)\]
\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale}
\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot \left(\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot -4\right)
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (-
  (*
   (/
    (/
     (*
      (* (* 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 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI)))
      (cos (* (/ angle 180.0) PI)))
     x-scale)
    y-scale))
  (*
   (*
    4.0
    (/
     (/
      (+
       (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))))
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (*
  (/ (* b a) (fabs (* x-scale y-scale)))
  (* (/ (* b a) (fabs (* x-scale y-scale))) -4.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return ((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((angle / 180.0) * ((double) M_PI))) * cos((angle / 180.0) * ((double) M_PI))) / x_45_scale) / y_45_scale) * (((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((angle / 180.0) * ((double) M_PI))) * cos((angle / 180.0) * ((double) M_PI))) / x_45_scale) / y_45_scale)) - ((4.0 * (((pow((a * sin((angle / 180.0) * ((double) M_PI))), 2.0) + pow((b * cos((angle / 180.0) * ((double) M_PI))), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * cos((angle / 180.0) * ((double) M_PI))), 2.0) + pow((b * sin((angle / 180.0) * ((double) M_PI))), 2.0)) / y_45_scale) / y_45_scale));
}
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return ((b * a) / fabs(x_45_scale * y_45_scale)) * (((b * a) / fabs(x_45_scale * y_45_scale)) * -4.0);
}

Error

Bits error versus a

Bits error versus b

Bits error versus angle

Bits error versus x-scale

Bits error versus y-scale

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error5.3
Cost1088
\[-4 \cdot \left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \frac{b \cdot a}{x-scale \cdot y-scale}\right)\]
Alternative 2
Error25.6
Cost2372
\[\begin{array}{l} \mathbf{if}\;b \leq -8.795436665510346 \cdot 10^{+118}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \mathbf{elif}\;b \leq -1.5607656595589156 \cdot 10^{-111}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\ \mathbf{elif}\;b \leq 2.702226870724568 \cdot 10^{-56}:\\ \;\;\;\;0\\ \mathbf{elif}\;b \leq 3.664237655447155 \cdot 10^{+152}:\\ \;\;\;\;-4 \cdot \frac{b \cdot b}{\frac{x-scale}{\frac{a \cdot a}{x-scale \cdot \left(y-scale \cdot y-scale\right)}}}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \end{array}\]
Alternative 3
Error23.6
Cost1416
\[\begin{array}{l} \mathbf{if}\;y-scale \leq -2.523845739005577 \cdot 10^{-145} \lor \neg \left(y-scale \leq 1.0134203741714062 \cdot 10^{-159}\right):\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\ \end{array}\]
Alternative 4
Error25.2
Cost2693
\[\begin{array}{l} \mathbf{if}\;a \leq -1.5253527079230074 \cdot 10^{+97}:\\ \;\;\;\;-4 \cdot \frac{a \cdot \left(b \cdot \left(b \cdot a\right)\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \mathbf{elif}\;a \leq -4.2079691751097936 \cdot 10^{-95}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\ \mathbf{elif}\;a \leq -1.6278111005178637 \cdot 10^{-191}:\\ \;\;\;\;-4 \cdot \frac{a \cdot \left(b \cdot \left(b \cdot a\right)\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \mathbf{elif}\;a \leq 1.198326162177305 \cdot 10^{-112}:\\ \;\;\;\;0\\ \mathbf{elif}\;a \leq 3.2653016509327842 \cdot 10^{+47}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \frac{a \cdot \left(b \cdot \left(b \cdot a\right)\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\\ \end{array}\]
Alternative 5
Error26.1
Cost1869
\[\begin{array}{l} \mathbf{if}\;b \leq -1.3414375482721307 \cdot 10^{+154}:\\ \;\;\;\;0\\ \mathbf{elif}\;b \leq -1.0209170351716767 \cdot 10^{-110} \lor \neg \left(b \leq 2.4893738136111806 \cdot 10^{-56}\right) \land b \leq 1.1818143761204457 \cdot 10^{+147}:\\ \;\;\;\;-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 6
Error30.1
Cost64
\[0\]
Alternative 7
Error62.5
Cost64
\[1\]

Error

Derivation

  1. Initial program 40.0

    \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale}\]
  2. Taylor expanded around 0 38.5

    \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}}\]
  3. Simplified35.9

    \[\leadsto \color{blue}{-4 \cdot \frac{\left(b \cdot b\right) \cdot \left(a \cdot a\right)}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}}\]
  4. Using strategy rm
  5. Applied unswap-sqr_binary64_141027.0

    \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt_binary64_146427.0

    \[\leadsto -4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{\color{blue}{\sqrt{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)} \cdot \sqrt{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}}}\]
  8. Simplified27.0

    \[\leadsto -4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{\color{blue}{\left|x-scale \cdot y-scale\right|} \cdot \sqrt{x-scale \cdot \left(x-scale \cdot \left(y-scale \cdot y-scale\right)\right)}}\]
  9. Simplified18.8

    \[\leadsto -4 \cdot \frac{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}{\left|x-scale \cdot y-scale\right| \cdot \color{blue}{\left|x-scale \cdot y-scale\right|}}\]
  10. Using strategy rm
  11. Applied times-frac_binary64_14485.3

    \[\leadsto -4 \cdot \color{blue}{\left(\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|}\right)}\]
  12. Applied associate-*r*_binary64_13825.3

    \[\leadsto \color{blue}{\left(-4 \cdot \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|}\right) \cdot \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|}}\]
  13. Simplified5.3

    \[\leadsto \color{blue}{\left(\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot -4\right)} \cdot \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|}\]
  14. Simplified5.3

    \[\leadsto \color{blue}{\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot \left(-4 \cdot \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|}\right)}\]
  15. Final simplification5.3

    \[\leadsto \frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot \left(\frac{b \cdot a}{\left|x-scale \cdot y-scale\right|} \cdot -4\right)\]

Reproduce

herbie shell --seed 2021044 
(FPCore (a b angle x-scale y-scale)
  :name "Simplification of discriminant from scale-rotated-ellipse"
  :precision binary64
  (- (* (/ (/ (* (* (* 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 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI))) (cos (* (/ angle 180.0) PI))) x-scale) y-scale)) (* (* 4.0 (/ (/ (+ (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))))