
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0
\end{array}
\end{array}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (/ angle 180.0))) (t_1 (- (pow b 2.0) (pow a 2.0))))
(if (<= (/ angle 180.0) 5e+18)
(* (* (* 2.0 t_1) (sin t_0)) (cos t_0))
t_1)))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_1 := {b}^{2} - {a}^{2}\\
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\left(\left(2 \cdot t\_1\right) \cdot \sin t\_0\right) \cdot \cos t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5e18Initial program 61.9%
if 5e18 < (/.f64 angle #s(literal 180 binary64)) Initial program 27.8%
Taylor expanded in a around 0
Applied rewrites32.7%
Taylor expanded in a around 0
Applied rewrites39.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (- (pow b 2.0) (pow a 2.0))) (t_1 (sin (* (PI) (/ angle 180.0))))) (if (<= t_0 2e-221) (* t_0 t_1) (* (* 2.0 (pow b 2.0)) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {b}^{2} - {a}^{2}\\
t_1 := \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-221}:\\
\;\;\;\;t\_0 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot {b}^{2}\right) \cdot t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) < 2.00000000000000003e-221Initial program 60.8%
Taylor expanded in a around 0
Applied rewrites60.2%
Taylor expanded in a around 0
Applied rewrites42.9%
if 2.00000000000000003e-221 < (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) Initial program 45.6%
Taylor expanded in a around 0
Applied rewrites43.5%
Taylor expanded in a around 0
Applied rewrites48.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (- (pow b 2.0) (pow a 2.0))))
(if (<= t_0 -5e+73)
t_0
(* (* 2.0 (pow b 2.0)) (sin (* (PI) (/ angle 180.0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {b}^{2} - {a}^{2}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot {b}^{2}\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) < -4.99999999999999976e73Initial program 50.3%
Taylor expanded in a around 0
Applied rewrites50.0%
Taylor expanded in a around 0
Applied rewrites23.9%
if -4.99999999999999976e73 < (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) Initial program 55.3%
Taylor expanded in a around 0
Applied rewrites53.4%
Taylor expanded in a around 0
Applied rewrites50.5%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (- (pow b 2.0) (pow a 2.0)))) (if (<= t_0 -5e+73) t_0 (* (pow b 2.0) (sin (* (PI) (/ angle 180.0)))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {b}^{2} - {a}^{2}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) < -4.99999999999999976e73Initial program 50.3%
Taylor expanded in a around 0
Applied rewrites50.0%
Taylor expanded in a around 0
Applied rewrites23.9%
if -4.99999999999999976e73 < (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) Initial program 55.3%
Taylor expanded in a around 0
Applied rewrites53.4%
Taylor expanded in a around 0
Applied rewrites50.5%
Taylor expanded in b around 0
Applied rewrites53.5%
Taylor expanded in a around 0
Applied rewrites40.2%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (- (pow b 2.0) (pow a 2.0)))) (if (<= t_0 -5e+73) t_0 (pow b 2.0))))
double code(double a, double b, double angle) {
double t_0 = pow(b, 2.0) - pow(a, 2.0);
double tmp;
if (t_0 <= -5e+73) {
tmp = t_0;
} else {
tmp = pow(b, 2.0);
}
return tmp;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8) :: t_0
real(8) :: tmp
t_0 = (b ** 2.0d0) - (a ** 2.0d0)
if (t_0 <= (-5d+73)) then
tmp = t_0
else
tmp = b ** 2.0d0
end if
code = tmp
end function
public static double code(double a, double b, double angle) {
double t_0 = Math.pow(b, 2.0) - Math.pow(a, 2.0);
double tmp;
if (t_0 <= -5e+73) {
tmp = t_0;
} else {
tmp = Math.pow(b, 2.0);
}
return tmp;
}
def code(a, b, angle): t_0 = math.pow(b, 2.0) - math.pow(a, 2.0) tmp = 0 if t_0 <= -5e+73: tmp = t_0 else: tmp = math.pow(b, 2.0) return tmp
function code(a, b, angle) t_0 = Float64((b ^ 2.0) - (a ^ 2.0)) tmp = 0.0 if (t_0 <= -5e+73) tmp = t_0; else tmp = b ^ 2.0; end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (b ^ 2.0) - (a ^ 2.0); tmp = 0.0; if (t_0 <= -5e+73) tmp = t_0; else tmp = b ^ 2.0; end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+73], t$95$0, N[Power[b, 2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {b}^{2} - {a}^{2}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{b}^{2}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) < -4.99999999999999976e73Initial program 50.3%
Taylor expanded in a around 0
Applied rewrites50.0%
Taylor expanded in a around 0
Applied rewrites23.9%
if -4.99999999999999976e73 < (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64))) Initial program 55.3%
Taylor expanded in a around 0
Applied rewrites53.4%
Taylor expanded in a around 0
Applied rewrites38.0%
Taylor expanded in a around inf
Applied rewrites34.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (PI) (/ angle 180.0))) (t_1 (sin t_0)))
(if (<= b 1.3e+154)
(* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1)
(* (* (pow b 2.0) (cos t_0)) t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
t_1 := \sin t\_0\\
\mathbf{if}\;b \leq 1.3 \cdot 10^{+154}:\\
\;\;\;\;\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{2} \cdot \cos t\_0\right) \cdot t\_1\\
\end{array}
\end{array}
if b < 1.29999999999999994e154Initial program 56.7%
Taylor expanded in a around 0
Applied rewrites56.5%
if 1.29999999999999994e154 < b Initial program 34.7%
Taylor expanded in a around 0
Applied rewrites26.3%
Taylor expanded in a around 0
Applied rewrites40.2%
Taylor expanded in b around 0
Applied rewrites26.3%
Taylor expanded in a around inf
Applied rewrites48.6%
(FPCore (a b angle) :precision binary64 (if (<= b 1.2e+154) (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (PI) (/ angle 180.0)))) (* 2.0 (pow b 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{+154}:\\
\;\;\;\;\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {b}^{2}\\
\end{array}
\end{array}
if b < 1.20000000000000007e154Initial program 56.7%
Taylor expanded in a around 0
Applied rewrites56.5%
if 1.20000000000000007e154 < b Initial program 34.7%
Taylor expanded in a around 0
Applied rewrites26.3%
Taylor expanded in a around 0
Applied rewrites34.7%
Taylor expanded in a around inf
Applied rewrites47.8%
(FPCore (a b angle) :precision binary64 (pow b 2.0))
double code(double a, double b, double angle) {
return pow(b, 2.0);
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b ** 2.0d0
end function
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0)
function code(a, b, angle) return b ^ 2.0 end
function tmp = code(a, b, angle) tmp = b ^ 2.0; end
code[a_, b_, angle_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
\\
{b}^{2}
\end{array}
Initial program 53.6%
Taylor expanded in a around 0
Applied rewrites52.3%
Taylor expanded in a around 0
Applied rewrites36.5%
Taylor expanded in a around inf
Applied rewrites24.0%
(FPCore (a b angle) :precision binary64 (* (PI) (/ angle 180.0)))
\begin{array}{l}
\\
\mathsf{PI}\left(\right) \cdot \frac{angle}{180}
\end{array}
Initial program 53.6%
Taylor expanded in a around 0
Applied rewrites52.3%
Taylor expanded in b around inf
Applied rewrites2.9%
herbie shell --seed 2024321
(FPCore (a b angle)
:name "ab-angle->ABCF B"
:precision binary64
:pre (TRUE)
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (PI) (/ angle 180.0)))) (cos (* (PI) (/ angle 180.0)))))