Average Error: 41.3 → 30.5
Time: 1.2min
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 -8.511885462028488 \cdot 10^{+62}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq -7.684380701499926 \cdot 10^{-88}:\\ \;\;\;\;\begin{array}{l} t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\ t_1 := \cos t_0\\ t_2 := \sin t_0\\ \frac{\left(\frac{\left(a \cdot a\right) \cdot \left({t_2}^{4} \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale} + \frac{{\left(\sqrt[3]{{t_1}^{3}}\right)}^{4} \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale}\right) \cdot -4 - 8 \cdot \frac{{t_1}^{2} \cdot \left(\left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot {t_2}^{2}\right)\right)}{y-scale \cdot y-scale}}{x-scale \cdot x-scale} \end{array}\\ \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 -8.511885462028488 \cdot 10^{+62}:\\
\;\;\;\;0\\

\mathbf{elif}\;x-scale \leq -7.684380701499926 \cdot 10^{-88}:\\
\;\;\;\;\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_1 := \cos t_0\\
t_2 := \sin t_0\\
\frac{\left(\frac{\left(a \cdot a\right) \cdot \left({t_2}^{4} \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale} + \frac{{\left(\sqrt[3]{{t_1}^{3}}\right)}^{4} \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale}\right) \cdot -4 - 8 \cdot \frac{{t_1}^{2} \cdot \left(\left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot {t_2}^{2}\right)\right)}{y-scale \cdot y-scale}}{x-scale \cdot x-scale}
\end{array}\\

\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 -8.511885462028488e+62)
   0.0
   (if (<= x-scale -7.684380701499926e-88)
     (let* ((t_0 (* 0.005555555555555556 (* angle PI)))
            (t_1 (cos t_0))
            (t_2 (sin t_0)))
       (/
        (-
         (*
          (+
           (/ (* (* a a) (* (pow t_2 4.0) (* b b))) (* y-scale y-scale))
           (/
            (* (pow (cbrt (pow t_1 3.0)) 4.0) (* (* a a) (* b b)))
            (* y-scale y-scale)))
          -4.0)
         (*
          8.0
          (/
           (* (pow t_1 2.0) (* (* a a) (* (* b b) (pow t_2 2.0))))
           (* y-scale y-scale))))
        (* x-scale x-scale)))
     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 <= -8.511885462028488e+62) {
		tmp = 0.0;
	} else if (x_45_scale <= -7.684380701499926e-88) {
		double t_0 = 0.005555555555555556 * (angle * ((double) M_PI));
		double t_1 = cos(t_0);
		double t_2 = sin(t_0);
		tmp = ((((((a * a) * (pow(t_2, 4.0) * (b * b))) / (y_45_scale * y_45_scale)) + ((pow(cbrt(pow(t_1, 3.0)), 4.0) * ((a * a) * (b * b))) / (y_45_scale * y_45_scale))) * -4.0) - (8.0 * ((pow(t_1, 2.0) * ((a * a) * ((b * b) * pow(t_2, 2.0)))) / (y_45_scale * y_45_scale)))) / (x_45_scale * x_45_scale);
	} 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 2 regimes
  2. if x-scale < -8.5118854620284885e62 or -7.6843807014999255e-88 < x-scale

    1. Initial program 41.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 41.7

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

      \[\leadsto \color{blue}{0} \]

    if -8.5118854620284885e62 < x-scale < -7.6843807014999255e-88

    1. Initial program 40.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 37.0

      \[\leadsto \color{blue}{\frac{4 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({b}^{4} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{y-scale}^{2}} - \left(4 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{4}\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}} + \left(8 \cdot \frac{{a}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)\right)}{{y-scale}^{2}} + 4 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left({a}^{2} \cdot {b}^{2}\right)}{{y-scale}^{2}}\right)\right)\right)}{{x-scale}^{2}}} \]
    3. Simplified33.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x-scale \leq -8.511885462028488 \cdot 10^{+62}:\\ \;\;\;\;0\\ \mathbf{elif}\;x-scale \leq -7.684380701499926 \cdot 10^{-88}:\\ \;\;\;\;\frac{\left(\frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale} + \frac{{\left(\sqrt[3]{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{3}}\right)}^{4} \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right)}{y-scale \cdot y-scale}\right) \cdot -4 - 8 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(\left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)\right)}{y-scale \cdot y-scale}}{x-scale \cdot x-scale}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Reproduce

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