
(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 (cbrt (PI))))
(if (<= y-scale_m 1.95e+98)
(*
(* (* 0.25 x-scale_m) 4.0)
(hypot
(* (sin (* (PI) (* 0.005555555555555556 angle))) b_m)
(* (cos (* (* (pow t_0 2.0) (* 0.005555555555555556 angle)) t_0)) a)))
(* b_m y-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 := \sqrt[3]{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;y-scale\_m \leq 1.95 \cdot 10^{+98}:\\
\;\;\;\;\left(\left(0.25 \cdot x-scale\_m\right) \cdot 4\right) \cdot \mathsf{hypot}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot b\_m, \cos \left(\left({t\_0}^{2} \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot t\_0\right) \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\end{array}
\end{array}
if y-scale < 1.95e98Initial program 3.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites22.4%
Applied rewrites27.7%
Applied rewrites27.8%
Applied rewrites27.9%
if 1.95e98 < y-scale Initial program 4.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.f6424.6
Applied rewrites24.6%
Applied rewrites24.7%
Taylor expanded in b around 0
Applied rewrites24.7%
Final simplification27.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 (<= y-scale_m 1.95e+98)
(*
(hypot
(* (sin (* (PI) (* 0.005555555555555556 angle))) b_m)
(* (cos (* (* (PI) 0.005555555555555556) angle)) a))
(* (* 0.25 x-scale_m) 4.0))
(* b_m y-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}
\mathbf{if}\;y-scale\_m \leq 1.95 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{hypot}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot b\_m, \cos \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right) \cdot a\right) \cdot \left(\left(0.25 \cdot x-scale\_m\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\end{array}
\end{array}
if y-scale < 1.95e98Initial program 3.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites22.4%
Applied rewrites27.7%
Applied rewrites27.8%
Applied rewrites27.9%
if 1.95e98 < y-scale Initial program 4.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.f6424.6
Applied rewrites24.6%
Applied rewrites24.7%
Taylor expanded in b around 0
Applied rewrites24.7%
Final simplification27.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
(let* ((t_0 (* (PI) (* 0.005555555555555556 angle))))
(if (<= y-scale_m 1.95e+98)
(* (hypot (* (sin t_0) b_m) (* (cos t_0) a)) x-scale_m)
(* b_m y-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 := \mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\\
\mathbf{if}\;y-scale\_m \leq 1.95 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{hypot}\left(\sin t\_0 \cdot b\_m, \cos t\_0 \cdot a\right) \cdot x-scale\_m\\
\mathbf{else}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\end{array}
\end{array}
if y-scale < 1.95e98Initial program 3.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites22.4%
Applied rewrites27.7%
Applied rewrites27.8%
Applied rewrites27.8%
if 1.95e98 < y-scale Initial program 4.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.f6424.6
Applied rewrites24.6%
Applied rewrites24.7%
Taylor expanded in b around 0
Applied rewrites24.7%
Final simplification27.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 (<= y-scale_m 1.95e+98)
(*
(hypot (* (sin (* (PI) (* 0.005555555555555556 angle))) b_m) (* 1.0 a))
(* (* 0.25 x-scale_m) 4.0))
(* b_m y-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}
\mathbf{if}\;y-scale\_m \leq 1.95 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{hypot}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot b\_m, 1 \cdot a\right) \cdot \left(\left(0.25 \cdot x-scale\_m\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\end{array}
\end{array}
if y-scale < 1.95e98Initial program 3.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites22.4%
Applied rewrites27.7%
Applied rewrites27.8%
Taylor expanded in angle around 0
Applied rewrites27.5%
if 1.95e98 < y-scale Initial program 4.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.f6424.6
Applied rewrites24.6%
Applied rewrites24.7%
Taylor expanded in b around 0
Applied rewrites24.7%
Final simplification27.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 (* (PI) (PI))))
(if (<= a 3.15e-96)
(* b_m y-scale_m)
(if (<= a 8.5e+74)
(*
(sqrt
(*
(fma
(* angle angle)
(fma
(* (* a a) -3.08641975308642e-5)
t_0
(* (* (* b_m b_m) 3.08641975308642e-5) t_0))
(* a a))
2.0))
(* (* (sqrt 8.0) x-scale_m) 0.25))
(*
(*
(fma
(fma
(* 3.969161205100849e-11 (* angle angle))
(pow (PI) 4.0)
(* -1.54320987654321e-5 t_0))
(* angle angle)
1.0)
(* (* 0.25 a) x-scale_m))
4.0)))))\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 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;a \leq 3.15 \cdot 10^{-96}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\mathbf{elif}\;a \leq 8.5 \cdot 10^{+74}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(angle \cdot angle, \mathsf{fma}\left(\left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_0, \left(\left(b\_m \cdot b\_m\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot t\_0\right), a \cdot a\right) \cdot 2} \cdot \left(\left(\sqrt{8} \cdot x-scale\_m\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(3.969161205100849 \cdot 10^{-11} \cdot \left(angle \cdot angle\right), {\mathsf{PI}\left(\right)}^{4}, -1.54320987654321 \cdot 10^{-5} \cdot t\_0\right), angle \cdot angle, 1\right) \cdot \left(\left(0.25 \cdot a\right) \cdot x-scale\_m\right)\right) \cdot 4\\
\end{array}
\end{array}
if a < 3.1499999999999998e-96Initial program 3.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.f6417.8
Applied rewrites17.8%
Applied rewrites17.9%
Taylor expanded in b around 0
Applied rewrites17.9%
if 3.1499999999999998e-96 < a < 8.50000000000000028e74Initial program 0.9%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites29.1%
Taylor expanded in angle around 0
Applied rewrites26.8%
if 8.50000000000000028e74 < a Initial program 6.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites28.9%
Taylor expanded in b around 0
Applied rewrites35.2%
Applied rewrites35.3%
Taylor expanded in angle around 0
Applied rewrites39.3%
Final simplification22.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
(let* ((t_0 (* (PI) (PI))))
(if (<= a 3.15e-96)
(* b_m y-scale_m)
(if (<= a 7e-16)
(*
(sqrt
(*
(fma
(* angle angle)
(fma
(* (* a a) -3.08641975308642e-5)
t_0
(* (* (* b_m b_m) 3.08641975308642e-5) t_0))
(* a a))
2.0))
(* (* (sqrt 8.0) x-scale_m) 0.25))
(* x-scale_m 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 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;a \leq 3.15 \cdot 10^{-96}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\mathbf{elif}\;a \leq 7 \cdot 10^{-16}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(angle \cdot angle, \mathsf{fma}\left(\left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}, t\_0, \left(\left(b\_m \cdot b\_m\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot t\_0\right), a \cdot a\right) \cdot 2} \cdot \left(\left(\sqrt{8} \cdot x-scale\_m\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;x-scale\_m \cdot a\\
\end{array}
\end{array}
if a < 3.1499999999999998e-96Initial program 3.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.f6417.8
Applied rewrites17.8%
Applied rewrites17.9%
Taylor expanded in b around 0
Applied rewrites17.9%
if 3.1499999999999998e-96 < a < 7.00000000000000035e-16Initial program 1.0%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites37.3%
Taylor expanded in angle around 0
Applied rewrites34.7%
if 7.00000000000000035e-16 < a Initial program 5.4%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
Applied rewrites26.4%
Taylor expanded in b around 0
Applied rewrites31.3%
Applied rewrites31.4%
Taylor expanded in angle around 0
Applied rewrites36.3%
Final simplification23.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 (<= b_m 2.6e+72) (* x-scale_m a) (* b_m y-scale_m)))
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 <= 2.6e+72) {
tmp = x_45_scale_m * a;
} else {
tmp = b_m * y_45_scale_m;
}
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 <= 2.6d+72) then
tmp = x_45scale_m * a
else
tmp = b_m * y_45scale_m
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 <= 2.6e+72) {
tmp = x_45_scale_m * a;
} else {
tmp = b_m * y_45_scale_m;
}
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 <= 2.6e+72: tmp = x_45_scale_m * a else: tmp = b_m * y_45_scale_m 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 <= 2.6e+72) tmp = Float64(x_45_scale_m * a); else tmp = Float64(b_m * y_45_scale_m); 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 <= 2.6e+72) tmp = x_45_scale_m * a; else tmp = b_m * y_45_scale_m; 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, 2.6e+72], N[(x$45$scale$95$m * a), $MachinePrecision], N[(b$95$m * y$45$scale$95$m), $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 2.6 \cdot 10^{+72}:\\
\;\;\;\;x-scale\_m \cdot a\\
\mathbf{else}:\\
\;\;\;\;b\_m \cdot y-scale\_m\\
\end{array}
\end{array}
if b < 2.59999999999999981e72Initial program 3.8%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/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 b around 0
Applied rewrites24.7%
Applied rewrites24.9%
Taylor expanded in angle around 0
Applied rewrites26.3%
if 2.59999999999999981e72 < b Initial program 4.7%
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.3
Applied rewrites27.3%
Applied rewrites27.5%
Taylor expanded in b around 0
Applied rewrites27.5%
Final simplification26.5%
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 3.9%
Taylor expanded in y-scale around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/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 b around 0
Applied rewrites21.6%
Applied rewrites21.8%
Taylor expanded in angle around 0
Applied rewrites22.9%
Final simplification22.9%
herbie shell --seed 2024253
(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))))