
(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 6 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}
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
:precision binary64
(let* ((t_0 (/ (* a b) (* x-scale_m y-scale))))
(if (<= x-scale_m 1e+138)
(* -4.0 (pow (/ (* a (/ b y-scale)) x-scale_m) 2.0))
(* t_0 (* -4.0 t_0)))))x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = (a * b) / (x_45_scale_m * y_45_scale);
double tmp;
if (x_45_scale_m <= 1e+138) {
tmp = -4.0 * pow(((a * (b / y_45_scale)) / x_45_scale_m), 2.0);
} else {
tmp = t_0 * (-4.0 * t_0);
}
return tmp;
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: tmp
t_0 = (a * b) / (x_45scale_m * y_45scale)
if (x_45scale_m <= 1d+138) then
tmp = (-4.0d0) * (((a * (b / y_45scale)) / x_45scale_m) ** 2.0d0)
else
tmp = t_0 * ((-4.0d0) * t_0)
end if
code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = (a * b) / (x_45_scale_m * y_45_scale);
double tmp;
if (x_45_scale_m <= 1e+138) {
tmp = -4.0 * Math.pow(((a * (b / y_45_scale)) / x_45_scale_m), 2.0);
} else {
tmp = t_0 * (-4.0 * t_0);
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): t_0 = (a * b) / (x_45_scale_m * y_45_scale) tmp = 0 if x_45_scale_m <= 1e+138: tmp = -4.0 * math.pow(((a * (b / y_45_scale)) / x_45_scale_m), 2.0) else: tmp = t_0 * (-4.0 * t_0) return tmp
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = Float64(Float64(a * b) / Float64(x_45_scale_m * y_45_scale)) tmp = 0.0 if (x_45_scale_m <= 1e+138) tmp = Float64(-4.0 * (Float64(Float64(a * Float64(b / y_45_scale)) / x_45_scale_m) ^ 2.0)); else tmp = Float64(t_0 * Float64(-4.0 * t_0)); end return tmp end
x-scale_m = abs(x_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = (a * b) / (x_45_scale_m * y_45_scale); tmp = 0.0; if (x_45_scale_m <= 1e+138) tmp = -4.0 * (((a * (b / y_45_scale)) / x_45_scale_m) ^ 2.0); else tmp = t_0 * (-4.0 * t_0); end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(N[(a * b), $MachinePrecision] / N[(x$45$scale$95$m * y$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$45$scale$95$m, 1e+138], N[(-4.0 * N[Power[N[(N[(a * N[(b / y$45$scale), $MachinePrecision]), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-4.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{a \cdot b}{x-scale\_m \cdot y-scale}\\
\mathbf{if}\;x-scale\_m \leq 10^{+138}:\\
\;\;\;\;-4 \cdot {\left(\frac{a \cdot \frac{b}{y-scale}}{x-scale\_m}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-4 \cdot t\_0\right)\\
\end{array}
\end{array}
if x-scale < 1e138Initial program 25.8%
Simplified24.1%
Taylor expanded in angle around 0 57.0%
*-commutative57.0%
unpow257.0%
unpow257.0%
swap-sqr65.8%
unpow265.8%
*-commutative65.8%
unpow265.8%
unpow265.8%
swap-sqr79.4%
unpow279.4%
Simplified79.4%
associate-*r/79.4%
Applied egg-rr79.4%
Taylor expanded in a around 0 57.0%
unpow257.0%
unpow257.0%
swap-sqr65.8%
unpow265.8%
associate-*r/65.8%
unpow265.8%
unpow265.8%
swap-sqr79.4%
associate-/r*86.1%
associate-/l*86.1%
unpow286.1%
associate-*l/91.5%
associate-*r/91.5%
associate-*r/92.8%
unpow292.8%
Simplified95.8%
if 1e138 < x-scale Initial program 39.0%
Simplified36.3%
Taylor expanded in angle around 0 41.5%
*-commutative41.5%
unpow241.5%
unpow241.5%
swap-sqr46.7%
unpow246.7%
*-commutative46.7%
unpow246.7%
unpow246.7%
swap-sqr74.7%
unpow274.7%
Simplified74.7%
associate-*r/74.7%
Applied egg-rr74.7%
rem-cube-cbrt74.5%
associate-*r/74.5%
add-sqr-sqrt74.5%
associate-*r*74.5%
Applied egg-rr97.1%
Final simplification96.0%
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
:precision binary64
(let* ((t_0 (/ b (* y-scale (/ x-scale_m a))))
(t_1 (/ (* a b) (* x-scale_m y-scale))))
(if (<= a 2.1e-147) (* t_1 (* -4.0 t_1)) (* -4.0 (* t_0 t_0)))))x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * (x_45_scale_m / a));
double t_1 = (a * b) / (x_45_scale_m * y_45_scale);
double tmp;
if (a <= 2.1e-147) {
tmp = t_1 * (-4.0 * t_1);
} else {
tmp = -4.0 * (t_0 * t_0);
}
return tmp;
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = b / (y_45scale * (x_45scale_m / a))
t_1 = (a * b) / (x_45scale_m * y_45scale)
if (a <= 2.1d-147) then
tmp = t_1 * ((-4.0d0) * t_1)
else
tmp = (-4.0d0) * (t_0 * t_0)
end if
code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * (x_45_scale_m / a));
double t_1 = (a * b) / (x_45_scale_m * y_45_scale);
double tmp;
if (a <= 2.1e-147) {
tmp = t_1 * (-4.0 * t_1);
} else {
tmp = -4.0 * (t_0 * t_0);
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): t_0 = b / (y_45_scale * (x_45_scale_m / a)) t_1 = (a * b) / (x_45_scale_m * y_45_scale) tmp = 0 if a <= 2.1e-147: tmp = t_1 * (-4.0 * t_1) else: tmp = -4.0 * (t_0 * t_0) return tmp
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * Float64(x_45_scale_m / a))) t_1 = Float64(Float64(a * b) / Float64(x_45_scale_m * y_45_scale)) tmp = 0.0 if (a <= 2.1e-147) tmp = Float64(t_1 * Float64(-4.0 * t_1)); else tmp = Float64(-4.0 * Float64(t_0 * t_0)); end return tmp end
x-scale_m = abs(x_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = b / (y_45_scale * (x_45_scale_m / a)); t_1 = (a * b) / (x_45_scale_m * y_45_scale); tmp = 0.0; if (a <= 2.1e-147) tmp = t_1 * (-4.0 * t_1); else tmp = -4.0 * (t_0 * t_0); end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * N[(x$45$scale$95$m / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] / N[(x$45$scale$95$m * y$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 2.1e-147], N[(t$95$1 * N[(-4.0 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot \frac{x-scale\_m}{a}}\\
t_1 := \frac{a \cdot b}{x-scale\_m \cdot y-scale}\\
\mathbf{if}\;a \leq 2.1 \cdot 10^{-147}:\\
\;\;\;\;t\_1 \cdot \left(-4 \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if a < 2.1e-147Initial program 31.4%
Simplified27.4%
Taylor expanded in angle around 0 54.4%
*-commutative54.4%
unpow254.4%
unpow254.4%
swap-sqr61.3%
unpow261.3%
*-commutative61.3%
unpow261.3%
unpow261.3%
swap-sqr80.2%
unpow280.2%
Simplified80.2%
associate-*r/80.2%
Applied egg-rr80.2%
rem-cube-cbrt80.0%
associate-*r/80.0%
add-sqr-sqrt80.0%
associate-*r*80.0%
Applied egg-rr90.7%
if 2.1e-147 < a Initial program 23.0%
Simplified24.0%
Taylor expanded in angle around 0 55.0%
*-commutative55.0%
unpow255.0%
unpow255.0%
swap-sqr65.1%
unpow265.1%
*-commutative65.1%
unpow265.1%
unpow265.1%
swap-sqr76.7%
unpow276.7%
Simplified76.7%
associate-*r/76.7%
Applied egg-rr76.7%
Taylor expanded in a around 0 55.0%
unpow255.0%
unpow255.0%
swap-sqr65.1%
unpow265.1%
associate-*r/65.1%
unpow265.1%
unpow265.1%
swap-sqr76.7%
associate-/r*85.0%
associate-/l*85.0%
unpow285.0%
associate-*l/93.8%
associate-*r/93.8%
associate-*r/97.1%
unpow297.1%
Simplified95.8%
associate-*l/94.8%
unpow294.8%
clear-num94.8%
frac-times94.0%
*-un-lft-identity94.0%
clear-num94.0%
frac-times96.3%
*-un-lft-identity96.3%
Applied egg-rr96.3%
Final simplification93.1%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (let* ((t_0 (/ b (* y-scale (/ x-scale_m a))))) (* -4.0 (* t_0 t_0))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * (x_45_scale_m / a));
return -4.0 * (t_0 * t_0);
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = b / (y_45scale * (x_45scale_m / a))
code = (-4.0d0) * (t_0 * t_0)
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * (x_45_scale_m / a));
return -4.0 * (t_0 * t_0);
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): t_0 = b / (y_45_scale * (x_45_scale_m / a)) return -4.0 * (t_0 * t_0)
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * Float64(x_45_scale_m / a))) return Float64(-4.0 * Float64(t_0 * t_0)) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = b / (y_45_scale * (x_45_scale_m / a)); tmp = -4.0 * (t_0 * t_0); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * N[(x$45$scale$95$m / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot \frac{x-scale\_m}{a}}\\
-4 \cdot \left(t\_0 \cdot t\_0\right)
\end{array}
\end{array}
Initial program 27.8%
Simplified26.0%
Taylor expanded in angle around 0 54.6%
*-commutative54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
unpow278.7%
Simplified78.7%
associate-*r/78.7%
Applied egg-rr78.7%
Taylor expanded in a around 0 54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
associate-*r/62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
associate-/r*85.2%
associate-/l*85.2%
unpow285.2%
associate-*l/90.9%
associate-*r/90.9%
associate-*r/93.4%
unpow293.4%
Simplified95.0%
associate-*l/94.2%
unpow294.2%
clear-num94.0%
frac-times92.6%
*-un-lft-identity92.6%
clear-num92.6%
frac-times93.7%
*-un-lft-identity93.7%
Applied egg-rr93.7%
Final simplification93.7%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* -4.0 (* (/ b y-scale) (* (/ b (* y-scale (/ x-scale_m a))) (/ a x-scale_m)))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return -4.0 * ((b / y_45_scale) * ((b / (y_45_scale * (x_45_scale_m / a))) * (a / x_45_scale_m)));
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = (-4.0d0) * ((b / y_45scale) * ((b / (y_45scale * (x_45scale_m / a))) * (a / x_45scale_m)))
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return -4.0 * ((b / y_45_scale) * ((b / (y_45_scale * (x_45_scale_m / a))) * (a / x_45_scale_m)));
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return -4.0 * ((b / y_45_scale) * ((b / (y_45_scale * (x_45_scale_m / a))) * (a / x_45_scale_m)))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(-4.0 * Float64(Float64(b / y_45_scale) * Float64(Float64(b / Float64(y_45_scale * Float64(x_45_scale_m / a))) * Float64(a / x_45_scale_m)))) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = -4.0 * ((b / y_45_scale) * ((b / (y_45_scale * (x_45_scale_m / a))) * (a / x_45_scale_m))); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(-4.0 * N[(N[(b / y$45$scale), $MachinePrecision] * N[(N[(b / N[(y$45$scale * N[(x$45$scale$95$m / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
-4 \cdot \left(\frac{b}{y-scale} \cdot \left(\frac{b}{y-scale \cdot \frac{x-scale\_m}{a}} \cdot \frac{a}{x-scale\_m}\right)\right)
\end{array}
Initial program 27.8%
Simplified26.0%
Taylor expanded in angle around 0 54.6%
*-commutative54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
unpow278.7%
Simplified78.7%
associate-*r/78.7%
Applied egg-rr78.7%
Taylor expanded in a around 0 54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
associate-*r/62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
associate-/r*85.2%
associate-/l*85.2%
unpow285.2%
associate-*l/90.9%
associate-*r/90.9%
associate-*r/93.4%
unpow293.4%
Simplified95.0%
associate-*l/94.2%
unpow294.2%
associate-*r*91.2%
clear-num91.2%
frac-times90.1%
*-un-lft-identity90.1%
Applied egg-rr90.1%
Final simplification90.1%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* -4.0 (* (* (* a (/ b y-scale)) (/ a (* x-scale_m y-scale))) (/ b x-scale_m))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return -4.0 * (((a * (b / y_45_scale)) * (a / (x_45_scale_m * y_45_scale))) * (b / x_45_scale_m));
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = (-4.0d0) * (((a * (b / y_45scale)) * (a / (x_45scale_m * y_45scale))) * (b / x_45scale_m))
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return -4.0 * (((a * (b / y_45_scale)) * (a / (x_45_scale_m * y_45_scale))) * (b / x_45_scale_m));
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return -4.0 * (((a * (b / y_45_scale)) * (a / (x_45_scale_m * y_45_scale))) * (b / x_45_scale_m))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(-4.0 * Float64(Float64(Float64(a * Float64(b / y_45_scale)) * Float64(a / Float64(x_45_scale_m * y_45_scale))) * Float64(b / x_45_scale_m))) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = -4.0 * (((a * (b / y_45_scale)) * (a / (x_45_scale_m * y_45_scale))) * (b / x_45_scale_m)); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(-4.0 * N[(N[(N[(a * N[(b / y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(a / N[(x$45$scale$95$m * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
-4 \cdot \left(\left(\left(a \cdot \frac{b}{y-scale}\right) \cdot \frac{a}{x-scale\_m \cdot y-scale}\right) \cdot \frac{b}{x-scale\_m}\right)
\end{array}
Initial program 27.8%
Simplified26.0%
Taylor expanded in angle around 0 54.6%
*-commutative54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
unpow278.7%
Simplified78.7%
associate-*r/78.7%
Applied egg-rr78.7%
Taylor expanded in a around 0 54.6%
unpow254.6%
unpow254.6%
swap-sqr62.9%
unpow262.9%
associate-*r/62.9%
unpow262.9%
unpow262.9%
swap-sqr78.7%
associate-/r*85.2%
associate-/l*85.2%
unpow285.2%
associate-*l/90.9%
associate-*r/90.9%
associate-*r/93.4%
unpow293.4%
Simplified95.0%
unpow295.0%
associate-*l/92.0%
frac-times89.5%
frac-times79.1%
associate-*l/80.9%
*-commutative80.9%
times-frac87.1%
associate-*r*87.1%
*-commutative87.1%
Applied egg-rr87.1%
Final simplification87.1%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 0.0)
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return 0.0;
}
x-scale_m = abs(x_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = 0.0d0
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return 0.0;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return 0.0
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return 0.0 end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = 0.0; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := 0.0
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
0
\end{array}
Initial program 27.8%
Simplified26.0%
Taylor expanded in b around 0 29.8%
distribute-rgt-out29.8%
metadata-eval29.8%
mul0-rgt40.3%
Simplified40.3%
herbie shell --seed 2024136
(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))))