
(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
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale))
(t_4
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(t_5 (* (* b a) (* b (- a))))
(t_6 (/ (* 4.0 t_5) (pow (* x-scale y-scale) 2.0))))
(/
(-
(sqrt
(*
(* (* 2.0 t_6) t_5)
(+
(+ t_4 t_3)
(sqrt
(+
(pow (- t_4 t_3) 2.0)
(pow
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)
2.0)))))))
t_6)))\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(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\
t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\
t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\
\frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6}
\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
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale))
(t_4
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(t_5 (* (* b a) (* b (- a))))
(t_6 (/ (* 4.0 t_5) (pow (* x-scale y-scale) 2.0))))
(/
(-
(sqrt
(*
(* (* 2.0 t_6) t_5)
(+
(+ t_4 t_3)
(sqrt
(+
(pow (- t_4 t_3) 2.0)
(pow
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)
2.0)))))))
t_6)))\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(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\
t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\
t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\
\frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6}
\end{array}
\end{array}
y-scale_m = (fabs.f64 y-scale)
x-scale_m = (fabs.f64 x-scale)
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale_m y-scale_m)
:precision binary64
(let* ((t_0 (* angle (* 0.005555555555555556 (PI)))))
(if (<= y-scale_m 1.8e+35)
(*
(* 0.25 (* (* x-scale_m (sqrt 2.0)) (sqrt 8.0)))
(hypot (* b_m (sin t_0)) (* a (cos t_0))))
(*
(* 0.25 (* b_m (* x-scale_m (* y-scale_m (sqrt 8.0)))))
(/ (sqrt 2.0) x-scale_m)))))\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := angle \cdot \left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;y-scale\_m \leq 1.8 \cdot 10^{+35}:\\
\;\;\;\;\left(0.25 \cdot \left(\left(x-scale\_m \cdot \sqrt{2}\right) \cdot \sqrt{8}\right)\right) \cdot \mathsf{hypot}\left(b\_m \cdot \sin t\_0, a \cdot \cos t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.25 \cdot \left(b\_m \cdot \left(x-scale\_m \cdot \left(y-scale\_m \cdot \sqrt{8}\right)\right)\right)\right) \cdot \frac{\sqrt{2}}{x-scale\_m}\\
\end{array}
\end{array}
if y-scale < 1.8e35Initial program 2.4%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites20.5%
Taylor expanded in x-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-fma.f64N/A
Applied rewrites20.4%
add-cbrt-cubeN/A
pow1/3N/A
add-sqr-sqrtN/A
associate-*r*N/A
unpow-prod-downN/A
pow1/3N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-cbrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6420.5
Applied rewrites20.5%
Applied rewrites24.5%
if 1.8e35 < y-scale Initial program 4.1%
Taylor expanded in b around inf
Applied rewrites18.0%
Taylor expanded in angle around 0
lower-/.f64N/A
lower-sqrt.f6436.7
Applied rewrites36.7%
y-scale_m = (fabs.f64 y-scale)
x-scale_m = (fabs.f64 x-scale)
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale_m y-scale_m)
:precision binary64
(let* ((t_0 (cos (* (* angle (PI)) 0.011111111111111112))))
(if (<= a 1.35e+40)
(* b_m (* 0.25 (* y-scale_m 4.0)))
(*
x-scale_m
(sqrt
(fma b_m (* b_m (fma t_0 -0.5 0.5)) (* (* a a) (fma 0.5 t_0 0.5))))))))\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \cos \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot 0.011111111111111112\right)\\
\mathbf{if}\;a \leq 1.35 \cdot 10^{+40}:\\
\;\;\;\;b\_m \cdot \left(0.25 \cdot \left(y-scale\_m \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x-scale\_m \cdot \sqrt{\mathsf{fma}\left(b\_m, b\_m \cdot \mathsf{fma}\left(t\_0, -0.5, 0.5\right), \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, t\_0, 0.5\right)\right)}\\
\end{array}
\end{array}
if a < 1.35000000000000005e40Initial program 2.8%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6427.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6427.6
Applied rewrites27.6%
if 1.35000000000000005e40 < a Initial program 2.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites35.5%
Taylor expanded in x-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-fma.f64N/A
Applied rewrites35.5%
Applied rewrites36.0%
Final simplification29.0%
y-scale_m = (fabs.f64 y-scale)
x-scale_m = (fabs.f64 x-scale)
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale_m y-scale_m)
:precision binary64
(let* ((t_0 (* 0.25 (* x-scale_m (sqrt 8.0)))))
(if (<= a 1.35e+40)
(* b_m (* 0.25 (* y-scale_m 4.0)))
(if (<= a 5.8e+133)
(*
t_0
(sqrt
(*
2.0
(fma
3.08641975308642e-5
(* (* angle angle) (* (* b_m b_m) (* (PI) (PI))))
(* a a)))))
(if (<= a 1.35e+244) (* x-scale_m a) (* t_0 (sqrt (* 2.0 (* a a)))))))))\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := 0.25 \cdot \left(x-scale\_m \cdot \sqrt{8}\right)\\
\mathbf{if}\;a \leq 1.35 \cdot 10^{+40}:\\
\;\;\;\;b\_m \cdot \left(0.25 \cdot \left(y-scale\_m \cdot 4\right)\right)\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{+133}:\\
\;\;\;\;t\_0 \cdot \sqrt{2 \cdot \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(angle \cdot angle\right) \cdot \left(\left(b\_m \cdot b\_m\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), a \cdot a\right)}\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+244}:\\
\;\;\;\;x-scale\_m \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{2 \cdot \left(a \cdot a\right)}\\
\end{array}
\end{array}
if a < 1.35000000000000005e40Initial program 2.8%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6427.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6427.6
Applied rewrites27.6%
if 1.35000000000000005e40 < a < 5.8000000000000002e133Initial program 6.2%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites37.0%
Taylor expanded in angle around 0
Applied rewrites37.1%
Taylor expanded in angle around 0
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6437.2
Applied rewrites37.2%
if 5.8000000000000002e133 < a < 1.34999999999999999e244Initial program 0.0%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites21.3%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6439.0
Applied rewrites39.0%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity39.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.3
Applied rewrites39.3%
if 1.34999999999999999e244 < a Initial program 0.0%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites55.9%
Taylor expanded in angle around 0
Applied rewrites55.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6467.1
Applied rewrites67.1%
Final simplification30.4%
y-scale_m = (fabs.f64 y-scale)
x-scale_m = (fabs.f64 x-scale)
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale_m y-scale_m)
:precision binary64
(if (<= b_m 1.65e-52)
(* x-scale_m a)
(*
(/ (sqrt 2.0) x-scale_m)
(* (* x-scale_m b_m) (* y-scale_m (* 0.25 (sqrt 8.0)))))))y-scale_m = fabs(y_45_scale);
x-scale_m = fabs(x_45_scale);
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (b_m <= 1.65e-52) {
tmp = x_45_scale_m * a;
} else {
tmp = (sqrt(2.0) / x_45_scale_m) * ((x_45_scale_m * b_m) * (y_45_scale_m * (0.25 * sqrt(8.0))));
}
return tmp;
}
y-scale_m = abs(y_45scale)
x-scale_m = abs(x_45scale)
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: tmp
if (b_m <= 1.65d-52) then
tmp = x_45scale_m * a
else
tmp = (sqrt(2.0d0) / x_45scale_m) * ((x_45scale_m * b_m) * (y_45scale_m * (0.25d0 * sqrt(8.0d0))))
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
x-scale_m = Math.abs(x_45_scale);
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (b_m <= 1.65e-52) {
tmp = x_45_scale_m * a;
} else {
tmp = (Math.sqrt(2.0) / x_45_scale_m) * ((x_45_scale_m * b_m) * (y_45_scale_m * (0.25 * Math.sqrt(8.0))));
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) x-scale_m = math.fabs(x_45_scale) b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale_m, y_45_scale_m): tmp = 0 if b_m <= 1.65e-52: tmp = x_45_scale_m * a else: tmp = (math.sqrt(2.0) / x_45_scale_m) * ((x_45_scale_m * b_m) * (y_45_scale_m * (0.25 * math.sqrt(8.0)))) return tmp
y-scale_m = abs(y_45_scale) x-scale_m = abs(x_45_scale) b_m = abs(b) function code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0 if (b_m <= 1.65e-52) tmp = Float64(x_45_scale_m * a); else tmp = Float64(Float64(sqrt(2.0) / x_45_scale_m) * Float64(Float64(x_45_scale_m * b_m) * Float64(y_45_scale_m * Float64(0.25 * sqrt(8.0))))); end return tmp end
y-scale_m = abs(y_45_scale); x-scale_m = abs(x_45_scale); b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0; if (b_m <= 1.65e-52) tmp = x_45_scale_m * a; else tmp = (sqrt(2.0) / x_45_scale_m) * ((x_45_scale_m * b_m) * (y_45_scale_m * (0.25 * sqrt(8.0)))); end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] x-scale_m = N[Abs[x$45$scale], $MachinePrecision] b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := If[LessEqual[b$95$m, 1.65e-52], N[(x$45$scale$95$m * a), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] * N[(N[(x$45$scale$95$m * b$95$m), $MachinePrecision] * N[(y$45$scale$95$m * N[(0.25 * N[Sqrt[8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 1.65 \cdot 10^{-52}:\\
\;\;\;\;x-scale\_m \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{x-scale\_m} \cdot \left(\left(x-scale\_m \cdot b\_m\right) \cdot \left(y-scale\_m \cdot \left(0.25 \cdot \sqrt{8}\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.64999999999999998e-52Initial program 3.0%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites20.7%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6421.3
Applied rewrites21.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity21.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6421.5
Applied rewrites21.5%
if 1.64999999999999998e-52 < b Initial program 2.3%
Taylor expanded in b around inf
Applied rewrites16.0%
Applied rewrites16.9%
Taylor expanded in angle around 0
lower-/.f64N/A
lower-sqrt.f6432.1
Applied rewrites32.1%
Final simplification24.4%
y-scale_m = (fabs.f64 y-scale)
x-scale_m = (fabs.f64 x-scale)
b_m = (fabs.f64 b)
(FPCore (a b_m angle x-scale_m y-scale_m)
:precision binary64
(if (<= a 5.8e+40)
(* b_m (* 0.25 (* y-scale_m 4.0)))
(if (<= a 1.35e+244)
(* x-scale_m a)
(* (* 0.25 (* x-scale_m (sqrt 8.0))) (sqrt (* 2.0 (* a a)))))))y-scale_m = fabs(y_45_scale);
x-scale_m = fabs(x_45_scale);
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = b_m * (0.25 * (y_45_scale_m * 4.0));
} else if (a <= 1.35e+244) {
tmp = x_45_scale_m * a;
} else {
tmp = (0.25 * (x_45_scale_m * sqrt(8.0))) * sqrt((2.0 * (a * a)));
}
return tmp;
}
y-scale_m = abs(y_45scale)
x-scale_m = abs(x_45scale)
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: tmp
if (a <= 5.8d+40) then
tmp = b_m * (0.25d0 * (y_45scale_m * 4.0d0))
else if (a <= 1.35d+244) then
tmp = x_45scale_m * a
else
tmp = (0.25d0 * (x_45scale_m * sqrt(8.0d0))) * sqrt((2.0d0 * (a * a)))
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
x-scale_m = Math.abs(x_45_scale);
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = b_m * (0.25 * (y_45_scale_m * 4.0));
} else if (a <= 1.35e+244) {
tmp = x_45_scale_m * a;
} else {
tmp = (0.25 * (x_45_scale_m * Math.sqrt(8.0))) * Math.sqrt((2.0 * (a * a)));
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) x-scale_m = math.fabs(x_45_scale) b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale_m, y_45_scale_m): tmp = 0 if a <= 5.8e+40: tmp = b_m * (0.25 * (y_45_scale_m * 4.0)) elif a <= 1.35e+244: tmp = x_45_scale_m * a else: tmp = (0.25 * (x_45_scale_m * math.sqrt(8.0))) * math.sqrt((2.0 * (a * a))) return tmp
y-scale_m = abs(y_45_scale) x-scale_m = abs(x_45_scale) b_m = abs(b) function code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0 if (a <= 5.8e+40) tmp = Float64(b_m * Float64(0.25 * Float64(y_45_scale_m * 4.0))); elseif (a <= 1.35e+244) tmp = Float64(x_45_scale_m * a); else tmp = Float64(Float64(0.25 * Float64(x_45_scale_m * sqrt(8.0))) * sqrt(Float64(2.0 * Float64(a * a)))); end return tmp end
y-scale_m = abs(y_45_scale); x-scale_m = abs(x_45_scale); b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0; if (a <= 5.8e+40) tmp = b_m * (0.25 * (y_45_scale_m * 4.0)); elseif (a <= 1.35e+244) tmp = x_45_scale_m * a; else tmp = (0.25 * (x_45_scale_m * sqrt(8.0))) * sqrt((2.0 * (a * a))); end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] x-scale_m = N[Abs[x$45$scale], $MachinePrecision] b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := If[LessEqual[a, 5.8e+40], N[(b$95$m * N[(0.25 * N[(y$45$scale$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.35e+244], N[(x$45$scale$95$m * a), $MachinePrecision], N[(N[(0.25 * N[(x$45$scale$95$m * N[Sqrt[8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.8 \cdot 10^{+40}:\\
\;\;\;\;b\_m \cdot \left(0.25 \cdot \left(y-scale\_m \cdot 4\right)\right)\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{+244}:\\
\;\;\;\;x-scale\_m \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(0.25 \cdot \left(x-scale\_m \cdot \sqrt{8}\right)\right) \cdot \sqrt{2 \cdot \left(a \cdot a\right)}\\
\end{array}
\end{array}
if a < 5.80000000000000035e40Initial program 2.8%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6427.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6427.6
Applied rewrites27.6%
if 5.80000000000000035e40 < a < 1.34999999999999999e244Initial program 3.5%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites30.3%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6435.4
Applied rewrites35.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity35.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.7
Applied rewrites35.7%
if 1.34999999999999999e244 < a Initial program 0.0%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites55.9%
Taylor expanded in angle around 0
Applied rewrites55.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6467.1
Applied rewrites67.1%
Final simplification30.1%
y-scale_m = (fabs.f64 y-scale) x-scale_m = (fabs.f64 x-scale) b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale_m y-scale_m) :precision binary64 (if (<= a 5.8e+40) (* b_m (* 0.25 (* y-scale_m 4.0))) (* x-scale_m a)))
y-scale_m = fabs(y_45_scale);
x-scale_m = fabs(x_45_scale);
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = b_m * (0.25 * (y_45_scale_m * 4.0));
} else {
tmp = x_45_scale_m * a;
}
return tmp;
}
y-scale_m = abs(y_45scale)
x-scale_m = abs(x_45scale)
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: tmp
if (a <= 5.8d+40) then
tmp = b_m * (0.25d0 * (y_45scale_m * 4.0d0))
else
tmp = x_45scale_m * a
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
x-scale_m = Math.abs(x_45_scale);
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = b_m * (0.25 * (y_45_scale_m * 4.0));
} else {
tmp = x_45_scale_m * a;
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) x-scale_m = math.fabs(x_45_scale) b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale_m, y_45_scale_m): tmp = 0 if a <= 5.8e+40: tmp = b_m * (0.25 * (y_45_scale_m * 4.0)) else: tmp = x_45_scale_m * a return tmp
y-scale_m = abs(y_45_scale) x-scale_m = abs(x_45_scale) b_m = abs(b) function code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0 if (a <= 5.8e+40) tmp = Float64(b_m * Float64(0.25 * Float64(y_45_scale_m * 4.0))); else tmp = Float64(x_45_scale_m * a); end return tmp end
y-scale_m = abs(y_45_scale); x-scale_m = abs(x_45_scale); b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0; if (a <= 5.8e+40) tmp = b_m * (0.25 * (y_45_scale_m * 4.0)); else tmp = x_45_scale_m * a; end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] x-scale_m = N[Abs[x$45$scale], $MachinePrecision] b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := If[LessEqual[a, 5.8e+40], N[(b$95$m * N[(0.25 * N[(y$45$scale$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$45$scale$95$m * a), $MachinePrecision]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.8 \cdot 10^{+40}:\\
\;\;\;\;b\_m \cdot \left(0.25 \cdot \left(y-scale\_m \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x-scale\_m \cdot a\\
\end{array}
\end{array}
if a < 5.80000000000000035e40Initial program 2.8%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6427.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6427.6
Applied rewrites27.6%
if 5.80000000000000035e40 < a Initial program 2.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites35.5%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.6
Applied rewrites37.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity37.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.8
Applied rewrites37.8%
Final simplification29.3%
y-scale_m = (fabs.f64 y-scale) x-scale_m = (fabs.f64 x-scale) b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale_m y-scale_m) :precision binary64 (if (<= a 5.8e+40) (* y-scale_m b_m) (* x-scale_m a)))
y-scale_m = fabs(y_45_scale);
x-scale_m = fabs(x_45_scale);
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = y_45_scale_m * b_m;
} else {
tmp = x_45_scale_m * a;
}
return tmp;
}
y-scale_m = abs(y_45scale)
x-scale_m = abs(x_45scale)
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: tmp
if (a <= 5.8d+40) then
tmp = y_45scale_m * b_m
else
tmp = x_45scale_m * a
end if
code = tmp
end function
y-scale_m = Math.abs(y_45_scale);
x-scale_m = Math.abs(x_45_scale);
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
double tmp;
if (a <= 5.8e+40) {
tmp = y_45_scale_m * b_m;
} else {
tmp = x_45_scale_m * a;
}
return tmp;
}
y-scale_m = math.fabs(y_45_scale) x-scale_m = math.fabs(x_45_scale) b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale_m, y_45_scale_m): tmp = 0 if a <= 5.8e+40: tmp = y_45_scale_m * b_m else: tmp = x_45_scale_m * a return tmp
y-scale_m = abs(y_45_scale) x-scale_m = abs(x_45_scale) b_m = abs(b) function code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0 if (a <= 5.8e+40) tmp = Float64(y_45_scale_m * b_m); else tmp = Float64(x_45_scale_m * a); end return tmp end
y-scale_m = abs(y_45_scale); x-scale_m = abs(x_45_scale); b_m = abs(b); function tmp_2 = code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0; if (a <= 5.8e+40) tmp = y_45_scale_m * b_m; else tmp = x_45_scale_m * a; end tmp_2 = tmp; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] x-scale_m = N[Abs[x$45$scale], $MachinePrecision] b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := If[LessEqual[a, 5.8e+40], N[(y$45$scale$95$m * b$95$m), $MachinePrecision], N[(x$45$scale$95$m * a), $MachinePrecision]]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.8 \cdot 10^{+40}:\\
\;\;\;\;y-scale\_m \cdot b\_m\\
\mathbf{else}:\\
\;\;\;\;x-scale\_m \cdot a\\
\end{array}
\end{array}
if a < 5.80000000000000035e40Initial program 2.8%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6427.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6427.6
Applied rewrites27.6%
associate-*l*N/A
metadata-evalN/A
*-rgt-identity27.6
Applied rewrites27.6%
if 5.80000000000000035e40 < a Initial program 2.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites35.5%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.6
Applied rewrites37.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity37.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.8
Applied rewrites37.8%
y-scale_m = (fabs.f64 y-scale) x-scale_m = (fabs.f64 x-scale) b_m = (fabs.f64 b) (FPCore (a b_m angle x-scale_m y-scale_m) :precision binary64 (* x-scale_m a))
y-scale_m = fabs(y_45_scale);
x-scale_m = fabs(x_45_scale);
b_m = fabs(b);
double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
return x_45_scale_m * a;
}
y-scale_m = abs(y_45scale)
x-scale_m = abs(x_45scale)
b_m = abs(b)
real(8) function code(a, b_m, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
code = x_45scale_m * a
end function
y-scale_m = Math.abs(y_45_scale);
x-scale_m = Math.abs(x_45_scale);
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle, double x_45_scale_m, double y_45_scale_m) {
return x_45_scale_m * a;
}
y-scale_m = math.fabs(y_45_scale) x-scale_m = math.fabs(x_45_scale) b_m = math.fabs(b) def code(a, b_m, angle, x_45_scale_m, y_45_scale_m): return x_45_scale_m * a
y-scale_m = abs(y_45_scale) x-scale_m = abs(x_45_scale) b_m = abs(b) function code(a, b_m, angle, x_45_scale_m, y_45_scale_m) return Float64(x_45_scale_m * a) end
y-scale_m = abs(y_45_scale); x-scale_m = abs(x_45_scale); b_m = abs(b); function tmp = code(a, b_m, angle, x_45_scale_m, y_45_scale_m) tmp = x_45_scale_m * a; end
y-scale_m = N[Abs[y$45$scale], $MachinePrecision] x-scale_m = N[Abs[x$45$scale], $MachinePrecision] b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := N[(x$45$scale$95$m * a), $MachinePrecision]
\begin{array}{l}
y-scale_m = \left|y-scale\right|
\\
x-scale_m = \left|x-scale\right|
\\
b_m = \left|b\right|
\\
x-scale\_m \cdot a
\end{array}
Initial program 2.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites19.4%
Taylor expanded in angle around 0
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6418.7
Applied rewrites18.7%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identity18.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6418.9
Applied rewrites18.9%
herbie shell --seed 2024216
(FPCore (a b angle x-scale y-scale)
:name "a from scale-rotated-ellipse"
:precision binary64
(/ (- (sqrt (* (* (* 2.0 (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))) (* (* b a) (* b (- a)))) (+ (+ (/ (/ (+ (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)) (sqrt (+ (pow (- (/ (/ (+ (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)) 2.0) (pow (/ (/ (* (* (* 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))))))) (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))))