
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (PI) (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (fma (* (pow (cos (* (/ angle 180.0) (cbrt (pow (PI) 3.0)))) 2.0) a) a (pow (* (sin (* (* 0.005555555555555556 (PI)) angle)) b) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left({\cos \left(\frac{angle}{180} \cdot \sqrt[3]{{\mathsf{PI}\left(\right)}^{3}}\right)}^{2} \cdot a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right)
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
Applied rewrites80.7%
lift-PI.f64N/A
add-cbrt-cubeN/A
lower-cbrt.f64N/A
rem-cube-cbrtN/A
add-cbrt-cubeN/A
lift-PI.f64N/A
lower-pow.f6480.7
Applied rewrites80.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (sin (* (* 0.005555555555555556 (PI)) angle)) b))) (fma t_0 t_0 (pow (* (cos (* (/ angle 180.0) (PI))) a) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\\
\mathsf{fma}\left(t\_0, t\_0, {\left(\cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right) \cdot a\right)}^{2}\right)
\end{array}
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f6480.7
Applied rewrites80.7%
(FPCore (a b angle) :precision binary64 (fma (* (pow (cos (fma (PI) (/ angle 180.0) (PI))) 2.0) a) a (pow (* (sin (* (* 0.005555555555555556 (PI)) angle)) b) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left({\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{angle}{180}, \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right)
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
Applied rewrites80.7%
lift-pow.f64N/A
unpow2N/A
sqr-neg-revN/A
pow2N/A
lower-pow.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
cos-+PI-revN/A
lower-cos.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lower-fma.f6480.7
Applied rewrites80.7%
(FPCore (a b angle) :precision binary64 (fma (* (+ 0.5 (* 0.5 (cos (* 2.0 (* (PI) (/ angle 180.0)))))) a) a (pow (* (sin (* (* 0.005555555555555556 (PI)) angle)) b) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)\right) \cdot a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right)
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
Applied rewrites80.7%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-cos-aN/A
metadata-evalN/A
lower-+.f64N/A
metadata-evalN/A
metadata-evalN/A
cos-2N/A
cos-sumN/A
lower-*.f64N/A
Applied rewrites80.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (sin (* (* 0.005555555555555556 (PI)) angle)) b))) (fma t_0 t_0 (pow (* 1.0 a) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\\
\mathsf{fma}\left(t\_0, t\_0, {\left(1 \cdot a\right)}^{2}\right)
\end{array}
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f6480.7
Applied rewrites80.7%
Taylor expanded in angle around 0
Applied rewrites80.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 6.9e-180)
(* (pow (sin (* (* (PI) 0.005555555555555556) angle)) 2.0) (* b b))
(if (<= a 1.2e+38)
(fma
(* (* (* angle angle) b) b)
(*
-3.08641975308642e-5
(- (* (/ (* (* a a) (PI)) b) (/ (PI) b)) (* (PI) (PI))))
(* a a))
(* (pow (cos (* -0.005555555555555556 (* (PI) angle))) 2.0) (* a a)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.9 \cdot 10^{-180}:\\
\;\;\;\;{\sin \left(\left(\mathsf{PI}\left(\right) \cdot 0.005555555555555556\right) \cdot angle\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(\frac{\left(a \cdot a\right) \cdot \mathsf{PI}\left(\right)}{b} \cdot \frac{\mathsf{PI}\left(\right)}{b} - \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 6.9000000000000003e-180Initial program 81.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6438.8
Applied rewrites38.8%
if 6.9000000000000003e-180 < a < 1.20000000000000009e38Initial program 73.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites47.7%
Taylor expanded in angle around 0
Applied rewrites50.6%
if 1.20000000000000009e38 < a Initial program 84.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6484.6
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification49.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 6.9e-180)
(* (pow (sin (* (* angle (PI)) 0.005555555555555556)) 2.0) (* b b))
(if (<= a 1.2e+38)
(fma
(* (* (* angle angle) b) b)
(*
-3.08641975308642e-5
(- (* (/ (* (* a a) (PI)) b) (/ (PI) b)) (* (PI) (PI))))
(* a a))
(* (pow (cos (* -0.005555555555555556 (* (PI) angle))) 2.0) (* a a)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.9 \cdot 10^{-180}:\\
\;\;\;\;{\sin \left(\left(angle \cdot \mathsf{PI}\left(\right)\right) \cdot 0.005555555555555556\right)}^{2} \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(\frac{\left(a \cdot a\right) \cdot \mathsf{PI}\left(\right)}{b} \cdot \frac{\mathsf{PI}\left(\right)}{b} - \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 6.9000000000000003e-180Initial program 81.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.2%
Taylor expanded in angle around 0
Applied rewrites36.3%
Taylor expanded in a around 0
Applied rewrites38.6%
if 6.9000000000000003e-180 < a < 1.20000000000000009e38Initial program 73.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites47.7%
Taylor expanded in angle around 0
Applied rewrites50.6%
if 1.20000000000000009e38 < a Initial program 84.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6484.6
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification49.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.2e+38)
(fma
(* (* (* angle angle) b) b)
(*
-3.08641975308642e-5
(- (* (/ (* (* a a) (PI)) b) (/ (PI) b)) (* (PI) (PI))))
(* a a))
(* (pow (cos (* -0.005555555555555556 (* (PI) angle))) 2.0) (* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(\frac{\left(a \cdot a\right) \cdot \mathsf{PI}\left(\right)}{b} \cdot \frac{\mathsf{PI}\left(\right)}{b} - \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 1.20000000000000009e38Initial program 79.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.5%
Taylor expanded in angle around 0
Applied rewrites46.1%
if 1.20000000000000009e38 < a Initial program 84.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6484.6
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification53.1%
(FPCore (a b angle) :precision binary64 (fma (* 1.0 a) a (pow (* (sin (* (* 0.005555555555555556 (PI)) angle)) b) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(1 \cdot a, a, {\left(\sin \left(\left(0.005555555555555556 \cdot \mathsf{PI}\left(\right)\right) \cdot angle\right) \cdot b\right)}^{2}\right)
\end{array}
Initial program 80.6%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
Applied rewrites80.7%
Taylor expanded in angle around 0
Applied rewrites80.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.2e+38)
(fma
(* (* (* angle angle) b) b)
(*
-3.08641975308642e-5
(- (* (/ (* (* a a) (PI)) b) (/ (PI) b)) (* (PI) (PI))))
(* a a))
(*
(fma (sin (fma (* (PI) angle) 0.011111111111111112 (* 0.5 (PI)))) 0.5 0.5)
(* a a))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(\frac{\left(a \cdot a\right) \cdot \mathsf{PI}\left(\right)}{b} \cdot \frac{\mathsf{PI}\left(\right)}{b} - \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot angle, 0.011111111111111112, 0.5 \cdot \mathsf{PI}\left(\right)\right)\right), 0.5, 0.5\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 1.20000000000000009e38Initial program 79.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.5%
Taylor expanded in angle around 0
Applied rewrites46.1%
if 1.20000000000000009e38 < a Initial program 84.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.7%
Applied rewrites50.9%
Applied rewrites55.6%
Taylor expanded in a around inf
Applied rewrites79.6%
Final simplification53.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.2e+38)
(fma
(* (* (* angle angle) b) b)
(*
-3.08641975308642e-5
(- (* (/ (* (* a a) (PI)) b) (/ (PI) b)) (* (PI) (PI))))
(* a a))
(* a a)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(angle \cdot angle\right) \cdot b\right) \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(\frac{\left(a \cdot a\right) \cdot \mathsf{PI}\left(\right)}{b} \cdot \frac{\mathsf{PI}\left(\right)}{b} - \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.20000000000000009e38Initial program 79.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.5%
Taylor expanded in angle around 0
Applied rewrites46.1%
if 1.20000000000000009e38 < a Initial program 84.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
Final simplification53.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 4e+31)
(fma
(*
(* (PI) (PI))
(fma 3.08641975308642e-5 (* b b) (* -3.08641975308642e-5 (* a a))))
(* angle angle)
(* a a))
(* a a)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, b \cdot b, -3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle \cdot angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.9999999999999999e31Initial program 79.3%
Taylor expanded in angle around inf
*-commutativeN/A
associate-*r*N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6479.4
Applied rewrites79.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.1%
if 3.9999999999999999e31 < a Initial program 85.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.9
Applied rewrites78.9%
Final simplification53.9%
(FPCore (a b angle)
:precision binary64
(if (<= a 4e+31)
(fma
(* (* -3.08641975308642e-5 (* (PI) (PI))) (- (* a a) (* b b)))
(* angle angle)
(* a a))
(* a a)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(a \cdot a - b \cdot b\right), angle \cdot angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.9999999999999999e31Initial program 79.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.1%
if 3.9999999999999999e31 < a Initial program 85.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.9
Applied rewrites78.9%
Final simplification53.9%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 80.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
Final simplification53.3%
herbie shell --seed 2024346
(FPCore (a b angle)
:name "ab-angle->ABCF C"
:precision binary64
(+ (pow (* a (cos (* (PI) (/ angle 180.0)))) 2.0) (pow (* b (sin (* (PI) (/ angle 180.0)))) 2.0)))