Average Error: 40.6 → 30.6
Time: 54.4s
Precision: binary64
\[\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}\]
\[\begin{array}{l} \mathbf{if}\;x-scale \leq -6.014062421476606 \cdot 10^{+97}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq -2.5856443380881613 \cdot 10^{+51}:\\ \;\;\;\;\frac{\frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)}{y-scale \cdot y-scale} \cdot -8 + \left(\frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left(\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)\right) \cdot -4}{x-scale \cdot x-scale}\\ \mathbf{elif}\;x-scale \leq 3.567887701014496 \cdot 10^{-122}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq 40872864303.27646:\\ \;\;\;\;{a}^{2} \cdot \left(\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 + \left(\frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -8 + \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
\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}
\begin{array}{l}
\mathbf{if}\;x-scale \leq -6.014062421476606 \cdot 10^{+97}:\\
\;\;\;\;0\\

\mathbf{elif}\;x-scale \leq -2.5856443380881613 \cdot 10^{+51}:\\
\;\;\;\;\frac{\frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)}{y-scale \cdot y-scale} \cdot -8 + \left(\frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left(\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)\right) \cdot -4}{x-scale \cdot x-scale}\\

\mathbf{elif}\;x-scale \leq 3.567887701014496 \cdot 10^{-122}:\\
\;\;\;\;0\\

\mathbf{elif}\;x-scale \leq 40872864303.27646:\\
\;\;\;\;{a}^{2} \cdot \left(\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 + \left(\frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -8 + \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
(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
 (if (<= x-scale -6.014062421476606e+97)
   0.0
   (if (<= x-scale -2.5856443380881613e+51)
     (/
      (+
       (*
        (/
         (*
          (* a a)
          (*
           (pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
           (* (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0) (* b b))))
         (* y-scale y-scale))
        -8.0)
       (*
        (*
         (/ (* a a) (* y-scale y-scale))
         (+
          (* (* b b) (pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
          (* (* b b) (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0))))
        -4.0))
      (* x-scale x-scale))
     (if (<= x-scale 3.567887701014496e-122)
       0.0
       (if (<= x-scale 40872864303.27646)
         (*
          (pow a 2.0)
          (+
           (*
            (/
             (*
              (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)
              (pow b 2.0))
             (* (pow x-scale 2.0) (pow y-scale 2.0)))
            -4.0)
           (+
            (*
             (/
              (*
               (pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
               (*
                (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
                (pow b 2.0)))
              (* (pow x-scale 2.0) (pow y-scale 2.0)))
             -8.0)
            (*
             (/
              (*
               (pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
               (pow b 2.0))
              (* (pow x-scale 2.0) (pow y-scale 2.0)))
             -4.0))))
         0.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) {
	double tmp;
	if (x_45_scale <= -6.014062421476606e+97) {
		tmp = 0.0;
	} else if (x_45_scale <= -2.5856443380881613e+51) {
		tmp = (((((a * a) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b)))) / (y_45_scale * y_45_scale)) * -8.0) + ((((a * a) / (y_45_scale * y_45_scale)) * (((b * b) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) + ((b * b) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)))) * -4.0)) / (x_45_scale * x_45_scale);
	} else if (x_45_scale <= 3.567887701014496e-122) {
		tmp = 0.0;
	} else if (x_45_scale <= 40872864303.27646) {
		tmp = pow(a, 2.0) * ((((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(b, 2.0)) / (pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0))) * -4.0) + ((((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(b, 2.0))) / (pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0))) * -8.0) + (((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(b, 2.0)) / (pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0))) * -4.0)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}

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

Derivation

  1. Split input into 3 regimes
  2. if x-scale < -6.014062421476606e97 or -2.5856443380881613e51 < x-scale < 3.5678877010144962e-122 or 40872864303.276459 < x-scale

    1. Initial program 29.8

      \[0\]

    if -6.014062421476606e97 < x-scale < -2.5856443380881613e51

    1. Initial program 39.1

      \[\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 33.6

      \[\leadsto \color{blue}{-1 \cdot \frac{8 \cdot \frac{{a}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)\right)}{{y-scale}^{2}} + \left(4 \cdot \frac{{a}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}\right)}{{y-scale}^{2}} + 4 \cdot \frac{{a}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}\right)}{{y-scale}^{2}}\right)}{{x-scale}^{2}}}\]
    3. Simplified33.9

      \[\leadsto \color{blue}{-\frac{8 \cdot \frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)}{y-scale \cdot y-scale} + 4 \cdot \left(\frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left(b \cdot b\right) + {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left(b \cdot b\right)\right)\right)}{x-scale \cdot x-scale}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity_binary6433.9

      \[\leadsto -\frac{8 \cdot \frac{\left(a \cdot a\right) \cdot \left({\color{blue}{\left(1 \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)}{y-scale \cdot y-scale} + 4 \cdot \left(\frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left(b \cdot b\right) + {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left(b \cdot b\right)\right)\right)}{x-scale \cdot x-scale}\]

    if 3.5678877010144962e-122 < x-scale < 40872864303.276459

    1. Initial program 44.5

      \[\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 36.5

      \[\leadsto \color{blue}{-1 \cdot \left(\left(4 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \left(8 \cdot \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} + 4 \cdot \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right) \cdot {a}^{2}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification30.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x-scale \leq -6.014062421476606 \cdot 10^{+97}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq -2.5856443380881613 \cdot 10^{+51}:\\ \;\;\;\;\frac{\frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)}{y-scale \cdot y-scale} \cdot -8 + \left(\frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left(\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)\right) \cdot -4}{x-scale \cdot x-scale}\\ \mathbf{elif}\;x-scale \leq 3.567887701014496 \cdot 10^{-122}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq 40872864303.27646:\\ \;\;\;\;{a}^{2} \cdot \left(\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 + \left(\frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -8 + \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Alternatives

Reproduce

herbie shell --seed 2021113 
(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))))