
(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)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
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 7 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)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
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}
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ a y-scale) (/ b_m x-scale)))
(t_1 (/ (* a b_m) (* y-scale x-scale))))
(if (<= b_m 2e-151) (* (* t_1 t_1) -4.0) (* (* t_0 t_0) -4.0))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b_m / x_45_scale);
double t_1 = (a * b_m) / (y_45_scale * x_45_scale);
double tmp;
if (b_m <= 2e-151) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.0;
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (a / y_45scale) * (b_m / x_45scale)
t_1 = (a * b_m) / (y_45scale * x_45scale)
if (b_m <= 2d-151) then
tmp = (t_1 * t_1) * (-4.0d0)
else
tmp = (t_0 * t_0) * (-4.0d0)
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / y_45_scale) * (b_m / x_45_scale);
double t_1 = (a * b_m) / (y_45_scale * x_45_scale);
double tmp;
if (b_m <= 2e-151) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.0;
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = (a / y_45_scale) * (b_m / x_45_scale) t_1 = (a * b_m) / (y_45_scale * x_45_scale) tmp = 0 if b_m <= 2e-151: tmp = (t_1 * t_1) * -4.0 else: tmp = (t_0 * t_0) * -4.0 return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a / y_45_scale) * Float64(b_m / x_45_scale)) t_1 = Float64(Float64(a * b_m) / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if (b_m <= 2e-151) tmp = Float64(Float64(t_1 * t_1) * -4.0); else tmp = Float64(Float64(t_0 * t_0) * -4.0); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = (a / y_45_scale) * (b_m / x_45_scale); t_1 = (a * b_m) / (y_45_scale * x_45_scale); tmp = 0.0; if (b_m <= 2e-151) tmp = (t_1 * t_1) * -4.0; else tmp = (t_0 * t_0) * -4.0; end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a / y$45$scale), $MachinePrecision] * N[(b$95$m / x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * b$95$m), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b$95$m, 2e-151], N[(N[(t$95$1 * t$95$1), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(t$95$0 * t$95$0), $MachinePrecision] * -4.0), $MachinePrecision]]]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \frac{a}{y-scale} \cdot \frac{b\_m}{x-scale}\\
t_1 := \frac{a \cdot b\_m}{y-scale \cdot x-scale}\\
\mathbf{if}\;b\_m \leq 2 \cdot 10^{-151}:\\
\;\;\;\;\left(t\_1 \cdot t\_1\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot -4\\
\end{array}
\end{array}
if b < 1.9999999999999999e-151Initial program 28.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.2
Applied rewrites57.2%
Applied rewrites77.2%
Applied rewrites94.2%
if 1.9999999999999999e-151 < b Initial program 17.6%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
Applied rewrites72.5%
Taylor expanded in a around 0
Applied rewrites90.8%
Applied rewrites97.6%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ a x-scale) (/ b_m y-scale)))
(t_1 (/ (* a b_m) (* y-scale x-scale))))
(if (<= y-scale 100000000000.0) (* (* t_1 t_1) -4.0) (* (* t_0 t_0) -4.0))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / x_45_scale) * (b_m / y_45_scale);
double t_1 = (a * b_m) / (y_45_scale * x_45_scale);
double tmp;
if (y_45_scale <= 100000000000.0) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.0;
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (a / x_45scale) * (b_m / y_45scale)
t_1 = (a * b_m) / (y_45scale * x_45scale)
if (y_45scale <= 100000000000.0d0) then
tmp = (t_1 * t_1) * (-4.0d0)
else
tmp = (t_0 * t_0) * (-4.0d0)
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a / x_45_scale) * (b_m / y_45_scale);
double t_1 = (a * b_m) / (y_45_scale * x_45_scale);
double tmp;
if (y_45_scale <= 100000000000.0) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.0;
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = (a / x_45_scale) * (b_m / y_45_scale) t_1 = (a * b_m) / (y_45_scale * x_45_scale) tmp = 0 if y_45_scale <= 100000000000.0: tmp = (t_1 * t_1) * -4.0 else: tmp = (t_0 * t_0) * -4.0 return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a / x_45_scale) * Float64(b_m / y_45_scale)) t_1 = Float64(Float64(a * b_m) / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if (y_45_scale <= 100000000000.0) tmp = Float64(Float64(t_1 * t_1) * -4.0); else tmp = Float64(Float64(t_0 * t_0) * -4.0); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = (a / x_45_scale) * (b_m / y_45_scale); t_1 = (a * b_m) / (y_45_scale * x_45_scale); tmp = 0.0; if (y_45_scale <= 100000000000.0) tmp = (t_1 * t_1) * -4.0; else tmp = (t_0 * t_0) * -4.0; end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a / x$45$scale), $MachinePrecision] * N[(b$95$m / y$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * b$95$m), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$45$scale, 100000000000.0], N[(N[(t$95$1 * t$95$1), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(t$95$0 * t$95$0), $MachinePrecision] * -4.0), $MachinePrecision]]]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \frac{a}{x-scale} \cdot \frac{b\_m}{y-scale}\\
t_1 := \frac{a \cdot b\_m}{y-scale \cdot x-scale}\\
\mathbf{if}\;y-scale \leq 100000000000:\\
\;\;\;\;\left(t\_1 \cdot t\_1\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot -4\\
\end{array}
\end{array}
if y-scale < 1e11Initial program 18.0%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
Applied rewrites78.3%
Applied rewrites93.7%
if 1e11 < y-scale Initial program 45.0%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6453.8
Applied rewrites53.8%
Applied rewrites65.7%
Taylor expanded in a around 0
Applied rewrites96.2%
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale y-scale)
:precision binary64
(let* ((t_0 (/ b_m (* y-scale x-scale))))
(if (or (<= a 1.25e-173) (not (<= a 7.5e+99)))
(*
(/ (* (* (/ a x-scale) b_m) (* a b_m)) (* y-scale (* y-scale x-scale)))
-4.0)
(* (* -4.0 (* a a)) (* t_0 t_0)))))b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b_m / (y_45_scale * x_45_scale);
double tmp;
if ((a <= 1.25e-173) || !(a <= 7.5e+99)) {
tmp = ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0;
} else {
tmp = (-4.0 * (a * a)) * (t_0 * t_0);
}
return tmp;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
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 = b_m / (y_45scale * x_45scale)
if ((a <= 1.25d-173) .or. (.not. (a <= 7.5d+99))) then
tmp = ((((a / x_45scale) * b_m) * (a * b_m)) / (y_45scale * (y_45scale * x_45scale))) * (-4.0d0)
else
tmp = ((-4.0d0) * (a * a)) * (t_0 * t_0)
end if
code = tmp
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = b_m / (y_45_scale * x_45_scale);
double tmp;
if ((a <= 1.25e-173) || !(a <= 7.5e+99)) {
tmp = ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0;
} else {
tmp = (-4.0 * (a * a)) * (t_0 * t_0);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = b_m / (y_45_scale * x_45_scale) tmp = 0 if (a <= 1.25e-173) or not (a <= 7.5e+99): tmp = ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0 else: tmp = (-4.0 * (a * a)) * (t_0 * t_0) return tmp
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(b_m / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if ((a <= 1.25e-173) || !(a <= 7.5e+99)) tmp = Float64(Float64(Float64(Float64(Float64(a / x_45_scale) * b_m) * Float64(a * b_m)) / Float64(y_45_scale * Float64(y_45_scale * x_45_scale))) * -4.0); else tmp = Float64(Float64(-4.0 * Float64(a * a)) * Float64(t_0 * t_0)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = b_m / (y_45_scale * x_45_scale); tmp = 0.0; if ((a <= 1.25e-173) || ~((a <= 7.5e+99))) tmp = ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0; else tmp = (-4.0 * (a * a)) * (t_0 * t_0); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b$95$m / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, 1.25e-173], N[Not[LessEqual[a, 7.5e+99]], $MachinePrecision]], N[(N[(N[(N[(N[(a / x$45$scale), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(-4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \frac{b\_m}{y-scale \cdot x-scale}\\
\mathbf{if}\;a \leq 1.25 \cdot 10^{-173} \lor \neg \left(a \leq 7.5 \cdot 10^{+99}\right):\\
\;\;\;\;\frac{\left(\frac{a}{x-scale} \cdot b\_m\right) \cdot \left(a \cdot b\_m\right)}{y-scale \cdot \left(y-scale \cdot x-scale\right)} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot \left(a \cdot a\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if a < 1.2500000000000001e-173 or 7.49999999999999963e99 < a Initial program 19.2%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6453.2
Applied rewrites53.2%
Applied rewrites75.4%
Taylor expanded in a around 0
Applied rewrites92.7%
Applied rewrites73.8%
if 1.2500000000000001e-173 < a < 7.49999999999999963e99Initial program 40.5%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6468.0
Applied rewrites68.0%
Applied rewrites93.5%
Final simplification78.3%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (let* ((t_0 (/ (* a b_m) (* y-scale x-scale)))) (* (* t_0 t_0) -4.0)))
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a * b_m) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.0;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = (a * b_m) / (y_45scale * x_45scale)
code = (t_0 * t_0) * (-4.0d0)
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a * b_m) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.0;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = (a * b_m) / (y_45_scale * x_45_scale) return (t_0 * t_0) * -4.0
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a * b_m) / Float64(y_45_scale * x_45_scale)) return Float64(Float64(t_0 * t_0) * -4.0) end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = (a * b_m) / (y_45_scale * x_45_scale); tmp = (t_0 * t_0) * -4.0; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a * b$95$m), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \frac{a \cdot b\_m}{y-scale \cdot x-scale}\\
\left(t\_0 \cdot t\_0\right) \cdot -4
\end{array}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
Applied rewrites75.4%
Applied rewrites92.8%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (let* ((t_0 (* a (/ b_m (* y-scale x-scale))))) (* (* t_0 t_0) -4.0)))
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = a * (b_m / (y_45_scale * x_45_scale));
return (t_0 * t_0) * -4.0;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = a * (b_m / (y_45scale * x_45scale))
code = (t_0 * t_0) * (-4.0d0)
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
double t_0 = a * (b_m / (y_45_scale * x_45_scale));
return (t_0 * t_0) * -4.0;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): t_0 = a * (b_m / (y_45_scale * x_45_scale)) return (t_0 * t_0) * -4.0
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = Float64(a * Float64(b_m / Float64(y_45_scale * x_45_scale))) return Float64(Float64(t_0 * t_0) * -4.0) end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) t_0 = a * (b_m / (y_45_scale * x_45_scale)); tmp = (t_0 * t_0) * -4.0; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(a * N[(b$95$m / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := a \cdot \frac{b\_m}{y-scale \cdot x-scale}\\
\left(t\_0 \cdot t\_0\right) \cdot -4
\end{array}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
Applied rewrites75.4%
Applied rewrites92.6%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (* (/ (* (* (/ a x-scale) b_m) (* a b_m)) (* y-scale (* y-scale x-scale))) -4.0))
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0;
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = ((((a / x_45scale) * b_m) * (a * b_m)) / (y_45scale * (y_45scale * x_45scale))) * (-4.0d0)
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0;
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): return ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(Float64(Float64(a / x_45_scale) * b_m) * Float64(a * b_m)) / Float64(y_45_scale * Float64(y_45_scale * x_45_scale))) * -4.0) end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = ((((a / x_45_scale) * b_m) * (a * b_m)) / (y_45_scale * (y_45_scale * x_45_scale))) * -4.0; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(a / x$45$scale), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
\frac{\left(\frac{a}{x-scale} \cdot b\_m\right) \cdot \left(a \cdot b\_m\right)}{y-scale \cdot \left(y-scale \cdot x-scale\right)} \cdot -4
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
Applied rewrites75.4%
Taylor expanded in a around 0
Applied rewrites92.8%
Applied rewrites74.2%
b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale y-scale) :precision binary64 (* (* -4.0 (* a a)) (/ (* b_m b_m) (* (* y-scale x-scale) (* y-scale x-scale)))))
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return (-4.0 * (a * a)) * ((b_m * b_m) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)));
}
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale, y_45scale)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = ((-4.0d0) * (a * a)) * ((b_m * b_m) / ((y_45scale * x_45scale) * (y_45scale * x_45scale)))
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale, double y_45_scale) {
return (-4.0 * (a * a)) * ((b_m * b_m) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)));
}
b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale, y_45_scale): return (-4.0 * (a * a)) * ((b_m * b_m) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)))
b_m = abs(b) function code(a, b_m, angle, x_45_scale, y_45_scale) return Float64(Float64(-4.0 * Float64(a * a)) * Float64(Float64(b_m * b_m) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale)))) end
b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale, y_45_scale) tmp = (-4.0 * (a * a)) * ((b_m * b_m) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))); end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale_, y$45$scale_] := N[(N[(-4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(N[(b$95$m * b$95$m), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
\left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b\_m \cdot b\_m}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}
\end{array}
Initial program 24.1%
Taylor expanded in angle around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
Taylor expanded in b around 0
Applied rewrites62.7%
herbie shell --seed 2024307
(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))))