
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (pow (* (/ a y-scale) (/ b x-scale)) 2.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * pow(((a / y_45_scale) * (b / x_45_scale)), 2.0);
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = (-4.0d0) * (((a / y_45scale) * (b / x_45scale)) ** 2.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * Math.pow(((a / y_45_scale) * (b / x_45_scale)), 2.0);
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * math.pow(((a / y_45_scale) * (b / x_45_scale)), 2.0)
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * (Float64(Float64(a / y_45_scale) * Float64(b / x_45_scale)) ^ 2.0)) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * (((a / y_45_scale) * (b / x_45_scale)) ^ 2.0); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[Power[N[(N[(a / y$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot {\left(\frac{a}{y-scale} \cdot \frac{b}{x-scale}\right)}^{2}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Applied rewrites78.4%
Applied rewrites91.0%
Applied rewrites94.8%
Final simplification94.8%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ b (* y-scale x-scale)) a))
(t_1 (* (PI) (/ angle 180.0)))
(t_2 (sin t_1))
(t_3 (cos t_1))
(t_4
(/
(/ (* t_3 (* t_2 (* (- (pow b 2.0) (pow a 2.0)) 2.0))) x-scale)
y-scale)))
(if (<=
(-
(* t_4 t_4)
(*
(/ (/ (+ (pow (* t_2 b) 2.0) (pow (* t_3 a) 2.0)) y-scale) y-scale)
(*
(/ (/ (+ (pow (* t_3 b) 2.0) (pow (* t_2 a) 2.0)) x-scale) x-scale)
4.0)))
5e+291)
(* (* t_0 -4.0) t_0)
(* (pow (/ (* a b) (* y-scale x-scale)) 2.0) -4.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale} \cdot a\\
t_1 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_2 := \sin t\_1\\
t_3 := \cos t\_1\\
t_4 := \frac{\frac{t\_3 \cdot \left(t\_2 \cdot \left(\left({b}^{2} - {a}^{2}\right) \cdot 2\right)\right)}{x-scale}}{y-scale}\\
\mathbf{if}\;t\_4 \cdot t\_4 - \frac{\frac{{\left(t\_2 \cdot b\right)}^{2} + {\left(t\_3 \cdot a\right)}^{2}}{y-scale}}{y-scale} \cdot \left(\frac{\frac{{\left(t\_3 \cdot b\right)}^{2} + {\left(t\_2 \cdot a\right)}^{2}}{x-scale}}{x-scale} \cdot 4\right) \leq 5 \cdot 10^{+291}:\\
\;\;\;\;\left(t\_0 \cdot -4\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{a \cdot b}{y-scale \cdot x-scale}\right)}^{2} \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) < 5.0000000000000001e291Initial program 66.3%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6465.5
Applied rewrites65.5%
Applied rewrites87.5%
Applied rewrites94.0%
Applied rewrites94.0%
if 5.0000000000000001e291 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) Initial program 0.0%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.0
Applied rewrites57.0%
Applied rewrites73.3%
Applied rewrites89.3%
Applied rewrites92.4%
Final simplification93.0%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (/ b (* y-scale x-scale))) (t_1 (* (* t_0 t_0) (* (* a a) -4.0))))
(if (<= b 7.2e-165)
t_1
(if (<= b 2.6e+149)
(*
(* b b)
(* (/ a (* y-scale x-scale)) (/ (* -4.0 a) (* y-scale x-scale))))
t_1))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale);
double t_1 = (t_0 * t_0) * ((a * a) * -4.0);
double tmp;
if (b <= 7.2e-165) {
tmp = t_1;
} else if (b <= 2.6e+149) {
tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = b / (y_45scale * x_45scale)
t_1 = (t_0 * t_0) * ((a * a) * (-4.0d0))
if (b <= 7.2d-165) then
tmp = t_1
else if (b <= 2.6d+149) then
tmp = (b * b) * ((a / (y_45scale * x_45scale)) * (((-4.0d0) * a) / (y_45scale * x_45scale)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale);
double t_1 = (t_0 * t_0) * ((a * a) * -4.0);
double tmp;
if (b <= 7.2e-165) {
tmp = t_1;
} else if (b <= 2.6e+149) {
tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale)));
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = b / (y_45_scale * x_45_scale) t_1 = (t_0 * t_0) * ((a * a) * -4.0) tmp = 0 if b <= 7.2e-165: tmp = t_1 elif b <= 2.6e+149: tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale))) else: tmp = t_1 return tmp
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * x_45_scale)) t_1 = Float64(Float64(t_0 * t_0) * Float64(Float64(a * a) * -4.0)) tmp = 0.0 if (b <= 7.2e-165) tmp = t_1; elseif (b <= 2.6e+149) tmp = Float64(Float64(b * b) * Float64(Float64(a / Float64(y_45_scale * x_45_scale)) * Float64(Float64(-4.0 * a) / Float64(y_45_scale * x_45_scale)))); else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = b / (y_45_scale * x_45_scale); t_1 = (t_0 * t_0) * ((a * a) * -4.0); tmp = 0.0; if (b <= 7.2e-165) tmp = t_1; elseif (b <= 2.6e+149) tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale))); else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 7.2e-165], t$95$1, If[LessEqual[b, 2.6e+149], N[(N[(b * b), $MachinePrecision] * N[(N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(-4.0 * a), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot \left(\left(a \cdot a\right) \cdot -4\right)\\
\mathbf{if}\;b \leq 7.2 \cdot 10^{-165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{+149}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\frac{a}{y-scale \cdot x-scale} \cdot \frac{-4 \cdot a}{y-scale \cdot x-scale}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < 7.19999999999999969e-165 or 2.59999999999999979e149 < b Initial program 20.7%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
Applied rewrites78.9%
if 7.19999999999999969e-165 < b < 2.59999999999999979e149Initial program 37.4%
Taylor expanded in b around 0
Applied rewrites59.9%
Taylor expanded in angle around 0
Applied rewrites73.3%
Applied rewrites86.6%
Final simplification80.5%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (* y-scale x-scale) y-scale)))
(if (<= x-scale 9.8e-213)
(* (/ (* (* (* b b) a) -4.0) (* t_0 x-scale)) a)
(if (<= x-scale 9.5e+157)
(*
(/ (* (* (* a b) b) -4.0) (* (* (* x-scale x-scale) y-scale) y-scale))
a)
(* (* (* (/ a x-scale) a) (/ -4.0 t_0)) (* b b))))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (y_45_scale * x_45_scale) * y_45_scale;
double tmp;
if (x_45_scale <= 9.8e-213) {
tmp = ((((b * b) * a) * -4.0) / (t_0 * x_45_scale)) * a;
} else if (x_45_scale <= 9.5e+157) {
tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a;
} else {
tmp = (((a / x_45_scale) * a) * (-4.0 / t_0)) * (b * b);
}
return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: tmp
t_0 = (y_45scale * x_45scale) * y_45scale
if (x_45scale <= 9.8d-213) then
tmp = ((((b * b) * a) * (-4.0d0)) / (t_0 * x_45scale)) * a
else if (x_45scale <= 9.5d+157) then
tmp = ((((a * b) * b) * (-4.0d0)) / (((x_45scale * x_45scale) * y_45scale) * y_45scale)) * a
else
tmp = (((a / x_45scale) * a) * ((-4.0d0) / t_0)) * (b * b)
end if
code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (y_45_scale * x_45_scale) * y_45_scale;
double tmp;
if (x_45_scale <= 9.8e-213) {
tmp = ((((b * b) * a) * -4.0) / (t_0 * x_45_scale)) * a;
} else if (x_45_scale <= 9.5e+157) {
tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a;
} else {
tmp = (((a / x_45_scale) * a) * (-4.0 / t_0)) * (b * b);
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (y_45_scale * x_45_scale) * y_45_scale tmp = 0 if x_45_scale <= 9.8e-213: tmp = ((((b * b) * a) * -4.0) / (t_0 * x_45_scale)) * a elif x_45_scale <= 9.5e+157: tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a else: tmp = (((a / x_45_scale) * a) * (-4.0 / t_0)) * (b * b) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(y_45_scale * x_45_scale) * y_45_scale) tmp = 0.0 if (x_45_scale <= 9.8e-213) tmp = Float64(Float64(Float64(Float64(Float64(b * b) * a) * -4.0) / Float64(t_0 * x_45_scale)) * a); elseif (x_45_scale <= 9.5e+157) tmp = Float64(Float64(Float64(Float64(Float64(a * b) * b) * -4.0) / Float64(Float64(Float64(x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a); else tmp = Float64(Float64(Float64(Float64(a / x_45_scale) * a) * Float64(-4.0 / t_0)) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (y_45_scale * x_45_scale) * y_45_scale; tmp = 0.0; if (x_45_scale <= 9.8e-213) tmp = ((((b * b) * a) * -4.0) / (t_0 * x_45_scale)) * a; elseif (x_45_scale <= 9.5e+157) tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a; else tmp = (((a / x_45_scale) * a) * (-4.0 / t_0)) * (b * b); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision]}, If[LessEqual[x$45$scale, 9.8e-213], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision] * -4.0), $MachinePrecision] / N[(t$95$0 * x$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[x$45$scale, 9.5e+157], N[(N[(N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(N[(x$45$scale * x$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(N[(N[(a / x$45$scale), $MachinePrecision] * a), $MachinePrecision] * N[(-4.0 / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y-scale \cdot x-scale\right) \cdot y-scale\\
\mathbf{if}\;x-scale \leq 9.8 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\left(b \cdot b\right) \cdot a\right) \cdot -4}{t\_0 \cdot x-scale} \cdot a\\
\mathbf{elif}\;x-scale \leq 9.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{\left(\left(a \cdot b\right) \cdot b\right) \cdot -4}{\left(\left(x-scale \cdot x-scale\right) \cdot y-scale\right) \cdot y-scale} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{a}{x-scale} \cdot a\right) \cdot \frac{-4}{t\_0}\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if x-scale < 9.7999999999999997e-213Initial program 22.8%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6462.3
Applied rewrites62.3%
Applied rewrites73.1%
Taylor expanded in a around 0
Applied rewrites65.7%
Applied rewrites71.7%
if 9.7999999999999997e-213 < x-scale < 9.4999999999999996e157Initial program 21.5%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.2
Applied rewrites60.2%
Applied rewrites62.4%
Taylor expanded in a around 0
Applied rewrites55.3%
Taylor expanded in a around 0
Applied rewrites66.2%
if 9.4999999999999996e157 < x-scale Initial program 43.2%
Taylor expanded in b around 0
Applied rewrites67.3%
Taylor expanded in angle around 0
Applied rewrites71.9%
Applied rewrites77.8%
Final simplification70.4%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0
(*
(/
(* (* (* b b) a) -4.0)
(* (* (* y-scale x-scale) y-scale) x-scale))
a)))
(if (<= x-scale 9.8e-213)
t_0
(if (<= x-scale 9.5e+157)
(*
(/ (* (* (* a b) b) -4.0) (* (* (* x-scale x-scale) y-scale) y-scale))
a)
t_0))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a;
double tmp;
if (x_45_scale <= 9.8e-213) {
tmp = t_0;
} else if (x_45_scale <= 9.5e+157) {
tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: tmp
t_0 = ((((b * b) * a) * (-4.0d0)) / (((y_45scale * x_45scale) * y_45scale) * x_45scale)) * a
if (x_45scale <= 9.8d-213) then
tmp = t_0
else if (x_45scale <= 9.5d+157) then
tmp = ((((a * b) * b) * (-4.0d0)) / (((x_45scale * x_45scale) * y_45scale) * y_45scale)) * a
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a;
double tmp;
if (x_45_scale <= 9.8e-213) {
tmp = t_0;
} else if (x_45_scale <= 9.5e+157) {
tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a tmp = 0 if x_45_scale <= 9.8e-213: tmp = t_0 elif x_45_scale <= 9.5e+157: tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a else: tmp = t_0 return tmp
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(Float64(Float64(Float64(b * b) * a) * -4.0) / Float64(Float64(Float64(y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a) tmp = 0.0 if (x_45_scale <= 9.8e-213) tmp = t_0; elseif (x_45_scale <= 9.5e+157) tmp = Float64(Float64(Float64(Float64(Float64(a * b) * b) * -4.0) / Float64(Float64(Float64(x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a; tmp = 0.0; if (x_45_scale <= 9.8e-213) tmp = t_0; elseif (x_45_scale <= 9.5e+157) tmp = ((((a * b) * b) * -4.0) / (((x_45_scale * x_45_scale) * y_45_scale) * y_45_scale)) * a; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(N[(N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[x$45$scale, 9.8e-213], t$95$0, If[LessEqual[x$45$scale, 9.5e+157], N[(N[(N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(N[(x$45$scale * x$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(\left(b \cdot b\right) \cdot a\right) \cdot -4}{\left(\left(y-scale \cdot x-scale\right) \cdot y-scale\right) \cdot x-scale} \cdot a\\
\mathbf{if}\;x-scale \leq 9.8 \cdot 10^{-213}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x-scale \leq 9.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{\left(\left(a \cdot b\right) \cdot b\right) \cdot -4}{\left(\left(x-scale \cdot x-scale\right) \cdot y-scale\right) \cdot y-scale} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x-scale < 9.7999999999999997e-213 or 9.4999999999999996e157 < x-scale Initial program 25.3%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Applied rewrites72.8%
Taylor expanded in a around 0
Applied rewrites65.9%
Applied rewrites71.9%
if 9.7999999999999997e-213 < x-scale < 9.4999999999999996e157Initial program 21.5%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.2
Applied rewrites60.2%
Applied rewrites62.4%
Taylor expanded in a around 0
Applied rewrites55.3%
Taylor expanded in a around 0
Applied rewrites66.2%
Final simplification70.0%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(if (<= b 7.2e-165)
(* (/ (* (* (* a b) b) -4.0) (* (* (* y-scale y-scale) x-scale) x-scale)) a)
(*
(* b b)
(* (/ a (* y-scale x-scale)) (/ (* -4.0 a) (* y-scale x-scale))))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (b <= 7.2e-165) {
tmp = ((((a * b) * b) * -4.0) / (((y_45_scale * y_45_scale) * x_45_scale) * x_45_scale)) * a;
} else {
tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale)));
}
return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: tmp
if (b <= 7.2d-165) then
tmp = ((((a * b) * b) * (-4.0d0)) / (((y_45scale * y_45scale) * x_45scale) * x_45scale)) * a
else
tmp = (b * b) * ((a / (y_45scale * x_45scale)) * (((-4.0d0) * a) / (y_45scale * x_45scale)))
end if
code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (b <= 7.2e-165) {
tmp = ((((a * b) * b) * -4.0) / (((y_45_scale * y_45_scale) * x_45_scale) * x_45_scale)) * a;
} else {
tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale)));
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): tmp = 0 if b <= 7.2e-165: tmp = ((((a * b) * b) * -4.0) / (((y_45_scale * y_45_scale) * x_45_scale) * x_45_scale)) * a else: tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale))) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0 if (b <= 7.2e-165) tmp = Float64(Float64(Float64(Float64(Float64(a * b) * b) * -4.0) / Float64(Float64(Float64(y_45_scale * y_45_scale) * x_45_scale) * x_45_scale)) * a); else tmp = Float64(Float64(b * b) * Float64(Float64(a / Float64(y_45_scale * x_45_scale)) * Float64(Float64(-4.0 * a) / Float64(y_45_scale * x_45_scale)))); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0; if (b <= 7.2e-165) tmp = ((((a * b) * b) * -4.0) / (((y_45_scale * y_45_scale) * x_45_scale) * x_45_scale)) * a; else tmp = (b * b) * ((a / (y_45_scale * x_45_scale)) * ((-4.0 * a) / (y_45_scale * x_45_scale))); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[b, 7.2e-165], N[(N[(N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(N[(y$45$scale * y$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(-4.0 * a), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{-165}:\\
\;\;\;\;\frac{\left(\left(a \cdot b\right) \cdot b\right) \cdot -4}{\left(\left(y-scale \cdot y-scale\right) \cdot x-scale\right) \cdot x-scale} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\frac{a}{y-scale \cdot x-scale} \cdot \frac{-4 \cdot a}{y-scale \cdot x-scale}\right)\\
\end{array}
\end{array}
if b < 7.19999999999999969e-165Initial program 25.4%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6459.9
Applied rewrites59.9%
Applied rewrites66.0%
Taylor expanded in a around 0
Applied rewrites61.9%
Applied rewrites69.2%
if 7.19999999999999969e-165 < b Initial program 21.6%
Taylor expanded in b around 0
Applied rewrites56.1%
Taylor expanded in angle around 0
Applied rewrites72.4%
Applied rewrites81.7%
Final simplification73.6%
(FPCore (a b angle x-scale y-scale) :precision binary64 (let* ((t_0 (* (/ b (* y-scale x-scale)) a))) (* (* t_0 -4.0) t_0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (b / (y_45_scale * x_45_scale)) * a;
return (t_0 * -4.0) * t_0;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = (b / (y_45scale * x_45scale)) * a
code = (t_0 * (-4.0d0)) * t_0
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (b / (y_45_scale * x_45_scale)) * a;
return (t_0 * -4.0) * t_0;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (b / (y_45_scale * x_45_scale)) * a return (t_0 * -4.0) * t_0
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(b / Float64(y_45_scale * x_45_scale)) * a) return Float64(Float64(t_0 * -4.0) * t_0) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (b / (y_45_scale * x_45_scale)) * a; tmp = (t_0 * -4.0) * t_0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(b / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]}, N[(N[(t$95$0 * -4.0), $MachinePrecision] * t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale} \cdot a\\
\left(t\_0 \cdot -4\right) \cdot t\_0
\end{array}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Applied rewrites78.4%
Applied rewrites91.0%
Applied rewrites91.0%
Final simplification91.0%
(FPCore (a b angle x-scale y-scale) :precision binary64 (let* ((t_0 (/ b (* y-scale x-scale)))) (* (* (* (* t_0 a) t_0) a) -4.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale);
return (((t_0 * a) * t_0) * a) * -4.0;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = b / (y_45scale * x_45scale)
code = (((t_0 * a) * t_0) * a) * (-4.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale);
return (((t_0 * a) * t_0) * a) * -4.0;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = b / (y_45_scale * x_45_scale) return (((t_0 * a) * t_0) * a) * -4.0
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * x_45_scale)) return Float64(Float64(Float64(Float64(t_0 * a) * t_0) * a) * -4.0) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = b / (y_45_scale * x_45_scale); tmp = (((t_0 * a) * t_0) * a) * -4.0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(t$95$0 * a), $MachinePrecision] * t$95$0), $MachinePrecision] * a), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale}\\
\left(\left(\left(t\_0 \cdot a\right) \cdot t\_0\right) \cdot a\right) \cdot -4
\end{array}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Applied rewrites78.4%
Applied rewrites91.0%
Applied rewrites89.3%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* (/ (* (* (* b b) a) -4.0) (* (* (* y-scale x-scale) y-scale) x-scale)) a))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = ((((b * b) * a) * (-4.0d0)) / (((y_45scale * x_45scale) * y_45scale) * x_45scale)) * a
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a;
}
def code(a, b, angle, x_45_scale, y_45_scale): return ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(Float64(Float64(b * b) * a) * -4.0) / Float64(Float64(Float64(y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = ((((b * b) * a) * -4.0) / (((y_45_scale * x_45_scale) * y_45_scale) * x_45_scale)) * a; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * y$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(b \cdot b\right) \cdot a\right) \cdot -4}{\left(\left(y-scale \cdot x-scale\right) \cdot y-scale\right) \cdot x-scale} \cdot a
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Applied rewrites69.4%
Taylor expanded in a around 0
Applied rewrites62.5%
Applied rewrites66.9%
Final simplification66.9%
herbie shell --seed 2024283
(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))))