
(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 8 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}
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ b y-scale) (/ a_m x-scale)))
(t_1 (/ (* a_m b) (* y-scale x-scale))))
(if (<= a_m 1e+224) (* (* t_1 t_1) -4.0) (* (* t_0 t_0) -4.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 = (b / y_45_scale) * (a_m / x_45_scale);
double t_1 = (a_m * b) / (y_45_scale * x_45_scale);
double tmp;
if (a_m <= 1e+224) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b / y_45scale) * (a_m / x_45scale)
t_1 = (a_m * b) / (y_45scale * x_45scale)
if (a_m <= 1d+224) then
tmp = (t_1 * t_1) * (-4.0d0)
else
tmp = (t_0 * t_0) * (-4.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 t_0 = (b / y_45_scale) * (a_m / x_45_scale);
double t_1 = (a_m * b) / (y_45_scale * x_45_scale);
double tmp;
if (a_m <= 1e+224) {
tmp = (t_1 * t_1) * -4.0;
} else {
tmp = (t_0 * t_0) * -4.0;
}
return tmp;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): t_0 = (b / y_45_scale) * (a_m / x_45_scale) t_1 = (a_m * b) / (y_45_scale * x_45_scale) tmp = 0 if a_m <= 1e+224: tmp = (t_1 * t_1) * -4.0 else: tmp = (t_0 * t_0) * -4.0 return tmp
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(b / y_45_scale) * Float64(a_m / x_45_scale)) t_1 = Float64(Float64(a_m * b) / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if (a_m <= 1e+224) tmp = Float64(Float64(t_1 * t_1) * -4.0); else tmp = Float64(Float64(t_0 * t_0) * -4.0); end return tmp end
a_m = abs(a); function tmp_2 = code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = (b / y_45_scale) * (a_m / x_45_scale); t_1 = (a_m * b) / (y_45_scale * x_45_scale); tmp = 0.0; if (a_m <= 1e+224) tmp = (t_1 * t_1) * -4.0; else tmp = (t_0 * t_0) * -4.0; end tmp_2 = tmp; 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[(b / y$45$scale), $MachinePrecision] * N[(a$95$m / x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a$95$m * b), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 1e+224], 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}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale} \cdot \frac{a\_m}{x-scale}\\
t_1 := \frac{a\_m \cdot b}{y-scale \cdot x-scale}\\
\mathbf{if}\;a\_m \leq 10^{+224}:\\
\;\;\;\;\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 a < 9.9999999999999997e223Initial program 22.7%
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-*.f6458.6
Applied rewrites58.6%
Applied rewrites78.3%
Applied rewrites94.4%
if 9.9999999999999997e223 < a Initial program 0.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-*.f6450.9
Applied rewrites50.9%
Applied rewrites59.0%
Taylor expanded in a around 0
Applied rewrites99.5%
a_m = (fabs.f64 a)
(FPCore (a_m 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_m 2.0))) t_1) t_2) x-scale)
y-scale)))
(if (<=
(-
(* t_3 t_3)
(*
(*
4.0
(/
(/ (+ (pow (* a_m t_1) 2.0) (pow (* b t_2) 2.0)) x-scale)
x-scale))
(/
(/ (+ (pow (* a_m t_2) 2.0) (pow (* b t_1) 2.0)) y-scale)
y-scale)))
2e-57)
(*
(* (/ (* -4.0 a_m) y-scale) (/ a_m (* (* x-scale x-scale) y-scale)))
(* b b))
(*
(/ (* (* a_m b) (* a_m b)) (* x-scale (* y-scale (* y-scale x-scale))))
-4.0))))\begin{array}{l}
a_m = \left|a\right|
\\
\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\_m}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
\mathbf{if}\;t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a\_m \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a\_m \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale} \leq 2 \cdot 10^{-57}:\\
\;\;\;\;\left(\frac{-4 \cdot a\_m}{y-scale} \cdot \frac{a\_m}{\left(x-scale \cdot x-scale\right) \cdot y-scale}\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a\_m \cdot b\right) \cdot \left(a\_m \cdot b\right)}{x-scale \cdot \left(y-scale \cdot \left(y-scale \cdot x-scale\right)\right)} \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) < 1.99999999999999991e-57Initial program 71.1%
Taylor expanded in b around 0
Applied rewrites71.2%
Taylor expanded in angle around 0
Applied rewrites79.5%
Applied rewrites83.5%
if 1.99999999999999991e-57 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) Initial program 0.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-*.f6450.2
Applied rewrites50.2%
Applied rewrites78.5%
Applied rewrites93.0%
Applied rewrites75.3%
Final simplification77.7%
a_m = (fabs.f64 a)
(FPCore (a_m 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_m 2.0))) t_1) t_2) x-scale)
y-scale)))
(if (<=
(-
(* t_3 t_3)
(*
(*
4.0
(/
(/ (+ (pow (* a_m t_1) 2.0) (pow (* b t_2) 2.0)) x-scale)
x-scale))
(/
(/ (+ (pow (* a_m t_2) 2.0) (pow (* b t_1) 2.0)) y-scale)
y-scale)))
2e-57)
(*
(/ (* -4.0 (* a_m a_m)) (* (* y-scale x-scale) (* y-scale x-scale)))
(* b b))
(*
(/ (* (* a_m b) (* a_m b)) (* x-scale (* y-scale (* y-scale x-scale))))
-4.0))))\begin{array}{l}
a_m = \left|a\right|
\\
\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\_m}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
\mathbf{if}\;t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a\_m \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a\_m \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale} \leq 2 \cdot 10^{-57}:\\
\;\;\;\;\frac{-4 \cdot \left(a\_m \cdot a\_m\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a\_m \cdot b\right) \cdot \left(a\_m \cdot b\right)}{x-scale \cdot \left(y-scale \cdot \left(y-scale \cdot x-scale\right)\right)} \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) < 1.99999999999999991e-57Initial program 71.1%
Taylor expanded in b around 0
Applied rewrites71.2%
Taylor expanded in angle around 0
Applied rewrites79.5%
if 1.99999999999999991e-57 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) Initial program 0.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-*.f6450.2
Applied rewrites50.2%
Applied rewrites78.5%
Applied rewrites93.0%
Applied rewrites75.3%
Final simplification76.5%
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (/ b (* y-scale x-scale))))
(if (or (<= a_m 1.05e-152) (not (<= a_m 3e+153)))
(*
(/ (* (* a_m b) (* a_m b)) (* x-scale (* y-scale (* y-scale x-scale))))
-4.0)
(* (* -4.0 (* a_m a_m)) (* t_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 = b / (y_45_scale * x_45_scale);
double tmp;
if ((a_m <= 1.05e-152) || !(a_m <= 3e+153)) {
tmp = (((a_m * b) * (a_m * b)) / (x_45_scale * (y_45_scale * (y_45_scale * x_45_scale)))) * -4.0;
} else {
tmp = (-4.0 * (a_m * a_m)) * (t_0 * t_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) :: t_0
real(8) :: tmp
t_0 = b / (y_45scale * x_45scale)
if ((a_m <= 1.05d-152) .or. (.not. (a_m <= 3d+153))) then
tmp = (((a_m * b) * (a_m * b)) / (x_45scale * (y_45scale * (y_45scale * x_45scale)))) * (-4.0d0)
else
tmp = ((-4.0d0) * (a_m * a_m)) * (t_0 * t_0)
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 t_0 = b / (y_45_scale * x_45_scale);
double tmp;
if ((a_m <= 1.05e-152) || !(a_m <= 3e+153)) {
tmp = (((a_m * b) * (a_m * b)) / (x_45_scale * (y_45_scale * (y_45_scale * x_45_scale)))) * -4.0;
} else {
tmp = (-4.0 * (a_m * a_m)) * (t_0 * t_0);
}
return tmp;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): t_0 = b / (y_45_scale * x_45_scale) tmp = 0 if (a_m <= 1.05e-152) or not (a_m <= 3e+153): tmp = (((a_m * b) * (a_m * b)) / (x_45_scale * (y_45_scale * (y_45_scale * x_45_scale)))) * -4.0 else: tmp = (-4.0 * (a_m * a_m)) * (t_0 * t_0) return tmp
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if ((a_m <= 1.05e-152) || !(a_m <= 3e+153)) tmp = Float64(Float64(Float64(Float64(a_m * b) * Float64(a_m * b)) / Float64(x_45_scale * Float64(y_45_scale * Float64(y_45_scale * x_45_scale)))) * -4.0); else tmp = Float64(Float64(-4.0 * Float64(a_m * a_m)) * Float64(t_0 * t_0)); end return tmp end
a_m = abs(a); function tmp_2 = code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = b / (y_45_scale * x_45_scale); tmp = 0.0; if ((a_m <= 1.05e-152) || ~((a_m <= 3e+153))) tmp = (((a_m * b) * (a_m * b)) / (x_45_scale * (y_45_scale * (y_45_scale * x_45_scale)))) * -4.0; else tmp = (-4.0 * (a_m * a_m)) * (t_0 * t_0); end tmp_2 = tmp; end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a$95$m, 1.05e-152], N[Not[LessEqual[a$95$m, 3e+153]], $MachinePrecision]], N[(N[(N[(N[(a$95$m * b), $MachinePrecision] * N[(a$95$m * b), $MachinePrecision]), $MachinePrecision] / N[(x$45$scale * N[(y$45$scale * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(-4.0 * N[(a$95$m * a$95$m), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale}\\
\mathbf{if}\;a\_m \leq 1.05 \cdot 10^{-152} \lor \neg \left(a\_m \leq 3 \cdot 10^{+153}\right):\\
\;\;\;\;\frac{\left(a\_m \cdot b\right) \cdot \left(a\_m \cdot b\right)}{x-scale \cdot \left(y-scale \cdot \left(y-scale \cdot x-scale\right)\right)} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot \left(a\_m \cdot a\_m\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if a < 1.04999999999999999e-152 or 3.00000000000000019e153 < a Initial program 22.8%
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.4
Applied rewrites56.4%
Applied rewrites76.9%
Applied rewrites92.3%
Applied rewrites74.1%
if 1.04999999999999999e-152 < a < 3.00000000000000019e153Initial program 16.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-*.f6464.6
Applied rewrites64.6%
Applied rewrites97.8%
Final simplification79.3%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (let* ((t_0 (/ (* a_m b) (* y-scale x-scale)))) (* (* t_0 t_0) -4.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) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.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) / (y_45scale * x_45scale)
code = (t_0 * t_0) * (-4.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) {
double t_0 = (a_m * b) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.0;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): t_0 = (a_m * b) / (y_45_scale * x_45_scale) return (t_0 * t_0) * -4.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(y_45_scale * x_45_scale)) return Float64(Float64(t_0 * t_0) * -4.0) end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) t_0 = (a_m * b) / (y_45_scale * x_45_scale); tmp = (t_0 * t_0) * -4.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[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \frac{a\_m \cdot b}{y-scale \cdot x-scale}\\
\left(t\_0 \cdot t\_0\right) \cdot -4
\end{array}
\end{array}
Initial program 21.4%
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-*.f6458.2
Applied rewrites58.2%
Applied rewrites77.3%
Applied rewrites93.5%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* (* (/ (* a_m b) (* y-scale x-scale)) (* b (/ a_m (* y-scale x-scale)))) -4.0))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
return (((a_m * b) / (y_45_scale * x_45_scale)) * (b * (a_m / (y_45_scale * x_45_scale)))) * -4.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 = (((a_m * b) / (y_45scale * x_45scale)) * (b * (a_m / (y_45scale * x_45scale)))) * (-4.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 (((a_m * b) / (y_45_scale * x_45_scale)) * (b * (a_m / (y_45_scale * x_45_scale)))) * -4.0;
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): return (((a_m * b) / (y_45_scale * x_45_scale)) * (b * (a_m / (y_45_scale * x_45_scale)))) * -4.0
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(Float64(a_m * b) / Float64(y_45_scale * x_45_scale)) * Float64(b * Float64(a_m / Float64(y_45_scale * x_45_scale)))) * -4.0) end
a_m = abs(a); function tmp = code(a_m, b, angle, x_45_scale, y_45_scale) tmp = (((a_m * b) / (y_45_scale * x_45_scale)) * (b * (a_m / (y_45_scale * x_45_scale)))) * -4.0; end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(a$95$m * b), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(b * N[(a$95$m / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\left(\frac{a\_m \cdot b}{y-scale \cdot x-scale} \cdot \left(b \cdot \frac{a\_m}{y-scale \cdot x-scale}\right)\right) \cdot -4
\end{array}
Initial program 21.4%
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-*.f6458.2
Applied rewrites58.2%
Applied rewrites77.3%
Applied rewrites93.5%
Applied rewrites92.2%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* (* -4.0 (* a_m a_m)) (/ (* b b) (* (* y-scale x-scale) (* y-scale x-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 * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_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 * b) / ((y_45scale * x_45scale) * (y_45scale * x_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 * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_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 * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)))
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return Float64(Float64(-4.0 * Float64(a_m * a_m)) * Float64(Float64(b * b) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_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 * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(-4.0 * N[(a$95$m * a$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\left(-4 \cdot \left(a\_m \cdot a\_m\right)\right) \cdot \frac{b \cdot b}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}
\end{array}
Initial program 21.4%
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-*.f6458.2
Applied rewrites58.2%
Taylor expanded in b around 0
Applied rewrites57.8%
a_m = (fabs.f64 a) (FPCore (a_m b angle x-scale y-scale) :precision binary64 (* (/ (* -4.0 (* a_m a_m)) (* (* y-scale x-scale) (* y-scale x-scale))) (* b b)))
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)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * (b * b);
}
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)) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))) * (b * b)
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)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * (b * b);
}
a_m = math.fabs(a) def code(a_m, b, angle, x_45_scale, y_45_scale): return ((-4.0 * (a_m * a_m)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * (b * b)
a_m = abs(a) function code(a_m, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(-4.0 * Float64(a_m * a_m)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * Float64(b * b)) 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)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * (b * b); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(-4.0 * N[(a$95$m * a$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\frac{-4 \cdot \left(a\_m \cdot a\_m\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot \left(b \cdot b\right)
\end{array}
Initial program 21.4%
Taylor expanded in b around 0
Applied rewrites41.8%
Taylor expanded in angle around 0
Applied rewrites57.3%
herbie shell --seed 2024296
(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))))