
(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}
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (pow (/ b (* (/ x-scale a) y-scale)) 2.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * pow((b / ((x_45_scale / a) * 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) * ((b / ((x_45scale / a) * 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((b / ((x_45_scale / a) * y_45_scale)), 2.0);
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * math.pow((b / ((x_45_scale / a) * y_45_scale)), 2.0)
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * (Float64(b / Float64(Float64(x_45_scale / a) * y_45_scale)) ^ 2.0)) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * ((b / ((x_45_scale / a) * y_45_scale)) ^ 2.0); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[Power[N[(b / N[(N[(x$45$scale / a), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot {\left(\frac{b}{\frac{x-scale}{a} \cdot y-scale}\right)}^{2}
\end{array}
Initial program 26.8%
Simplified22.6%
Taylor expanded in angle around 0 53.1%
*-commutative53.1%
unpow253.1%
unpow253.1%
swap-sqr64.8%
unpow264.8%
unpow264.8%
unpow264.8%
swap-sqr77.3%
unpow277.3%
Simplified77.3%
pow-to-exp39.5%
pow-to-exp23.5%
div-exp26.3%
Applied egg-rr26.3%
*-un-lft-identity26.3%
exp-prod26.3%
distribute-rgt-out--26.3%
diff-log60.8%
Applied egg-rr60.8%
exp-prod60.9%
*-lft-identity60.9%
*-commutative60.9%
exp-to-pow94.4%
*-commutative94.4%
times-frac95.9%
Simplified95.9%
clear-num95.9%
frac-times96.7%
*-un-lft-identity96.7%
Applied egg-rr96.7%
(FPCore (a b angle x-scale y-scale) :precision binary64 (if (<= a 9e-171) (* -4.0 (* (/ b y-scale) (* (/ a x-scale) (/ (/ b y-scale) (/ x-scale a))))) (* -4.0 (pow (* a (/ b (* x-scale y-scale))) 2.0))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (a <= 9e-171) {
tmp = -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a))));
} else {
tmp = -4.0 * pow((a * (b / (x_45_scale * y_45_scale))), 2.0);
}
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) :: tmp
if (a <= 9d-171) then
tmp = (-4.0d0) * ((b / y_45scale) * ((a / x_45scale) * ((b / y_45scale) / (x_45scale / a))))
else
tmp = (-4.0d0) * ((a * (b / (x_45scale * y_45scale))) ** 2.0d0)
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 tmp;
if (a <= 9e-171) {
tmp = -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a))));
} else {
tmp = -4.0 * Math.pow((a * (b / (x_45_scale * y_45_scale))), 2.0);
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): tmp = 0 if a <= 9e-171: tmp = -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a)))) else: tmp = -4.0 * math.pow((a * (b / (x_45_scale * y_45_scale))), 2.0) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0 if (a <= 9e-171) tmp = Float64(-4.0 * Float64(Float64(b / y_45_scale) * Float64(Float64(a / x_45_scale) * Float64(Float64(b / y_45_scale) / Float64(x_45_scale / a))))); else tmp = Float64(-4.0 * (Float64(a * Float64(b / Float64(x_45_scale * y_45_scale))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0; if (a <= 9e-171) tmp = -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a)))); else tmp = -4.0 * ((a * (b / (x_45_scale * y_45_scale))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[a, 9e-171], N[(-4.0 * N[(N[(b / y$45$scale), $MachinePrecision] * N[(N[(a / x$45$scale), $MachinePrecision] * N[(N[(b / y$45$scale), $MachinePrecision] / N[(x$45$scale / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[Power[N[(a * N[(b / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9 \cdot 10^{-171}:\\
\;\;\;\;-4 \cdot \left(\frac{b}{y-scale} \cdot \left(\frac{a}{x-scale} \cdot \frac{\frac{b}{y-scale}}{\frac{x-scale}{a}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot {\left(a \cdot \frac{b}{x-scale \cdot y-scale}\right)}^{2}\\
\end{array}
\end{array}
if a < 9.0000000000000008e-171Initial program 28.3%
Simplified22.3%
Taylor expanded in angle around 0 53.9%
*-commutative53.9%
unpow253.9%
unpow253.9%
swap-sqr65.7%
unpow265.7%
unpow265.7%
unpow265.7%
swap-sqr79.2%
unpow279.2%
Simplified79.2%
pow-to-exp42.3%
pow-to-exp26.3%
div-exp29.1%
Applied egg-rr29.1%
*-un-lft-identity29.1%
exp-prod29.1%
distribute-rgt-out--29.1%
diff-log66.9%
Applied egg-rr66.9%
exp-prod67.1%
*-lft-identity67.1%
*-commutative67.1%
exp-to-pow95.3%
*-commutative95.3%
times-frac95.4%
Simplified95.4%
unpow295.4%
frac-times91.2%
*-commutative91.2%
associate-*r/91.7%
associate-*r*90.1%
associate-*r/90.7%
*-commutative90.7%
frac-times93.8%
clear-num93.8%
un-div-inv93.8%
Applied egg-rr93.8%
if 9.0000000000000008e-171 < a Initial program 24.5%
Simplified23.2%
Taylor expanded in angle around 0 51.9%
*-commutative51.9%
unpow251.9%
unpow251.9%
swap-sqr63.5%
unpow263.5%
unpow263.5%
unpow263.5%
swap-sqr74.5%
unpow274.5%
Simplified74.5%
pow-to-exp35.2%
pow-to-exp19.2%
div-exp22.1%
Applied egg-rr22.1%
*-un-lft-identity22.1%
exp-prod22.1%
distribute-rgt-out--22.1%
diff-log51.4%
Applied egg-rr51.4%
exp-prod51.4%
*-lft-identity51.4%
*-commutative51.4%
exp-to-pow93.0%
*-commutative93.0%
times-frac96.8%
Simplified96.8%
Taylor expanded in a around 0 93.0%
associate-/l*94.9%
Simplified94.9%
Final simplification94.2%
(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 26.8%
Simplified22.6%
Taylor expanded in angle around 0 53.1%
*-commutative53.1%
unpow253.1%
unpow253.1%
swap-sqr64.8%
unpow264.8%
unpow264.8%
unpow264.8%
swap-sqr77.3%
unpow277.3%
Simplified77.3%
pow-to-exp39.5%
pow-to-exp23.5%
div-exp26.3%
Applied egg-rr26.3%
*-un-lft-identity26.3%
exp-prod26.3%
distribute-rgt-out--26.3%
diff-log60.8%
Applied egg-rr60.8%
exp-prod60.9%
*-lft-identity60.9%
*-commutative60.9%
exp-to-pow94.4%
*-commutative94.4%
times-frac95.9%
Simplified95.9%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* -4.0 (* (/ b y-scale) (* (/ a x-scale) (/ (/ b y-scale) (/ x-scale a))))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a))));
}
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) * ((b / y_45scale) * ((a / x_45scale) * ((b / y_45scale) / (x_45scale / a))))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a))));
}
def code(a, b, angle, x_45_scale, y_45_scale): return -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a))))
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(-4.0 * Float64(Float64(b / y_45_scale) * Float64(Float64(a / x_45_scale) * Float64(Float64(b / y_45_scale) / Float64(x_45_scale / a))))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = -4.0 * ((b / y_45_scale) * ((a / x_45_scale) * ((b / y_45_scale) / (x_45_scale / a)))); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(N[(b / y$45$scale), $MachinePrecision] * N[(N[(a / x$45$scale), $MachinePrecision] * N[(N[(b / y$45$scale), $MachinePrecision] / N[(x$45$scale / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{b}{y-scale} \cdot \left(\frac{a}{x-scale} \cdot \frac{\frac{b}{y-scale}}{\frac{x-scale}{a}}\right)\right)
\end{array}
Initial program 26.8%
Simplified22.6%
Taylor expanded in angle around 0 53.1%
*-commutative53.1%
unpow253.1%
unpow253.1%
swap-sqr64.8%
unpow264.8%
unpow264.8%
unpow264.8%
swap-sqr77.3%
unpow277.3%
Simplified77.3%
pow-to-exp39.5%
pow-to-exp23.5%
div-exp26.3%
Applied egg-rr26.3%
*-un-lft-identity26.3%
exp-prod26.3%
distribute-rgt-out--26.3%
diff-log60.8%
Applied egg-rr60.8%
exp-prod60.9%
*-lft-identity60.9%
*-commutative60.9%
exp-to-pow94.4%
*-commutative94.4%
times-frac95.9%
Simplified95.9%
unpow295.9%
frac-times91.2%
*-commutative91.2%
associate-*r/92.7%
associate-*r*90.8%
associate-*r/90.1%
*-commutative90.1%
frac-times94.1%
clear-num94.1%
un-div-inv94.1%
Applied egg-rr94.1%
Final simplification94.1%
(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 26.8%
Simplified23.6%
Taylor expanded in b around 0 25.5%
distribute-rgt-out25.5%
metadata-eval25.5%
mul0-rgt37.3%
Simplified37.3%
herbie shell --seed 2024112
(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))))