
(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 9 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}
(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_4 (/ (* a b) (* y-scale x-scale))))
(if (<=
(-
(* 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)))
0.0)
(*
(* (/ (* -4.0 a) x-scale) (/ a y-scale))
(* (/ b x-scale) (/ b y-scale)))
(* (* t_4 t_4) -4.0))))\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_4 := \frac{a \cdot b}{y-scale \cdot x-scale}\\
\mathbf{if}\;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} \leq 0:\\
\;\;\;\;\left(\frac{-4 \cdot a}{x-scale} \cdot \frac{a}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{b}{y-scale}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_4 \cdot t\_4\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))) < 0.0Initial program 81.9%
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-*.f6476.2
Applied rewrites76.2%
Applied rewrites83.3%
Applied rewrites93.8%
Applied rewrites99.4%
if 0.0 < (-.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.3%
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-*.f6445.9
Applied rewrites45.9%
Applied rewrites78.0%
Applied rewrites93.3%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ (/ b x-scale) y-scale) a))
(t_1 (* (/ angle 180.0) (PI)))
(t_2 (sin t_1))
(t_3 (/ (* a b) (* y-scale x-scale)))
(t_4 (cos t_1))
(t_5
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_2) t_4) x-scale)
y-scale)))
(if (<=
(-
(* t_5 t_5)
(*
(*
4.0
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_4) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_4) 2.0) (pow (* b t_2) 2.0)) y-scale) y-scale)))
2e+48)
(* (* t_0 t_0) -4.0)
(* (* t_3 t_3) -4.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{b}{x-scale}}{y-scale} \cdot a\\
t_1 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_2 := \sin t\_1\\
t_3 := \frac{a \cdot b}{y-scale \cdot x-scale}\\
t_4 := \cos t\_1\\
t_5 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_2\right) \cdot t\_4}{x-scale}}{y-scale}\\
\mathbf{if}\;t\_5 \cdot t\_5 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_4\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_4\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{y-scale}}{y-scale} \leq 2 \cdot 10^{+48}:\\
\;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 \cdot t\_3\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))) < 2.00000000000000009e48Initial program 74.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-*.f6473.2
Applied rewrites73.2%
Applied rewrites82.0%
Applied rewrites93.5%
Applied rewrites97.9%
if 2.00000000000000009e48 < (-.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.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-*.f6445.9
Applied rewrites45.9%
Applied rewrites78.5%
Applied rewrites93.5%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(if (or (<= b 2.85e-210) (not (<= b 4.1e+161)))
(/ (* (* b a) (* (* b a) -4.0)) (* (* y-scale x-scale) (* y-scale x-scale)))
(*
(* (/ a (* y-scale x-scale)) (/ (* (* b b) a) (* y-scale x-scale)))
-4.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if ((b <= 2.85e-210) || !(b <= 4.1e+161)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = ((a / (y_45_scale * x_45_scale)) * (((b * b) * a) / (y_45_scale * x_45_scale))) * -4.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 ((b <= 2.85d-210) .or. (.not. (b <= 4.1d+161))) then
tmp = ((b * a) * ((b * a) * (-4.0d0))) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))
else
tmp = ((a / (y_45scale * x_45scale)) * (((b * b) * a) / (y_45scale * x_45scale))) * (-4.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 ((b <= 2.85e-210) || !(b <= 4.1e+161)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = ((a / (y_45_scale * x_45_scale)) * (((b * b) * a) / (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): tmp = 0 if (b <= 2.85e-210) or not (b <= 4.1e+161): tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)) else: tmp = ((a / (y_45_scale * x_45_scale)) * (((b * b) * a) / (y_45_scale * x_45_scale))) * -4.0 return tmp
function code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0 if ((b <= 2.85e-210) || !(b <= 4.1e+161)) tmp = Float64(Float64(Float64(b * a) * Float64(Float64(b * a) * -4.0)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))); else tmp = Float64(Float64(Float64(a / Float64(y_45_scale * x_45_scale)) * Float64(Float64(Float64(b * b) * a) / Float64(y_45_scale * x_45_scale))) * -4.0); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0; if ((b <= 2.85e-210) || ~((b <= 4.1e+161))) tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)); else tmp = ((a / (y_45_scale * x_45_scale)) * (((b * b) * a) / (y_45_scale * x_45_scale))) * -4.0; end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[Or[LessEqual[b, 2.85e-210], N[Not[LessEqual[b, 4.1e+161]], $MachinePrecision]], N[(N[(N[(b * a), $MachinePrecision] * N[(N[(b * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.85 \cdot 10^{-210} \lor \neg \left(b \leq 4.1 \cdot 10^{+161}\right):\\
\;\;\;\;\frac{\left(b \cdot a\right) \cdot \left(\left(b \cdot a\right) \cdot -4\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{a}{y-scale \cdot x-scale} \cdot \frac{\left(b \cdot b\right) \cdot a}{y-scale \cdot x-scale}\right) \cdot -4\\
\end{array}
\end{array}
if b < 2.84999999999999985e-210 or 4.1000000000000001e161 < b Initial program 30.3%
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.0
Applied rewrites58.0%
Applied rewrites81.4%
Taylor expanded in a around 0
Applied rewrites62.8%
Applied rewrites81.5%
if 2.84999999999999985e-210 < b < 4.1000000000000001e161Initial program 32.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 rewrites77.5%
Applied rewrites86.8%
Final simplification83.4%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (/ b (* y-scale x-scale))))
(if (or (<= a 6.2e-96) (not (<= a 3.7e+89)))
(/
(* (* b a) (* (* b a) -4.0))
(* (* y-scale x-scale) (* y-scale x-scale)))
(* (* -4.0 (* a a)) (* t_0 t_0)))))
double code(double a, 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 <= 6.2e-96) || !(a <= 3.7e+89)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = (-4.0 * (a * a)) * (t_0 * t_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) :: t_0
real(8) :: tmp
t_0 = b / (y_45scale * x_45scale)
if ((a <= 6.2d-96) .or. (.not. (a <= 3.7d+89))) then
tmp = ((b * a) * ((b * a) * (-4.0d0))) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))
else
tmp = ((-4.0d0) * (a * a)) * (t_0 * t_0)
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 = b / (y_45_scale * x_45_scale);
double tmp;
if ((a <= 6.2e-96) || !(a <= 3.7e+89)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = (-4.0 * (a * a)) * (t_0 * t_0);
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = b / (y_45_scale * x_45_scale) tmp = 0 if (a <= 6.2e-96) or not (a <= 3.7e+89): tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)) else: tmp = (-4.0 * (a * a)) * (t_0 * t_0) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * x_45_scale)) tmp = 0.0 if ((a <= 6.2e-96) || !(a <= 3.7e+89)) tmp = Float64(Float64(Float64(b * a) * Float64(Float64(b * a) * -4.0)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))); else tmp = Float64(Float64(-4.0 * Float64(a * a)) * Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = b / (y_45_scale * x_45_scale); tmp = 0.0; if ((a <= 6.2e-96) || ~((a <= 3.7e+89))) tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)); else tmp = (-4.0 * (a * a)) * (t_0 * t_0); end tmp_2 = tmp; end
code[a_, 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, 6.2e-96], N[Not[LessEqual[a, 3.7e+89]], $MachinePrecision]], N[(N[(N[(b * a), $MachinePrecision] * N[(N[(b * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale}\\
\mathbf{if}\;a \leq 6.2 \cdot 10^{-96} \lor \neg \left(a \leq 3.7 \cdot 10^{+89}\right):\\
\;\;\;\;\frac{\left(b \cdot a\right) \cdot \left(\left(b \cdot a\right) \cdot -4\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\\
\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 < 6.1999999999999998e-96 or 3.6999999999999998e89 < a Initial program 28.9%
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 rewrites79.3%
Taylor expanded in a around 0
Applied rewrites62.4%
Applied rewrites79.3%
if 6.1999999999999998e-96 < a < 3.6999999999999998e89Initial program 46.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.5
Applied rewrites64.5%
Applied rewrites96.9%
Final simplification81.6%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(if (or (<= b 4.5e-127) (not (<= b 4e+130)))
(/ (* (* b a) (* (* b a) -4.0)) (* (* y-scale x-scale) (* y-scale x-scale)))
(*
(* (/ (* -4.0 a) (* y-scale x-scale)) (/ a (* y-scale x-scale)))
(* b b))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if ((b <= 4.5e-127) || !(b <= 4e+130)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = (((-4.0 * a) / (y_45_scale * x_45_scale)) * (a / (y_45_scale * x_45_scale))) * (b * b);
}
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 ((b <= 4.5d-127) .or. (.not. (b <= 4d+130))) then
tmp = ((b * a) * ((b * a) * (-4.0d0))) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))
else
tmp = ((((-4.0d0) * a) / (y_45scale * x_45scale)) * (a / (y_45scale * x_45scale))) * (b * b)
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 ((b <= 4.5e-127) || !(b <= 4e+130)) {
tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
} else {
tmp = (((-4.0 * a) / (y_45_scale * x_45_scale)) * (a / (y_45_scale * x_45_scale))) * (b * b);
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): tmp = 0 if (b <= 4.5e-127) or not (b <= 4e+130): tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)) else: tmp = (((-4.0 * a) / (y_45_scale * x_45_scale)) * (a / (y_45_scale * x_45_scale))) * (b * b) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0 if ((b <= 4.5e-127) || !(b <= 4e+130)) tmp = Float64(Float64(Float64(b * a) * Float64(Float64(b * a) * -4.0)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))); else tmp = Float64(Float64(Float64(Float64(-4.0 * a) / Float64(y_45_scale * x_45_scale)) * Float64(a / Float64(y_45_scale * x_45_scale))) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) tmp = 0.0; if ((b <= 4.5e-127) || ~((b <= 4e+130))) tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)); else tmp = (((-4.0 * a) / (y_45_scale * x_45_scale)) * (a / (y_45_scale * x_45_scale))) * (b * b); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[Or[LessEqual[b, 4.5e-127], N[Not[LessEqual[b, 4e+130]], $MachinePrecision]], N[(N[(N[(b * a), $MachinePrecision] * N[(N[(b * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-4.0 * a), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-127} \lor \neg \left(b \leq 4 \cdot 10^{+130}\right):\\
\;\;\;\;\frac{\left(b \cdot a\right) \cdot \left(\left(b \cdot a\right) \cdot -4\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-4 \cdot a}{y-scale \cdot x-scale} \cdot \frac{a}{y-scale \cdot x-scale}\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 4.4999999999999999e-127 or 4.0000000000000002e130 < b Initial program 30.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-*.f6457.2
Applied rewrites57.2%
Applied rewrites81.7%
Taylor expanded in a around 0
Applied rewrites63.3%
Applied rewrites81.7%
if 4.4999999999999999e-127 < b < 4.0000000000000002e130Initial program 32.6%
Taylor expanded in b around 0
Applied rewrites52.8%
Taylor expanded in angle around 0
Applied rewrites61.0%
Applied rewrites90.4%
Final simplification84.0%
(FPCore (a b angle x-scale y-scale) :precision binary64 (let* ((t_0 (/ (* a b) (* y-scale x-scale)))) (* (* t_0 t_0) -4.0)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a * b) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.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 * b) / (y_45scale * x_45scale)
code = (t_0 * t_0) * (-4.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (a * b) / (y_45_scale * x_45_scale);
return (t_0 * t_0) * -4.0;
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (a * b) / (y_45_scale * x_45_scale) return (t_0 * t_0) * -4.0
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(a * b) / Float64(y_45_scale * x_45_scale)) return Float64(Float64(t_0 * t_0) * -4.0) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (a * b) / (y_45_scale * x_45_scale); tmp = (t_0 * t_0) * -4.0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a * 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}
\\
\begin{array}{l}
t_0 := \frac{a \cdot b}{y-scale \cdot x-scale}\\
\left(t\_0 \cdot t\_0\right) \cdot -4
\end{array}
\end{array}
Initial program 31.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-*.f6457.4
Applied rewrites57.4%
Applied rewrites80.0%
Applied rewrites93.5%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* (* (/ (* a b) (* y-scale x-scale)) (* b (/ a (* x-scale y-scale)))) -4.0))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (((a * b) / (y_45_scale * x_45_scale)) * (b * (a / (x_45_scale * y_45_scale)))) * -4.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 = (((a * b) / (y_45scale * x_45scale)) * (b * (a / (x_45scale * y_45scale)))) * (-4.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (((a * b) / (y_45_scale * x_45_scale)) * (b * (a / (x_45_scale * y_45_scale)))) * -4.0;
}
def code(a, b, angle, x_45_scale, y_45_scale): return (((a * b) / (y_45_scale * x_45_scale)) * (b * (a / (x_45_scale * y_45_scale)))) * -4.0
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(Float64(a * b) / Float64(y_45_scale * x_45_scale)) * Float64(b * Float64(a / Float64(x_45_scale * y_45_scale)))) * -4.0) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = (((a * b) / (y_45_scale * x_45_scale)) * (b * (a / (x_45_scale * y_45_scale)))) * -4.0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(a * b), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(b * N[(a / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{a \cdot b}{y-scale \cdot x-scale} \cdot \left(b \cdot \frac{a}{x-scale \cdot y-scale}\right)\right) \cdot -4
\end{array}
Initial program 31.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-*.f6457.4
Applied rewrites57.4%
Applied rewrites80.0%
Applied rewrites93.5%
Applied rewrites91.8%
(FPCore (a b angle x-scale y-scale) :precision binary64 (/ (* (* b a) (* (* b a) -4.0)) (* (* y-scale x-scale) (* y-scale x-scale))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * 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 = ((b * a) * ((b * a) * (-4.0d0))) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): return ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(b * a) * Float64(Float64(b * a) * -4.0)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = ((b * a) * ((b * a) * -4.0)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(b * a), $MachinePrecision] * N[(N[(b * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(b \cdot a\right) \cdot \left(\left(b \cdot a\right) \cdot -4\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}
\end{array}
Initial program 31.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-*.f6457.4
Applied rewrites57.4%
Applied rewrites80.0%
Taylor expanded in a around 0
Applied rewrites65.3%
Applied rewrites80.0%
(FPCore (a b angle x-scale y-scale) :precision binary64 (/ (* (* -4.0 (* a a)) (* b b)) (* (* y-scale x-scale) (* y-scale x-scale))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((-4.0 * (a * a)) * (b * b)) / ((y_45_scale * x_45_scale) * (y_45_scale * 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)) * (b * b)) / ((y_45scale * x_45scale) * (y_45scale * 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)) * (b * b)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): return ((-4.0 * (a * a)) * (b * b)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(-4.0 * Float64(a * a)) * Float64(b * b)) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = ((-4.0 * (a * a)) * (b * b)) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(-4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-4 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}
\end{array}
Initial program 31.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-*.f6457.4
Applied rewrites57.4%
Applied rewrites80.0%
Taylor expanded in a around 0
Applied rewrites65.3%
herbie shell --seed 2024326
(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))))