
(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)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = cos(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * Math.PI;
double t_1 = Math.sin(t_0);
double t_2 = Math.cos(t_0);
double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (angle / 180.0) * math.pi t_1 = math.sin(t_0) t_2 = math.cos(t_0) t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(angle / 180.0) * pi) t_1 = sin(t_0) t_2 = cos(t_0) t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = cos(t_0); t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale; tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
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 5 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)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = cos(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * Math.PI;
double t_1 = Math.sin(t_0);
double t_2 = Math.cos(t_0);
double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (angle / 180.0) * math.pi t_1 = math.sin(t_0) t_2 = math.cos(t_0) t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(angle / 180.0) * pi) t_1 = sin(t_0) t_2 = cos(t_0) t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = cos(t_0); t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale; tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
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}
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0
(*
(/ (/ -4.0 y-scale) x-scale)
(/ (* b_m (* a (* b_m a))) (* y-scale x-scale)))))
(if (<= b_m 3.7e-195)
t_0
(if (<= b_m 4.8e+229)
(*
(/ (/ b_m (/ y-scale -4.0)) (/ x-scale b_m))
(/ a (/ y-scale (/ a x-scale))))
t_0))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale));
double tmp;
if (b_m <= 3.7e-195) {
tmp = t_0;
} else if (b_m <= 4.8e+229) {
tmp = ((b_m / (y_45_scale / -4.0)) / (x_45_scale / b_m)) * (a / (y_45_scale / (a / x_45_scale)));
} else {
tmp = t_0;
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
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 = (((-4.0d0) / y_45scale) / x_45scale) * ((b_m * (a * (b_m * a))) / (y_45scale * x_45scale))
if (b_m <= 3.7d-195) then
tmp = t_0
else if (b_m <= 4.8d+229) then
tmp = ((b_m / (y_45scale / (-4.0d0))) / (x_45scale / b_m)) * (a / (y_45scale / (a / x_45scale)))
else
tmp = t_0
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale));
double tmp;
if (b_m <= 3.7e-195) {
tmp = t_0;
} else if (b_m <= 4.8e+229) {
tmp = ((b_m / (y_45_scale / -4.0)) / (x_45_scale / b_m)) * (a / (y_45_scale / (a / x_45_scale)));
} else {
tmp = t_0;
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale)) tmp = 0 if b_m <= 3.7e-195: tmp = t_0 elif b_m <= 4.8e+229: tmp = ((b_m / (y_45_scale / -4.0)) / (x_45_scale / b_m)) * (a / (y_45_scale / (a / x_45_scale))) else: tmp = t_0 return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(Float64(-4.0 / y_45_scale) / x_45_scale) * Float64(Float64(b_m * Float64(a * Float64(b_m * a))) / Float64(y_45_scale * x_45_scale))) tmp = 0.0 if (b_m <= 3.7e-195) tmp = t_0; elseif (b_m <= 4.8e+229) tmp = Float64(Float64(Float64(b_m / Float64(y_45_scale / -4.0)) / Float64(x_45_scale / b_m)) * Float64(a / Float64(y_45_scale / Float64(a / x_45_scale)))); else tmp = t_0; end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale)); tmp = 0.0; if (b_m <= 3.7e-195) tmp = t_0; elseif (b_m <= 4.8e+229) tmp = ((b_m / (y_45_scale / -4.0)) / (x_45_scale / b_m)) * (a / (y_45_scale / (a / x_45_scale))); else tmp = t_0; end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(N[(-4.0 / y$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision] * N[(N[(b$95$m * N[(a * N[(b$95$m * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b$95$m, 3.7e-195], t$95$0, If[LessEqual[b$95$m, 4.8e+229], N[(N[(N[(b$95$m / N[(y$45$scale / -4.0), $MachinePrecision]), $MachinePrecision] / N[(x$45$scale / b$95$m), $MachinePrecision]), $MachinePrecision] * N[(a / N[(y$45$scale / N[(a / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \frac{\frac{-4}{y-scale}}{x-scale} \cdot \frac{b\_m \cdot \left(a \cdot \left(b\_m \cdot a\right)\right)}{y-scale \cdot x-scale}\\
\mathbf{if}\;b\_m \leq 3.7 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b\_m \leq 4.8 \cdot 10^{+229}:\\
\;\;\;\;\frac{\frac{b\_m}{\frac{y-scale}{-4}}}{\frac{x-scale}{b\_m}} \cdot \frac{a}{\frac{y-scale}{\frac{a}{x-scale}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < 3.69999999999999962e-195 or 4.8000000000000002e229 < b Initial program 24.7%
Simplified24.5%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6457.4%
Simplified57.4%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6465.7%
Applied egg-rr65.7%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f6477.1%
Applied egg-rr77.1%
associate-*r/N/A
associate-*r*N/A
associate-/l*N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
associate-/l/N/A
associate-*r/N/A
clear-numN/A
times-fracN/A
associate-*r*N/A
associate-*r*N/A
associate-/l*N/A
*-commutativeN/A
associate-*r*N/A
Applied egg-rr86.1%
if 3.69999999999999962e-195 < b < 4.8000000000000002e229Initial program 31.7%
Simplified25.9%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6461.3%
Simplified61.3%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6464.9%
Applied egg-rr64.9%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f6482.7%
Applied egg-rr82.7%
*-commutativeN/A
associate-*l/N/A
associate-*r/N/A
div-invN/A
*-lowering-*.f64N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
associate-*l/N/A
clear-numN/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6491.7%
Applied egg-rr91.7%
Final simplification88.1%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (<= b_m 1e-196)
(*
(/ (/ -4.0 y-scale) x-scale)
(/ (* b_m (* a (* b_m a))) (* y-scale x-scale)))
(*
(/ (* b_m (/ -4.0 (/ (/ y-scale (/ a x-scale)) a))) y-scale)
(/ b_m x-scale))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (b_m <= 1e-196) {
tmp = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale));
} else {
tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale);
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: tmp
if (b_m <= 1d-196) then
tmp = (((-4.0d0) / y_45scale) / x_45scale) * ((b_m * (a * (b_m * a))) / (y_45scale * x_45scale))
else
tmp = ((b_m * ((-4.0d0) / ((y_45scale / (a / x_45scale)) / a))) / y_45scale) * (b_m / x_45scale)
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (b_m <= 1e-196) {
tmp = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale));
} else {
tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): tmp = 0 if b_m <= 1e-196: tmp = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale)) else: tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale) return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) tmp = 0.0 if (b_m <= 1e-196) tmp = Float64(Float64(Float64(-4.0 / y_45_scale) / x_45_scale) * Float64(Float64(b_m * Float64(a * Float64(b_m * a))) / Float64(y_45_scale * x_45_scale))); else tmp = Float64(Float64(Float64(b_m * Float64(-4.0 / Float64(Float64(y_45_scale / Float64(a / x_45_scale)) / a))) / y_45_scale) * Float64(b_m / x_45_scale)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = 0.0; if (b_m <= 1e-196) tmp = ((-4.0 / y_45_scale) / x_45_scale) * ((b_m * (a * (b_m * a))) / (y_45_scale * x_45_scale)); else tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[b$95$m, 1e-196], N[(N[(N[(-4.0 / y$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision] * N[(N[(b$95$m * N[(a * N[(b$95$m * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b$95$m * N[(-4.0 / N[(N[(y$45$scale / N[(a / x$45$scale), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] * N[(b$95$m / x$45$scale), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 10^{-196}:\\
\;\;\;\;\frac{\frac{-4}{y-scale}}{x-scale} \cdot \frac{b\_m \cdot \left(a \cdot \left(b\_m \cdot a\right)\right)}{y-scale \cdot x-scale}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_m \cdot \frac{-4}{\frac{\frac{y-scale}{\frac{a}{x-scale}}}{a}}}{y-scale} \cdot \frac{b\_m}{x-scale}\\
\end{array}
\end{array}
if b < 1e-196Initial program 27.9%
Simplified27.7%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6457.3%
Simplified57.3%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6465.3%
Applied egg-rr65.3%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f6476.1%
Applied egg-rr76.1%
associate-*r/N/A
associate-*r*N/A
associate-/l*N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
associate-/l/N/A
associate-*r/N/A
clear-numN/A
times-fracN/A
associate-*r*N/A
associate-*r*N/A
associate-/l*N/A
*-commutativeN/A
associate-*r*N/A
Applied egg-rr85.7%
if 1e-196 < b Initial program 26.2%
Simplified21.4%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6460.7%
Simplified60.7%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6465.6%
Applied egg-rr65.6%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f6483.0%
Applied egg-rr83.0%
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/l/N/A
/-lowering-/.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6490.1%
Applied egg-rr90.1%
Final simplification87.6%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(if (<= a 8.5e-160)
(*
(/ b_m x-scale)
(* b_m (* a (* (/ -4.0 y-scale) (/ a (* y-scale x-scale))))))
(*
(/ (* b_m (/ -4.0 (/ (/ y-scale (/ a x-scale)) a))) y-scale)
(/ b_m x-scale))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (a <= 8.5e-160) {
tmp = (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale)))));
} else {
tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale);
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: tmp
if (a <= 8.5d-160) then
tmp = (b_m / x_45scale) * (b_m * (a * (((-4.0d0) / y_45scale) * (a / (y_45scale * x_45scale)))))
else
tmp = ((b_m * ((-4.0d0) / ((y_45scale / (a / x_45scale)) / a))) / y_45scale) * (b_m / x_45scale)
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (a <= 8.5e-160) {
tmp = (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale)))));
} else {
tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): tmp = 0 if a <= 8.5e-160: tmp = (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale))))) else: tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale) return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) tmp = 0.0 if (a <= 8.5e-160) tmp = Float64(Float64(b_m / x_45_scale) * Float64(b_m * Float64(a * Float64(Float64(-4.0 / y_45_scale) * Float64(a / Float64(y_45_scale * x_45_scale)))))); else tmp = Float64(Float64(Float64(b_m * Float64(-4.0 / Float64(Float64(y_45_scale / Float64(a / x_45_scale)) / a))) / y_45_scale) * Float64(b_m / x_45_scale)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = 0.0; if (a <= 8.5e-160) tmp = (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale))))); else tmp = ((b_m * (-4.0 / ((y_45_scale / (a / x_45_scale)) / a))) / y_45_scale) * (b_m / x_45_scale); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[a, 8.5e-160], N[(N[(b$95$m / x$45$scale), $MachinePrecision] * N[(b$95$m * N[(a * N[(N[(-4.0 / y$45$scale), $MachinePrecision] * N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b$95$m * N[(-4.0 / N[(N[(y$45$scale / N[(a / x$45$scale), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] * N[(b$95$m / x$45$scale), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.5 \cdot 10^{-160}:\\
\;\;\;\;\frac{b\_m}{x-scale} \cdot \left(b\_m \cdot \left(a \cdot \left(\frac{-4}{y-scale} \cdot \frac{a}{y-scale \cdot x-scale}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_m \cdot \frac{-4}{\frac{\frac{y-scale}{\frac{a}{x-scale}}}{a}}}{y-scale} \cdot \frac{b\_m}{x-scale}\\
\end{array}
\end{array}
if a < 8.49999999999999959e-160Initial program 33.4%
Simplified29.4%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6456.5%
Simplified56.5%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6461.6%
Applied egg-rr61.6%
associate-/r*N/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6473.0%
Applied egg-rr73.0%
associate-/r*N/A
associate-/l/N/A
div-invN/A
associate-*l/N/A
*-commutativeN/A
clear-numN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6484.7%
Applied egg-rr84.7%
if 8.49999999999999959e-160 < a Initial program 16.9%
Simplified17.9%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6462.5%
Simplified62.5%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6471.6%
Applied egg-rr71.6%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f6482.8%
Applied egg-rr82.8%
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-/l/N/A
/-lowering-/.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6490.9%
Applied egg-rr90.9%
Final simplification87.1%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (* (/ b_m x-scale) (* b_m (* a (* (/ -4.0 y-scale) (/ a (* y-scale x-scale)))))))
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale)))));
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = (b_m / x_45scale) * (b_m * (a * (((-4.0d0) / y_45scale) * (a / (y_45scale * x_45scale)))))
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale)))));
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): return (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale)))))
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) return Float64(Float64(b_m / x_45_scale) * Float64(b_m * Float64(a * Float64(Float64(-4.0 / y_45_scale) * Float64(a / Float64(y_45_scale * x_45_scale)))))) end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = (b_m / x_45_scale) * (b_m * (a * ((-4.0 / y_45_scale) * (a / (y_45_scale * x_45_scale))))); end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := N[(N[(b$95$m / x$45$scale), $MachinePrecision] * N[(b$95$m * N[(a * N[(N[(-4.0 / y$45$scale), $MachinePrecision] * N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
\frac{b\_m}{x-scale} \cdot \left(b\_m \cdot \left(a \cdot \left(\frac{-4}{y-scale} \cdot \frac{a}{y-scale \cdot x-scale}\right)\right)\right)
\end{array}
Initial program 27.2%
Simplified25.0%
Taylor expanded in angle around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6458.8%
Simplified58.8%
associate-*r*N/A
associate-/l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6465.4%
Applied egg-rr65.4%
associate-/r*N/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6475.2%
Applied egg-rr75.2%
associate-/r*N/A
associate-/l/N/A
div-invN/A
associate-*l/N/A
*-commutativeN/A
clear-numN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6484.7%
Applied egg-rr84.7%
Final simplification84.7%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 0.0)
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = 0.0d0
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): return 0.0
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) return 0.0 end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = 0.0; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := 0.0
\begin{array}{l}
b_m = \left|b\right|
\\
0
\end{array}
Initial program 27.2%
Simplified25.0%
Taylor expanded in b around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt35.5%
Simplified35.5%
herbie shell --seed 2024155
(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))))