
(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 (if (<= x-scale_m 6.5e+159) (* -4.0 (pow (* x-scale_m (/ (/ y-scale a) b)) -2.0)) (/ -4.0 (pow (/ (/ (* x-scale_m y-scale) a) b) 2.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 tmp;
if (x_45_scale_m <= 6.5e+159) {
tmp = -4.0 * pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0);
} else {
tmp = -4.0 / pow((((x_45_scale_m * y_45_scale) / a) / b), 2.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) :: tmp
if (x_45scale_m <= 6.5d+159) then
tmp = (-4.0d0) * ((x_45scale_m * ((y_45scale / a) / b)) ** (-2.0d0))
else
tmp = (-4.0d0) / ((((x_45scale_m * y_45scale) / a) / b) ** 2.0d0)
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 tmp;
if (x_45_scale_m <= 6.5e+159) {
tmp = -4.0 * Math.pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0);
} else {
tmp = -4.0 / Math.pow((((x_45_scale_m * y_45_scale) / a) / b), 2.0);
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): tmp = 0 if x_45_scale_m <= 6.5e+159: tmp = -4.0 * math.pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0) else: tmp = -4.0 / math.pow((((x_45_scale_m * y_45_scale) / a) / b), 2.0) return tmp
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) tmp = 0.0 if (x_45_scale_m <= 6.5e+159) tmp = Float64(-4.0 * (Float64(x_45_scale_m * Float64(Float64(y_45_scale / a) / b)) ^ -2.0)); else tmp = Float64(-4.0 / (Float64(Float64(Float64(x_45_scale_m * y_45_scale) / a) / b) ^ 2.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) tmp = 0.0; if (x_45_scale_m <= 6.5e+159) tmp = -4.0 * ((x_45_scale_m * ((y_45_scale / a) / b)) ^ -2.0); else tmp = -4.0 / ((((x_45_scale_m * y_45_scale) / a) / b) ^ 2.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_] := If[LessEqual[x$45$scale$95$m, 6.5e+159], N[(-4.0 * N[Power[N[(x$45$scale$95$m * N[(N[(y$45$scale / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 / N[Power[N[(N[(N[(x$45$scale$95$m * y$45$scale), $MachinePrecision] / a), $MachinePrecision] / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
\mathbf{if}\;x-scale\_m \leq 6.5 \cdot 10^{+159}:\\
\;\;\;\;-4 \cdot {\left(x-scale\_m \cdot \frac{\frac{y-scale}{a}}{b}\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-4}{{\left(\frac{\frac{x-scale\_m \cdot y-scale}{a}}{b}\right)}^{2}}\\
\end{array}
\end{array}
if x-scale < 6.5000000000000001e159Initial program 24.2%
Simplified24.1%
Taylor expanded in angle around 0 48.9%
*-commutative48.9%
unpow248.9%
unpow248.9%
swap-sqr64.4%
unpow264.4%
*-commutative64.4%
unpow264.4%
unpow264.4%
swap-sqr79.4%
unpow279.4%
Simplified79.4%
clear-num79.4%
inv-pow79.4%
Applied egg-rr79.4%
unpow-179.4%
Simplified79.4%
inv-pow79.4%
add-sqr-sqrt79.3%
unpow-prod-down79.3%
div-inv78.7%
pow-flip78.7%
metadata-eval78.7%
div-inv78.7%
pow-flip78.7%
metadata-eval78.7%
Applied egg-rr78.7%
pow-sqr78.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in x-scale around 0 92.2%
associate-/l*93.8%
associate-/r*95.4%
Simplified95.4%
if 6.5000000000000001e159 < x-scale Initial program 48.8%
Simplified41.1%
Taylor expanded in angle around 0 46.2%
*-commutative46.2%
unpow246.2%
unpow246.2%
swap-sqr54.0%
unpow254.0%
*-commutative54.0%
unpow254.0%
unpow254.0%
swap-sqr84.9%
unpow284.9%
Simplified84.9%
clear-num84.9%
inv-pow84.9%
Applied egg-rr84.9%
unpow-184.9%
Simplified84.9%
unpow284.9%
Applied egg-rr84.9%
un-div-inv84.9%
associate-/r*95.9%
associate-/r*84.9%
div-inv84.9%
pow284.9%
pow-flip84.9%
metadata-eval84.9%
add-sqr-sqrt84.9%
add-sqr-sqrt84.9%
metadata-eval84.9%
pow-flip84.9%
pow284.9%
div-inv84.9%
add-sqr-sqrt84.8%
pow284.8%
Applied egg-rr95.9%
associate-/r*96.1%
Simplified96.1%
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
:precision binary64
(let* ((t_0 (/ (* x-scale_m y-scale) (* a b))))
(if (<= x-scale_m 9e+159)
(* -4.0 (pow (* x-scale_m (/ (/ y-scale a) b)) -2.0))
(* -4.0 (/ 1.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 = (x_45_scale_m * y_45_scale) / (a * b);
double tmp;
if (x_45_scale_m <= 9e+159) {
tmp = -4.0 * pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0);
} else {
tmp = -4.0 * (1.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) :: tmp
t_0 = (x_45scale_m * y_45scale) / (a * b)
if (x_45scale_m <= 9d+159) then
tmp = (-4.0d0) * ((x_45scale_m * ((y_45scale / a) / b)) ** (-2.0d0))
else
tmp = (-4.0d0) * (1.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 = (x_45_scale_m * y_45_scale) / (a * b);
double tmp;
if (x_45_scale_m <= 9e+159) {
tmp = -4.0 * Math.pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0);
} else {
tmp = -4.0 * (1.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 = (x_45_scale_m * y_45_scale) / (a * b) tmp = 0 if x_45_scale_m <= 9e+159: tmp = -4.0 * math.pow((x_45_scale_m * ((y_45_scale / a) / b)), -2.0) else: tmp = -4.0 * (1.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(Float64(x_45_scale_m * y_45_scale) / Float64(a * b)) tmp = 0.0 if (x_45_scale_m <= 9e+159) tmp = Float64(-4.0 * (Float64(x_45_scale_m * Float64(Float64(y_45_scale / a) / b)) ^ -2.0)); else tmp = Float64(-4.0 * Float64(1.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 = (x_45_scale_m * y_45_scale) / (a * b); tmp = 0.0; if (x_45_scale_m <= 9e+159) tmp = -4.0 * ((x_45_scale_m * ((y_45_scale / a) / b)) ^ -2.0); else tmp = -4.0 * (1.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[(N[(x$45$scale$95$m * y$45$scale), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$45$scale$95$m, 9e+159], N[(-4.0 * N[Power[N[(x$45$scale$95$m * N[(N[(y$45$scale / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{x-scale\_m \cdot y-scale}{a \cdot b}\\
\mathbf{if}\;x-scale\_m \leq 9 \cdot 10^{+159}:\\
\;\;\;\;-4 \cdot {\left(x-scale\_m \cdot \frac{\frac{y-scale}{a}}{b}\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{1}{t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if x-scale < 9.00000000000000053e159Initial program 24.2%
Simplified24.1%
Taylor expanded in angle around 0 48.9%
*-commutative48.9%
unpow248.9%
unpow248.9%
swap-sqr64.4%
unpow264.4%
*-commutative64.4%
unpow264.4%
unpow264.4%
swap-sqr79.4%
unpow279.4%
Simplified79.4%
clear-num79.4%
inv-pow79.4%
Applied egg-rr79.4%
unpow-179.4%
Simplified79.4%
inv-pow79.4%
add-sqr-sqrt79.3%
unpow-prod-down79.3%
div-inv78.7%
pow-flip78.7%
metadata-eval78.7%
div-inv78.7%
pow-flip78.7%
metadata-eval78.7%
Applied egg-rr78.7%
pow-sqr78.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in x-scale around 0 92.2%
associate-/l*93.8%
associate-/r*95.4%
Simplified95.4%
if 9.00000000000000053e159 < x-scale Initial program 48.8%
Simplified41.1%
Taylor expanded in angle around 0 46.2%
*-commutative46.2%
unpow246.2%
unpow246.2%
swap-sqr54.0%
unpow254.0%
*-commutative54.0%
unpow254.0%
unpow254.0%
swap-sqr84.9%
unpow284.9%
Simplified84.9%
clear-num84.9%
inv-pow84.9%
Applied egg-rr84.9%
unpow-184.9%
Simplified84.9%
add-log-exp70.3%
div-inv70.3%
exp-prod70.3%
pow-flip70.3%
metadata-eval70.3%
Applied egg-rr70.3%
pow-exp70.3%
add-log-exp84.9%
metadata-eval84.9%
pow-flip84.9%
pow284.9%
div-inv84.9%
pow284.9%
times-frac95.9%
Applied egg-rr95.9%
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))))) (* -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 = a * (b / (x_45_scale_m * y_45_scale));
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 = a * (b / (x_45scale_m * y_45scale))
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 = a * (b / (x_45_scale_m * y_45_scale));
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 = a * (b / (x_45_scale_m * y_45_scale)) 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(a * Float64(b / Float64(x_45_scale_m * y_45_scale))) 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 = a * (b / (x_45_scale_m * y_45_scale)); 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[(a * N[(b / N[(x$45$scale$95$m * y$45$scale), $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 := a \cdot \frac{b}{x-scale\_m \cdot y-scale}\\
-4 \cdot \left(t\_0 \cdot t\_0\right)
\end{array}
\end{array}
Initial program 26.7%
Simplified25.8%
Taylor expanded in angle around 0 48.6%
*-commutative48.6%
unpow248.6%
unpow248.6%
swap-sqr63.4%
unpow263.4%
*-commutative63.4%
unpow263.4%
unpow263.4%
swap-sqr79.9%
unpow279.9%
Simplified79.9%
clear-num80.0%
inv-pow80.0%
Applied egg-rr80.0%
unpow-180.0%
Simplified80.0%
inv-pow80.0%
add-sqr-sqrt79.9%
unpow-prod-down79.9%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
Applied egg-rr79.3%
pow-sqr79.3%
metadata-eval79.3%
Simplified79.3%
sqrt-pow279.4%
metadata-eval79.4%
unpow-prod-down79.4%
metadata-eval79.4%
pow-flip79.4%
pow279.4%
unpow-prod-down79.4%
div-inv80.0%
inv-pow80.0%
clear-num79.9%
pow279.9%
times-frac92.6%
associate-/l*91.3%
associate-/l*94.6%
Applied egg-rr94.6%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* -4.0 (* a (/ (/ b (* x-scale_m y-scale)) (/ (/ (* x-scale_m y-scale) a) b)))))
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 / (x_45_scale_m * y_45_scale)) / (((x_45_scale_m * y_45_scale) / a) / b)));
}
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 / (x_45scale_m * y_45scale)) / (((x_45scale_m * y_45scale) / a) / b)))
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 / (x_45_scale_m * y_45_scale)) / (((x_45_scale_m * y_45_scale) / a) / b)));
}
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 / (x_45_scale_m * y_45_scale)) / (((x_45_scale_m * y_45_scale) / a) / b)))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(-4.0 * Float64(a * Float64(Float64(b / Float64(x_45_scale_m * y_45_scale)) / Float64(Float64(Float64(x_45_scale_m * y_45_scale) / a) / b)))) 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 / (x_45_scale_m * y_45_scale)) / (((x_45_scale_m * y_45_scale) / a) / b))); 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[(a * N[(N[(b / N[(x$45$scale$95$m * y$45$scale), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(x$45$scale$95$m * y$45$scale), $MachinePrecision] / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
-4 \cdot \left(a \cdot \frac{\frac{b}{x-scale\_m \cdot y-scale}}{\frac{\frac{x-scale\_m \cdot y-scale}{a}}{b}}\right)
\end{array}
Initial program 26.7%
Simplified25.8%
Taylor expanded in angle around 0 48.6%
*-commutative48.6%
unpow248.6%
unpow248.6%
swap-sqr63.4%
unpow263.4%
*-commutative63.4%
unpow263.4%
unpow263.4%
swap-sqr79.9%
unpow279.9%
Simplified79.9%
clear-num80.0%
inv-pow80.0%
Applied egg-rr80.0%
unpow-180.0%
Simplified80.0%
inv-pow80.0%
add-sqr-sqrt79.9%
unpow-prod-down79.9%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
Applied egg-rr79.3%
pow-sqr79.3%
metadata-eval79.3%
Simplified79.3%
sqrt-pow279.4%
metadata-eval79.4%
unpow-prod-down79.4%
metadata-eval79.4%
pow-flip79.4%
pow279.4%
unpow-prod-down79.4%
div-inv80.0%
inv-pow80.0%
add-sqr-sqrt79.9%
associate-/r*79.9%
Applied egg-rr91.3%
associate-/l*87.0%
associate-/r*88.2%
Simplified88.2%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* -4.0 (* a (/ (/ b (* x-scale_m y-scale)) (* x-scale_m (/ (/ y-scale a) b))))))
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 / (x_45_scale_m * y_45_scale)) / (x_45_scale_m * ((y_45_scale / a) / b))));
}
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 / (x_45scale_m * y_45scale)) / (x_45scale_m * ((y_45scale / a) / b))))
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 / (x_45_scale_m * y_45_scale)) / (x_45_scale_m * ((y_45_scale / a) / b))));
}
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 / (x_45_scale_m * y_45_scale)) / (x_45_scale_m * ((y_45_scale / a) / b))))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(-4.0 * Float64(a * Float64(Float64(b / Float64(x_45_scale_m * y_45_scale)) / Float64(x_45_scale_m * Float64(Float64(y_45_scale / a) / b))))) 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 / (x_45_scale_m * y_45_scale)) / (x_45_scale_m * ((y_45_scale / a) / b)))); 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[(a * N[(N[(b / N[(x$45$scale$95$m * y$45$scale), $MachinePrecision]), $MachinePrecision] / N[(x$45$scale$95$m * N[(N[(y$45$scale / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
-4 \cdot \left(a \cdot \frac{\frac{b}{x-scale\_m \cdot y-scale}}{x-scale\_m \cdot \frac{\frac{y-scale}{a}}{b}}\right)
\end{array}
Initial program 26.7%
Simplified25.8%
Taylor expanded in angle around 0 48.6%
*-commutative48.6%
unpow248.6%
unpow248.6%
swap-sqr63.4%
unpow263.4%
*-commutative63.4%
unpow263.4%
unpow263.4%
swap-sqr79.9%
unpow279.9%
Simplified79.9%
clear-num80.0%
inv-pow80.0%
Applied egg-rr80.0%
unpow-180.0%
Simplified80.0%
inv-pow80.0%
add-sqr-sqrt79.9%
unpow-prod-down79.9%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
div-inv79.3%
pow-flip79.3%
metadata-eval79.3%
Applied egg-rr79.3%
pow-sqr79.3%
metadata-eval79.3%
Simplified79.3%
sqrt-pow279.4%
metadata-eval79.4%
unpow-prod-down79.4%
metadata-eval79.4%
pow-flip79.4%
pow279.4%
unpow-prod-down79.4%
div-inv80.0%
inv-pow80.0%
add-sqr-sqrt79.9%
associate-/r*79.9%
Applied egg-rr91.3%
associate-/l*87.0%
associate-/l*86.5%
associate-/r*87.8%
Simplified87.8%
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 26.7%
Simplified25.8%
Taylor expanded in b around 0 26.5%
distribute-rgt-out26.5%
metadata-eval26.5%
mul0-rgt36.7%
Simplified36.7%
herbie shell --seed 2024185
(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))))