
(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}
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (pow (* (/ a x-scale) (/ b y-scale)) 2.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * pow(((a / x_45_scale) * (b / y_45_scale)), 2.0);
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
code = (-4.0d0) * (((a / x_45scale) * (b / y_45scale)) ** 2.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * Math.pow(((a / x_45_scale) * (b / y_45_scale)), 2.0);
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * math.pow(((a / x_45_scale) * (b / y_45_scale)), 2.0)
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * (Float64(Float64(a / x_45_scale) * Float64(b / y_45_scale)) ^ 2.0)) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * (((a / x_45_scale) * (b / y_45_scale)) ^ 2.0); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[Power[N[(N[(a / x$45$scale), $MachinePrecision] * N[(b / y$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot {\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2}
\end{array}
Initial program 22.6%
Simplified20.5%
Taylor expanded in angle around 0 53.5%
add-sqr-sqrt53.5%
pow253.5%
div-inv53.5%
pow-prod-down66.4%
pow-prod-down82.6%
pow-flip83.0%
metadata-eval83.0%
Applied egg-rr83.0%
Taylor expanded in a around 0 92.8%
times-frac95.3%
Simplified95.3%
Final simplification95.3%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ a y-scale) (/ b x-scale))))
(if (<= a 1.45e-229)
(* -4.0 (/ (* t_0 (/ a (/ x-scale b))) y-scale))
(* -4.0 (/ (* a t_0) (/ y-scale (/ b x-scale)))))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b / x_45_scale);
double tmp;
if (a <= 1.45e-229) {
tmp = -4.0 * ((t_0 * (a / (x_45_scale / b))) / y_45_scale);
} else {
tmp = -4.0 * ((a * t_0) / (y_45_scale / (b / x_45_scale)));
}
return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
real(8) :: t_0
real(8) :: tmp
t_0 = (a / y_45scale) * (b / x_45scale)
if (a <= 1.45d-229) then
tmp = (-4.0d0) * ((t_0 * (a / (x_45scale / b))) / y_45scale)
else
tmp = (-4.0d0) * ((a * t_0) / (y_45scale / (b / x_45scale)))
end if
code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b / x_45_scale);
double tmp;
if (a <= 1.45e-229) {
tmp = -4.0 * ((t_0 * (a / (x_45_scale / b))) / y_45_scale);
} else {
tmp = -4.0 * ((a * t_0) / (y_45_scale / (b / x_45_scale)));
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (a / y_45_scale) * (b / x_45_scale) tmp = 0 if a <= 1.45e-229: tmp = -4.0 * ((t_0 * (a / (x_45_scale / b))) / y_45_scale) else: tmp = -4.0 * ((a * t_0) / (y_45_scale / (b / x_45_scale))) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a / y_45_scale) * Float64(b / x_45_scale)) tmp = 0.0 if (a <= 1.45e-229) tmp = Float64(-4.0 * Float64(Float64(t_0 * Float64(a / Float64(x_45_scale / b))) / y_45_scale)); else tmp = Float64(-4.0 * Float64(Float64(a * t_0) / Float64(y_45_scale / Float64(b / x_45_scale)))); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (a / y_45_scale) * (b / x_45_scale); tmp = 0.0; if (a <= 1.45e-229) tmp = -4.0 * ((t_0 * (a / (x_45_scale / b))) / y_45_scale); else tmp = -4.0 * ((a * t_0) / (y_45_scale / (b / x_45_scale))); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a / y$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 1.45e-229], N[(-4.0 * N[(N[(t$95$0 * N[(a / N[(x$45$scale / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(a * t$95$0), $MachinePrecision] / N[(y$45$scale / N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{y-scale} \cdot \frac{b}{x-scale}\\
\mathbf{if}\;a \leq 1.45 \cdot 10^{-229}:\\
\;\;\;\;-4 \cdot \frac{t_0 \cdot \frac{a}{\frac{x-scale}{b}}}{y-scale}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t_0}{\frac{y-scale}{\frac{b}{x-scale}}}\\
\end{array}
\end{array}
if a < 1.45e-229Initial program 23.7%
Simplified21.7%
Taylor expanded in angle around 0 55.3%
add-sqr-sqrt55.3%
pow255.3%
div-inv55.3%
pow-prod-down68.0%
pow-prod-down83.3%
pow-flip83.3%
metadata-eval83.3%
Applied egg-rr83.3%
Taylor expanded in a around 0 93.5%
times-frac95.2%
Simplified95.2%
unpow295.2%
associate-*r/95.2%
associate-*l/93.8%
associate-*l/89.4%
associate-/l*90.0%
frac-times87.1%
*-commutative87.1%
times-frac92.6%
Applied egg-rr92.6%
if 1.45e-229 < a Initial program 21.0%
Simplified18.9%
Taylor expanded in angle around 0 51.0%
add-sqr-sqrt51.0%
pow251.0%
div-inv51.0%
pow-prod-down64.0%
pow-prod-down81.5%
pow-flip82.5%
metadata-eval82.5%
Applied egg-rr82.5%
Taylor expanded in a around 0 91.8%
times-frac95.4%
Simplified95.4%
unpow295.4%
frac-times87.7%
associate-/l*88.7%
associate-*r/87.7%
frac-times89.9%
*-commutative89.9%
times-frac86.5%
*-commutative86.5%
associate-/l*92.3%
Applied egg-rr92.3%
Final simplification92.5%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (/ (* a b) (* (* (/ x-scale a) (/ y-scale b)) (* x-scale y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((a * b) / (((x_45_scale / a) * (y_45_scale / b)) * (x_45_scale * y_45_scale)));
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
code = (-4.0d0) * ((a * b) / (((x_45scale / a) * (y_45scale / b)) * (x_45scale * y_45scale)))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((a * b) / (((x_45_scale / a) * (y_45_scale / b)) * (x_45_scale * y_45_scale)));
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * ((a * b) / (((x_45_scale / a) * (y_45_scale / b)) * (x_45_scale * y_45_scale)))
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * Float64(Float64(a * b) / Float64(Float64(Float64(x_45_scale / a) * Float64(y_45_scale / b)) * Float64(x_45_scale * y_45_scale)))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * ((a * b) / (((x_45_scale / a) * (y_45_scale / b)) * (x_45_scale * y_45_scale))); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(N[(a * b), $MachinePrecision] / N[(N[(N[(x$45$scale / a), $MachinePrecision] * N[(y$45$scale / b), $MachinePrecision]), $MachinePrecision] * N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{a \cdot b}{\left(\frac{x-scale}{a} \cdot \frac{y-scale}{b}\right) \cdot \left(x-scale \cdot y-scale\right)}
\end{array}
Initial program 22.6%
Simplified20.5%
Taylor expanded in angle around 0 53.5%
add-sqr-sqrt53.5%
pow253.5%
div-inv53.5%
pow-prod-down66.4%
pow-prod-down82.6%
pow-flip83.0%
metadata-eval83.0%
Applied egg-rr83.0%
Taylor expanded in a around 0 92.8%
times-frac95.3%
Simplified95.3%
frac-times92.8%
unpow292.8%
clear-num92.8%
*-commutative92.8%
frac-times90.8%
*-un-lft-identity90.8%
times-frac87.3%
*-commutative87.3%
Applied egg-rr87.3%
Final simplification87.3%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (/ (* a (* (/ a y-scale) (/ b x-scale))) (/ y-scale (/ b x-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((a * ((a / y_45_scale) * (b / x_45_scale))) / (y_45_scale / (b / x_45_scale)));
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
code = (-4.0d0) * ((a * ((a / y_45scale) * (b / x_45scale))) / (y_45scale / (b / x_45scale)))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((a * ((a / y_45_scale) * (b / x_45_scale))) / (y_45_scale / (b / x_45_scale)));
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * ((a * ((a / y_45_scale) * (b / x_45_scale))) / (y_45_scale / (b / x_45_scale)))
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * Float64(Float64(a * Float64(Float64(a / y_45_scale) * Float64(b / x_45_scale))) / Float64(y_45_scale / Float64(b / x_45_scale)))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * ((a * ((a / y_45_scale) * (b / x_45_scale))) / (y_45_scale / (b / x_45_scale))); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(N[(a * N[(N[(a / y$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale / N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \frac{a \cdot \left(\frac{a}{y-scale} \cdot \frac{b}{x-scale}\right)}{\frac{y-scale}{\frac{b}{x-scale}}}
\end{array}
Initial program 22.6%
Simplified20.5%
Taylor expanded in angle around 0 53.5%
add-sqr-sqrt53.5%
pow253.5%
div-inv53.5%
pow-prod-down66.4%
pow-prod-down82.6%
pow-flip83.0%
metadata-eval83.0%
Applied egg-rr83.0%
Taylor expanded in a around 0 92.8%
times-frac95.3%
Simplified95.3%
unpow295.3%
frac-times88.5%
associate-/l*89.0%
associate-*r/87.6%
frac-times89.6%
*-commutative89.6%
times-frac87.1%
*-commutative87.1%
associate-/l*91.0%
Applied egg-rr91.0%
Final simplification91.0%
(FPCore (a b angle x-scale y-scale) :precision binary64 (let* ((t_0 (* (/ a y-scale) (/ b x-scale)))) (* t_0 (* -4.0 t_0))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b / x_45_scale);
return t_0 * (-4.0 * t_0);
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
real(8) :: t_0
t_0 = (a / y_45scale) * (b / x_45scale)
code = t_0 * ((-4.0d0) * t_0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b / x_45_scale);
return t_0 * (-4.0 * t_0);
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (a / y_45_scale) * (b / x_45_scale) return t_0 * (-4.0 * t_0)
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a / y_45_scale) * Float64(b / x_45_scale)) return Float64(t_0 * Float64(-4.0 * t_0)) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (a / y_45_scale) * (b / x_45_scale); tmp = t_0 * (-4.0 * t_0); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a / y$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(-4.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{y-scale} \cdot \frac{b}{x-scale}\\
t_0 \cdot \left(-4 \cdot t_0\right)
\end{array}
\end{array}
Initial program 22.6%
Simplified20.5%
Taylor expanded in angle around 0 53.5%
associate-*r/53.5%
*-commutative53.5%
*-commutative53.5%
pow-prod-down66.3%
*-commutative66.3%
pow-prod-down82.9%
Applied egg-rr82.9%
*-commutative82.9%
pow-prod-down66.4%
Applied egg-rr66.4%
*-commutative66.4%
unpow-prod-down82.9%
*-un-lft-identity82.9%
times-frac82.9%
metadata-eval82.9%
unpow282.9%
unpow282.9%
frac-times92.8%
*-commutative92.8%
*-commutative92.8%
unpow292.8%
*-commutative92.8%
frac-times95.3%
unpow295.3%
associate-*l*95.3%
Applied egg-rr94.7%
Final simplification94.7%
(FPCore (a b angle x-scale y-scale) :precision binary64 0.0)
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
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
code = 0.0d0
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return 0.0;
}
def code(a, b, angle, x_45_scale, y_45_scale): return 0.0
function code(a, b, angle, x_45_scale, y_45_scale) return 0.0 end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 22.6%
Simplified22.7%
Taylor expanded in b around 0 22.7%
distribute-rgt-out22.7%
metadata-eval22.7%
mul0-rgt30.3%
Simplified30.3%
Final simplification30.3%
herbie shell --seed 2023318
(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))))