
(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}
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (if (<= a_m 1.2e+235) (* -4.0 (pow (* (/ a_m (* x-scale y-scale)) b) 2.0)) (/ -4.0 (pow (* (/ x-scale a_m) (/ y-scale b)) 2.0))))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (a_m <= 1.2e+235) {
tmp = -4.0 * pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0);
} else {
tmp = -4.0 / pow(((x_45_scale / a_m) * (y_45_scale / b)), 2.0);
}
return tmp;
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: tmp
if (a_m <= 1.2d+235) then
tmp = (-4.0d0) * (((a_m / (x_45scale * y_45scale)) * b) ** 2.0d0)
else
tmp = (-4.0d0) / (((x_45scale / a_m) * (y_45scale / b)) ** 2.0d0)
end if
code = tmp
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (a_m <= 1.2e+235) {
tmp = -4.0 * Math.pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0);
} else {
tmp = -4.0 / Math.pow(((x_45_scale / a_m) * (y_45_scale / b)), 2.0);
}
return tmp;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): tmp = 0 if a_m <= 1.2e+235: tmp = -4.0 * math.pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0) else: tmp = -4.0 / math.pow(((x_45_scale / a_m) * (y_45_scale / b)), 2.0) return tmp
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) tmp = 0.0 if (a_m <= 1.2e+235) tmp = Float64(-4.0 * (Float64(Float64(a_m / Float64(x_45_scale * y_45_scale)) * b) ^ 2.0)); else tmp = Float64(-4.0 / (Float64(Float64(x_45_scale / a_m) * Float64(y_45_scale / b)) ^ 2.0)); end return tmp end
a_m = abs(a); function tmp_2 = code(a_m, b, angle, x_45_scale, y_45_scale) tmp = 0.0; if (a_m <= 1.2e+235) tmp = -4.0 * (((a_m / (x_45_scale * y_45_scale)) * b) ^ 2.0); else tmp = -4.0 / (((x_45_scale / a_m) * (y_45_scale / b)) ^ 2.0); end tmp_2 = tmp; end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[a$95$m, 1.2e+235], N[(-4.0 * N[Power[N[(N[(a$95$m / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 / N[Power[N[(N[(x$45$scale / a$95$m), $MachinePrecision] * N[(y$45$scale / b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
\mathbf{if}\;a_m \leq 1.2 \cdot 10^{+235}:\\
\;\;\;\;-4 \cdot {\left(\frac{a_m}{x-scale \cdot y-scale} \cdot b\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-4}{{\left(\frac{x-scale}{a_m} \cdot \frac{y-scale}{b}\right)}^{2}}\\
\end{array}
\end{array}
if a < 1.2e235Initial program 26.2%
Simplified24.1%
Taylor expanded in angle around 0 47.9%
associate-*r/47.9%
*-commutative47.9%
unpow247.9%
unpow247.9%
swap-sqr60.5%
unpow260.5%
Simplified60.5%
pow-prod-down47.9%
associate-*r/47.9%
expm1-log1p-u26.0%
expm1-udef25.6%
div-inv25.5%
*-commutative25.5%
pow-prod-down28.4%
pow-prod-down32.5%
*-commutative32.5%
pow-flip32.5%
*-commutative32.5%
metadata-eval32.5%
Applied egg-rr32.5%
expm1-def39.9%
expm1-log1p78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
unpow278.3%
Applied egg-rr78.3%
Taylor expanded in a around 0 47.9%
unpow247.9%
unpow247.9%
swap-sqr59.3%
unpow259.3%
associate-*r/59.3%
unpow259.3%
unpow259.3%
swap-sqr78.2%
unpow278.2%
associate-/l*77.9%
unpow277.9%
associate-/l*83.4%
*-rgt-identity83.4%
associate-*r/83.4%
associate-/l*83.7%
Simplified94.4%
if 1.2e235 < a Initial program 0.0%
Simplified0.0%
Taylor expanded in angle around 0 50.0%
*-commutative50.0%
Simplified50.0%
associate-*r/50.0%
associate-/l*50.0%
pow-prod-down58.7%
*-commutative58.7%
pow-prod-down75.6%
Applied egg-rr75.6%
unpow275.6%
Applied egg-rr75.6%
Taylor expanded in x-scale around 0 50.0%
unpow250.0%
unpow250.0%
swap-sqr58.7%
unpow258.7%
unpow258.7%
unpow258.7%
swap-sqr75.6%
associate-/l/83.6%
unpow283.6%
associate-*r/99.6%
associate-*l/99.7%
unpow299.7%
times-frac97.0%
Simplified97.0%
Final simplification94.5%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* -4.0 (pow (* (/ a_m (* x-scale y-scale)) b) 2.0)))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0);
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = (-4.0d0) * (((a_m / (x_45scale * y_45scale)) * b) ** 2.0d0)
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * Math.pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0);
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): return -4.0 * math.pow(((a_m / (x_45_scale * y_45_scale)) * b), 2.0)
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * (Float64(Float64(a_m / Float64(x_45_scale * y_45_scale)) * b) ^ 2.0)) end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * (((a_m / (x_45_scale * y_45_scale)) * b) ^ 2.0); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[Power[N[(N[(a$95$m / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
-4 \cdot {\left(\frac{a_m}{x-scale \cdot y-scale} \cdot b\right)}^{2}
\end{array}
Initial program 25.0%
Simplified23.0%
Taylor expanded in angle around 0 48.0%
associate-*r/48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr60.4%
unpow260.4%
Simplified60.4%
pow-prod-down48.0%
associate-*r/48.0%
expm1-log1p-u24.8%
expm1-udef24.4%
div-inv24.4%
*-commutative24.4%
pow-prod-down27.5%
pow-prod-down31.4%
*-commutative31.4%
pow-flip31.4%
*-commutative31.4%
metadata-eval31.4%
Applied egg-rr31.4%
expm1-def38.5%
expm1-log1p78.1%
*-commutative78.1%
associate-*l*78.1%
Simplified78.1%
unpow278.1%
Applied egg-rr78.1%
Taylor expanded in a around 0 48.0%
unpow248.0%
unpow248.0%
swap-sqr59.6%
unpow259.6%
associate-*r/59.6%
unpow259.6%
unpow259.6%
swap-sqr78.0%
unpow278.0%
associate-/l*77.8%
unpow277.8%
associate-/l*83.8%
*-rgt-identity83.8%
associate-*r/83.8%
associate-/l*84.1%
Simplified94.3%
Final simplification94.3%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* -4.0 (* (/ (* a_m (* a_m b)) (* x-scale y-scale)) (/ b (* x-scale y-scale)))))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * (((a_m * (a_m * b)) / (x_45_scale * y_45_scale)) * (b / (x_45_scale * y_45_scale)));
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = (-4.0d0) * (((a_m * (a_m * b)) / (x_45scale * y_45scale)) * (b / (x_45scale * y_45scale)))
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * (((a_m * (a_m * b)) / (x_45_scale * y_45_scale)) * (b / (x_45_scale * y_45_scale)));
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): return -4.0 * (((a_m * (a_m * b)) / (x_45_scale * y_45_scale)) * (b / (x_45_scale * y_45_scale)))
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * Float64(Float64(Float64(a_m * Float64(a_m * b)) / Float64(x_45_scale * y_45_scale)) * Float64(b / Float64(x_45_scale * y_45_scale)))) end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * (((a_m * (a_m * b)) / (x_45_scale * y_45_scale)) * (b / (x_45_scale * y_45_scale))); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(N[(N[(a$95$m * N[(a$95$m * b), $MachinePrecision]), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(b / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
-4 \cdot \left(\frac{a_m \cdot \left(a_m \cdot b\right)}{x-scale \cdot y-scale} \cdot \frac{b}{x-scale \cdot y-scale}\right)
\end{array}
Initial program 25.0%
Simplified23.0%
Taylor expanded in angle around 0 48.0%
*-commutative48.0%
Simplified48.0%
pow-prod-down59.6%
Applied egg-rr59.6%
*-commutative59.6%
pow259.6%
associate-*r*57.7%
pow-prod-down75.0%
unpow275.0%
times-frac83.6%
Applied egg-rr83.6%
Final simplification83.6%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (let* ((t_0 (/ (* a_m b) (* x-scale y-scale)))) (* t_0 (* -4.0 t_0))))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a_m * b) / (x_45_scale * y_45_scale);
return t_0 * (-4.0 * t_0);
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = (a_m * b) / (x_45scale * y_45scale)
code = t_0 * ((-4.0d0) * t_0)
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a_m * b) / (x_45_scale * y_45_scale);
return t_0 * (-4.0 * t_0);
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): t_0 = (a_m * b) / (x_45_scale * y_45_scale) return t_0 * (-4.0 * t_0)
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a_m * b) / Float64(x_45_scale * y_45_scale)) return Float64(t_0 * Float64(-4.0 * t_0)) end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = (a_m * b) / (x_45_scale * y_45_scale); tmp = t_0 * (-4.0 * t_0); end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a$95$m * b), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(-4.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \frac{a_m \cdot b}{x-scale \cdot y-scale}\\
t_0 \cdot \left(-4 \cdot t_0\right)
\end{array}
\end{array}
Initial program 25.0%
Simplified23.0%
Taylor expanded in angle around 0 48.0%
*-commutative48.0%
Simplified48.0%
associate-*r/48.0%
associate-/l*48.0%
pow-prod-down60.4%
*-commutative60.4%
pow-prod-down77.8%
Applied egg-rr77.8%
unpow278.1%
Applied egg-rr77.8%
div-inv77.8%
pow-prod-down59.6%
pow259.6%
*-commutative59.6%
clear-num59.6%
add-sqr-sqrt59.6%
associate-*r*59.6%
Applied egg-rr93.8%
Final simplification93.8%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 0.0)
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = 0.0d0
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): return 0.0
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return 0.0 end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) tmp = 0.0; end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := 0.0
\begin{array}{l}
a_m = \left|a\right|
\\
0
\end{array}
Initial program 25.0%
Simplified24.7%
Taylor expanded in b around 0 24.4%
distribute-rgt-out24.4%
metadata-eval24.4%
mul0-rgt34.8%
Simplified34.8%
Final simplification34.8%
herbie shell --seed 2024011
(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))))