
(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 7 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}
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale y-scale_m)
:precision binary64
(if (<= y-scale_m 1.58e-254)
(*
(/ -4.0 x-scale)
(* (/ b y-scale_m) (* a (* b (/ (/ a x-scale) y-scale_m)))))
(*
(/ (* -4.0 (* b a)) (* y-scale_m x-scale))
(/ (* b a) (* y-scale_m x-scale)))))y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
double tmp;
if (y_45_scale_m <= 1.58e-254) {
tmp = (-4.0 / x_45_scale) * ((b / y_45_scale_m) * (a * (b * ((a / x_45_scale) / y_45_scale_m))));
} else {
tmp = ((-4.0 * (b * a)) / (y_45_scale_m * x_45_scale)) * ((b * a) / (y_45_scale_m * x_45_scale));
}
return tmp;
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
real(8) :: tmp
if (y_45scale_m <= 1.58d-254) then
tmp = ((-4.0d0) / x_45scale) * ((b / y_45scale_m) * (a * (b * ((a / x_45scale) / y_45scale_m))))
else
tmp = (((-4.0d0) * (b * a)) / (y_45scale_m * x_45scale)) * ((b * a) / (y_45scale_m * x_45scale))
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
double tmp;
if (y_45_scale_m <= 1.58e-254) {
tmp = (-4.0 / x_45_scale) * ((b / y_45_scale_m) * (a * (b * ((a / x_45_scale) / y_45_scale_m))));
} else {
tmp = ((-4.0 * (b * a)) / (y_45_scale_m * x_45_scale)) * ((b * a) / (y_45_scale_m * x_45_scale));
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): tmp = 0 if y_45_scale_m <= 1.58e-254: tmp = (-4.0 / x_45_scale) * ((b / y_45_scale_m) * (a * (b * ((a / x_45_scale) / y_45_scale_m)))) else: tmp = ((-4.0 * (b * a)) / (y_45_scale_m * x_45_scale)) * ((b * a) / (y_45_scale_m * x_45_scale)) return tmp
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) tmp = 0.0 if (y_45_scale_m <= 1.58e-254) tmp = Float64(Float64(-4.0 / x_45_scale) * Float64(Float64(b / y_45_scale_m) * Float64(a * Float64(b * Float64(Float64(a / x_45_scale) / y_45_scale_m))))); else tmp = Float64(Float64(Float64(-4.0 * Float64(b * a)) / Float64(y_45_scale_m * x_45_scale)) * Float64(Float64(b * a) / Float64(y_45_scale_m * x_45_scale))); end return tmp end
y-scale_m = abs(y_45_scale); function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = 0.0; if (y_45_scale_m <= 1.58e-254) tmp = (-4.0 / x_45_scale) * ((b / y_45_scale_m) * (a * (b * ((a / x_45_scale) / y_45_scale_m)))); else tmp = ((-4.0 * (b * a)) / (y_45_scale_m * x_45_scale)) * ((b * a) / (y_45_scale_m * x_45_scale)); end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := If[LessEqual[y$45$scale$95$m, 1.58e-254], N[(N[(-4.0 / x$45$scale), $MachinePrecision] * N[(N[(b / y$45$scale$95$m), $MachinePrecision] * N[(a * N[(b * N[(N[(a / x$45$scale), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * N[(b * a), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale$95$m * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(b * a), $MachinePrecision] / N[(y$45$scale$95$m * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
\begin{array}{l}
\mathbf{if}\;y-scale\_m \leq 1.58 \cdot 10^{-254}:\\
\;\;\;\;\frac{-4}{x-scale} \cdot \left(\frac{b}{y-scale\_m} \cdot \left(a \cdot \left(b \cdot \frac{\frac{a}{x-scale}}{y-scale\_m}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot \left(b \cdot a\right)}{y-scale\_m \cdot x-scale} \cdot \frac{b \cdot a}{y-scale\_m \cdot x-scale}\\
\end{array}
\end{array}
if y-scale < 1.58000000000000002e-254Initial program 21.4%
Simplified15.5%
Taylor expanded in angle around 0 42.9%
associate-*r/42.9%
*-commutative42.9%
*-commutative42.9%
unpow242.9%
unpow242.9%
swap-sqr53.2%
unpow253.2%
*-commutative53.2%
Simplified53.2%
div-inv53.1%
pow-prod-down74.7%
pow-flip74.8%
metadata-eval74.8%
Applied egg-rr74.8%
unpow274.8%
Applied egg-rr74.8%
*-commutative74.8%
unpow-prod-down59.0%
Applied egg-rr59.0%
pow-prod-down74.8%
*-commutative74.8%
metadata-eval74.8%
pow-flip74.7%
pow274.7%
div-inv74.8%
associate-/r*81.1%
pow281.1%
div-inv81.1%
clear-num81.1%
frac-times81.2%
metadata-eval81.2%
Applied egg-rr81.2%
associate-*l/74.8%
pow274.8%
clear-num74.8%
associate-/l/81.1%
associate-/l*81.1%
times-frac79.1%
div-inv79.1%
*-commutative79.1%
associate-/l/79.1%
associate-/l/79.1%
*-commutative79.1%
div-inv79.1%
pow279.1%
Applied egg-rr79.1%
associate-/l/74.3%
pow274.3%
associate-*l*73.5%
times-frac79.1%
Applied egg-rr79.1%
associate-/l*83.8%
associate-/l*85.4%
*-commutative85.4%
associate-/l/88.7%
Simplified88.7%
if 1.58000000000000002e-254 < y-scale Initial program 27.0%
Simplified24.4%
Taylor expanded in angle around 0 47.2%
associate-*r/47.2%
*-commutative47.2%
*-commutative47.2%
unpow247.2%
unpow247.2%
swap-sqr55.9%
unpow255.9%
*-commutative55.9%
Simplified55.9%
div-inv55.9%
pow-prod-down73.3%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
unpow273.3%
Applied egg-rr73.3%
*-commutative73.3%
unpow-prod-down59.8%
Applied egg-rr59.8%
pow-prod-down73.3%
*-commutative73.3%
metadata-eval73.3%
pow-flip73.3%
pow273.3%
div-inv73.3%
associate-/r*78.4%
pow278.4%
div-inv78.4%
clear-num78.3%
frac-times78.4%
metadata-eval78.4%
Applied egg-rr78.4%
associate-*l/73.3%
pow273.3%
clear-num73.3%
associate-*r*73.3%
times-frac94.2%
Applied egg-rr94.2%
Final simplification91.2%
y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale y-scale_m) :precision binary64 (* (pow (* b (/ (/ a y-scale_m) x-scale)) 2.0) -4.0))
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return pow((b * ((a / y_45_scale_m) / x_45_scale)), 2.0) * -4.0;
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
code = ((b * ((a / y_45scale_m) / x_45scale)) ** 2.0d0) * (-4.0d0)
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return Math.pow((b * ((a / y_45_scale_m) / x_45_scale)), 2.0) * -4.0;
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): return math.pow((b * ((a / y_45_scale_m) / x_45_scale)), 2.0) * -4.0
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) return Float64((Float64(b * Float64(Float64(a / y_45_scale_m) / x_45_scale)) ^ 2.0) * -4.0) end
y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = ((b * ((a / y_45_scale_m) / x_45_scale)) ^ 2.0) * -4.0; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := N[(N[Power[N[(b * N[(N[(a / y$45$scale$95$m), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -4.0), $MachinePrecision]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
{\left(b \cdot \frac{\frac{a}{y-scale\_m}}{x-scale}\right)}^{2} \cdot -4
\end{array}
Initial program 24.0%
Simplified19.6%
Taylor expanded in angle around 0 44.9%
associate-*r/44.9%
*-commutative44.9%
*-commutative44.9%
unpow244.9%
unpow244.9%
swap-sqr54.4%
unpow254.4%
*-commutative54.4%
Simplified54.4%
div-inv54.4%
pow-prod-down74.1%
pow-flip74.1%
metadata-eval74.1%
Applied egg-rr74.1%
unpow274.1%
Applied egg-rr74.1%
*-commutative74.1%
unpow-prod-down59.4%
Applied egg-rr59.4%
pow-prod-down74.1%
*-commutative74.1%
metadata-eval74.1%
pow-flip74.1%
pow274.1%
div-inv74.1%
associate-/r*79.9%
pow279.9%
div-inv79.8%
clear-num79.8%
frac-times79.9%
metadata-eval79.9%
Applied egg-rr79.9%
associate-*l/74.1%
pow274.1%
clear-num74.1%
associate-*r*74.1%
times-frac92.3%
Applied egg-rr92.3%
pow192.3%
Applied egg-rr0.0%
unpow10.0%
*-lft-identity0.0%
associate-*l/0.0%
unpow20.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-/l*0.0%
*-commutative0.0%
associate-/l/0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-/l*0.0%
*-commutative0.0%
associate-/l/0.0%
Simplified93.7%
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale y-scale_m)
:precision binary64
(if (<= angle 3.2e+37)
(*
(* (/ -4.0 x-scale) (* b (/ a y-scale_m)))
(/ (/ (* b a) x-scale) y-scale_m))
(*
(/ -4.0 x-scale)
(* b (* (/ a y-scale_m) (* b (/ (/ a y-scale_m) x-scale)))))))y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
double tmp;
if (angle <= 3.2e+37) {
tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m);
} else {
tmp = (-4.0 / x_45_scale) * (b * ((a / y_45_scale_m) * (b * ((a / y_45_scale_m) / x_45_scale))));
}
return tmp;
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
real(8) :: tmp
if (angle <= 3.2d+37) then
tmp = (((-4.0d0) / x_45scale) * (b * (a / y_45scale_m))) * (((b * a) / x_45scale) / y_45scale_m)
else
tmp = ((-4.0d0) / x_45scale) * (b * ((a / y_45scale_m) * (b * ((a / y_45scale_m) / x_45scale))))
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
double tmp;
if (angle <= 3.2e+37) {
tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m);
} else {
tmp = (-4.0 / x_45_scale) * (b * ((a / y_45_scale_m) * (b * ((a / y_45_scale_m) / x_45_scale))));
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): tmp = 0 if angle <= 3.2e+37: tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m) else: tmp = (-4.0 / x_45_scale) * (b * ((a / y_45_scale_m) * (b * ((a / y_45_scale_m) / x_45_scale)))) return tmp
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) tmp = 0.0 if (angle <= 3.2e+37) tmp = Float64(Float64(Float64(-4.0 / x_45_scale) * Float64(b * Float64(a / y_45_scale_m))) * Float64(Float64(Float64(b * a) / x_45_scale) / y_45_scale_m)); else tmp = Float64(Float64(-4.0 / x_45_scale) * Float64(b * Float64(Float64(a / y_45_scale_m) * Float64(b * Float64(Float64(a / y_45_scale_m) / x_45_scale))))); end return tmp end
y-scale_m = abs(y_45_scale); function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = 0.0; if (angle <= 3.2e+37) tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m); else tmp = (-4.0 / x_45_scale) * (b * ((a / y_45_scale_m) * (b * ((a / y_45_scale_m) / x_45_scale)))); end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := If[LessEqual[angle, 3.2e+37], N[(N[(N[(-4.0 / x$45$scale), $MachinePrecision] * N[(b * N[(a / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b * a), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 / x$45$scale), $MachinePrecision] * N[(b * N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b * N[(N[(a / y$45$scale$95$m), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 3.2 \cdot 10^{+37}:\\
\;\;\;\;\left(\frac{-4}{x-scale} \cdot \left(b \cdot \frac{a}{y-scale\_m}\right)\right) \cdot \frac{\frac{b \cdot a}{x-scale}}{y-scale\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{-4}{x-scale} \cdot \left(b \cdot \left(\frac{a}{y-scale\_m} \cdot \left(b \cdot \frac{\frac{a}{y-scale\_m}}{x-scale}\right)\right)\right)\\
\end{array}
\end{array}
if angle < 3.20000000000000014e37Initial program 24.3%
Simplified18.8%
Taylor expanded in angle around 0 41.9%
associate-*r/41.9%
*-commutative41.9%
*-commutative41.9%
unpow241.9%
unpow241.9%
swap-sqr50.9%
unpow250.9%
*-commutative50.9%
Simplified50.9%
div-inv50.9%
pow-prod-down72.4%
pow-flip72.5%
metadata-eval72.5%
Applied egg-rr72.5%
unpow272.5%
Applied egg-rr72.5%
*-commutative72.5%
unpow-prod-down58.7%
Applied egg-rr58.7%
pow-prod-down72.5%
*-commutative72.5%
metadata-eval72.5%
pow-flip72.4%
pow272.4%
div-inv72.4%
associate-/r*78.7%
pow278.7%
div-inv78.7%
clear-num78.7%
frac-times78.8%
metadata-eval78.8%
Applied egg-rr78.8%
associate-*l/72.5%
pow272.5%
clear-num72.4%
associate-*r*72.4%
times-frac91.3%
Applied egg-rr91.3%
times-frac88.8%
associate-/l*86.9%
associate-/l*88.1%
Simplified88.1%
associate-*r/86.9%
associate-/r*90.0%
Applied egg-rr90.0%
if 3.20000000000000014e37 < angle Initial program 22.7%
Simplified22.6%
Taylor expanded in angle around 0 56.3%
associate-*r/56.3%
*-commutative56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr67.6%
unpow267.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-prod-down80.3%
pow-flip80.3%
metadata-eval80.3%
Applied egg-rr80.3%
unpow280.3%
Applied egg-rr80.3%
*-commutative80.3%
unpow-prod-down62.0%
Applied egg-rr62.0%
pow-prod-down80.3%
*-commutative80.3%
metadata-eval80.3%
pow-flip80.3%
pow280.3%
div-inv80.3%
associate-/r*84.0%
pow284.0%
div-inv84.1%
clear-num84.1%
frac-times84.1%
metadata-eval84.1%
Applied egg-rr84.1%
associate-*l/80.3%
pow280.3%
clear-num80.3%
associate-/l/84.0%
associate-/l*84.0%
times-frac82.4%
div-inv82.4%
*-commutative82.4%
associate-/l/82.4%
associate-/l/82.4%
*-commutative82.4%
div-inv82.4%
pow282.4%
Applied egg-rr82.4%
associate-/l/80.4%
pow280.4%
times-frac91.8%
associate-*r/88.3%
associate-*r/88.4%
associate-/r*85.0%
Applied egg-rr85.0%
associate-*l*85.0%
associate-/l/88.5%
*-commutative88.5%
associate-/l/90.3%
Simplified90.3%
y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale y-scale_m) :precision binary64 (* (* (/ -4.0 x-scale) (* b (/ a y-scale_m))) (/ (/ (* b a) x-scale) y-scale_m)))
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m);
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
code = (((-4.0d0) / x_45scale) * (b * (a / y_45scale_m))) * (((b * a) / x_45scale) / y_45scale_m)
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m);
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m)
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) return Float64(Float64(Float64(-4.0 / x_45_scale) * Float64(b * Float64(a / y_45_scale_m))) * Float64(Float64(Float64(b * a) / x_45_scale) / y_45_scale_m)) end
y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (((b * a) / x_45_scale) / y_45_scale_m); end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := N[(N[(N[(-4.0 / x$45$scale), $MachinePrecision] * N[(b * N[(a / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b * a), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
\left(\frac{-4}{x-scale} \cdot \left(b \cdot \frac{a}{y-scale\_m}\right)\right) \cdot \frac{\frac{b \cdot a}{x-scale}}{y-scale\_m}
\end{array}
Initial program 24.0%
Simplified19.6%
Taylor expanded in angle around 0 44.9%
associate-*r/44.9%
*-commutative44.9%
*-commutative44.9%
unpow244.9%
unpow244.9%
swap-sqr54.4%
unpow254.4%
*-commutative54.4%
Simplified54.4%
div-inv54.4%
pow-prod-down74.1%
pow-flip74.1%
metadata-eval74.1%
Applied egg-rr74.1%
unpow274.1%
Applied egg-rr74.1%
*-commutative74.1%
unpow-prod-down59.4%
Applied egg-rr59.4%
pow-prod-down74.1%
*-commutative74.1%
metadata-eval74.1%
pow-flip74.1%
pow274.1%
div-inv74.1%
associate-/r*79.9%
pow279.9%
div-inv79.8%
clear-num79.8%
frac-times79.9%
metadata-eval79.9%
Applied egg-rr79.9%
associate-*l/74.1%
pow274.1%
clear-num74.1%
associate-*r*74.1%
times-frac92.3%
Applied egg-rr92.3%
times-frac90.0%
associate-/l*87.8%
associate-/l*88.7%
Simplified88.7%
associate-*r/87.8%
associate-/r*89.4%
Applied egg-rr89.4%
y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale y-scale_m) :precision binary64 (* (* (/ -4.0 x-scale) (* b (/ a y-scale_m))) (* b (/ a (* y-scale_m x-scale)))))
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (b * (a / (y_45_scale_m * x_45_scale)));
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
code = (((-4.0d0) / x_45scale) * (b * (a / y_45scale_m))) * (b * (a / (y_45scale_m * x_45scale)))
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (b * (a / (y_45_scale_m * x_45_scale)));
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): return ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (b * (a / (y_45_scale_m * x_45_scale)))
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) return Float64(Float64(Float64(-4.0 / x_45_scale) * Float64(b * Float64(a / y_45_scale_m))) * Float64(b * Float64(a / Float64(y_45_scale_m * x_45_scale)))) end
y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = ((-4.0 / x_45_scale) * (b * (a / y_45_scale_m))) * (b * (a / (y_45_scale_m * x_45_scale))); end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := N[(N[(N[(-4.0 / x$45$scale), $MachinePrecision] * N[(b * N[(a / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * N[(a / N[(y$45$scale$95$m * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
\left(\frac{-4}{x-scale} \cdot \left(b \cdot \frac{a}{y-scale\_m}\right)\right) \cdot \left(b \cdot \frac{a}{y-scale\_m \cdot x-scale}\right)
\end{array}
Initial program 24.0%
Simplified19.6%
Taylor expanded in angle around 0 44.9%
associate-*r/44.9%
*-commutative44.9%
*-commutative44.9%
unpow244.9%
unpow244.9%
swap-sqr54.4%
unpow254.4%
*-commutative54.4%
Simplified54.4%
div-inv54.4%
pow-prod-down74.1%
pow-flip74.1%
metadata-eval74.1%
Applied egg-rr74.1%
unpow274.1%
Applied egg-rr74.1%
*-commutative74.1%
unpow-prod-down59.4%
Applied egg-rr59.4%
pow-prod-down74.1%
*-commutative74.1%
metadata-eval74.1%
pow-flip74.1%
pow274.1%
div-inv74.1%
associate-/r*79.9%
pow279.9%
div-inv79.8%
clear-num79.8%
frac-times79.9%
metadata-eval79.9%
Applied egg-rr79.9%
associate-*l/74.1%
pow274.1%
clear-num74.1%
associate-*r*74.1%
times-frac92.3%
Applied egg-rr92.3%
times-frac90.0%
associate-/l*87.8%
associate-/l*88.7%
Simplified88.7%
Final simplification88.7%
y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale y-scale_m) :precision binary64 (* (/ (* b a) (* y-scale_m x-scale)) (* (/ a y-scale_m) (* b (/ -4.0 x-scale)))))
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((b * a) / (y_45_scale_m * x_45_scale)) * ((a / y_45_scale_m) * (b * (-4.0 / x_45_scale)));
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
code = ((b * a) / (y_45scale_m * x_45scale)) * ((a / y_45scale_m) * (b * ((-4.0d0) / x_45scale)))
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return ((b * a) / (y_45_scale_m * x_45_scale)) * ((a / y_45_scale_m) * (b * (-4.0 / x_45_scale)));
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): return ((b * a) / (y_45_scale_m * x_45_scale)) * ((a / y_45_scale_m) * (b * (-4.0 / x_45_scale)))
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) return Float64(Float64(Float64(b * a) / Float64(y_45_scale_m * x_45_scale)) * Float64(Float64(a / y_45_scale_m) * Float64(b * Float64(-4.0 / x_45_scale)))) end
y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = ((b * a) / (y_45_scale_m * x_45_scale)) * ((a / y_45_scale_m) * (b * (-4.0 / x_45_scale))); end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := N[(N[(N[(b * a), $MachinePrecision] / N[(y$45$scale$95$m * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b * N[(-4.0 / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
\frac{b \cdot a}{y-scale\_m \cdot x-scale} \cdot \left(\frac{a}{y-scale\_m} \cdot \left(b \cdot \frac{-4}{x-scale}\right)\right)
\end{array}
Initial program 24.0%
Simplified19.6%
Taylor expanded in angle around 0 44.9%
associate-*r/44.9%
*-commutative44.9%
*-commutative44.9%
unpow244.9%
unpow244.9%
swap-sqr54.4%
unpow254.4%
*-commutative54.4%
Simplified54.4%
div-inv54.4%
pow-prod-down74.1%
pow-flip74.1%
metadata-eval74.1%
Applied egg-rr74.1%
unpow274.1%
Applied egg-rr74.1%
*-commutative74.1%
unpow-prod-down59.4%
Applied egg-rr59.4%
pow-prod-down74.1%
*-commutative74.1%
metadata-eval74.1%
pow-flip74.1%
pow274.1%
div-inv74.1%
associate-/r*79.9%
pow279.9%
div-inv79.8%
clear-num79.8%
frac-times79.9%
metadata-eval79.9%
Applied egg-rr79.9%
associate-*l/74.1%
pow274.1%
clear-num74.1%
associate-*r*74.1%
times-frac92.3%
Applied egg-rr92.3%
times-frac90.0%
associate-*r/87.8%
associate-*r*86.5%
Applied egg-rr86.5%
Final simplification86.5%
y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale y-scale_m) :precision binary64 0.0)
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return 0.0;
}
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale, y_45scale_m)
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_m
code = 0.0d0
end function
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale_m) {
return 0.0;
}
y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale, y_45_scale_m): return 0.0
y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale, y_45_scale_m) return 0.0 end
y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale, y_45_scale_m) tmp = 0.0; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale_, y$45$scale$95$m_] := 0.0
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
0
\end{array}
Initial program 24.0%
Simplified21.3%
Taylor expanded in b around 0 22.4%
distribute-rgt-out22.4%
metadata-eval22.4%
mul0-rgt34.7%
Simplified34.7%
herbie shell --seed 2024107
(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))))