
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (fma (+ 0.5 (* 0.5 (cos (* 2.0 (* PI (* 0.005555555555555556 angle)))))) (* b b) (pow (* (sin (* (* PI angle) 0.005555555555555556)) a) 2.0)))
double code(double a, double b, double angle) {
return fma((0.5 + (0.5 * cos((2.0 * (((double) M_PI) * (0.005555555555555556 * angle)))))), (b * b), pow((sin(((((double) M_PI) * angle) * 0.005555555555555556)) * a), 2.0));
}
function code(a, b, angle) return fma(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(pi * Float64(0.005555555555555556 * angle)))))), Float64(b * b), (Float64(sin(Float64(Float64(pi * angle) * 0.005555555555555556)) * a) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision] + N[Power[N[(N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, {\left(\sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right) \cdot a\right)}^{2}\right)
\end{array}
Initial program 79.3%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-cos.f64N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in angle around inf
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6479.2
Applied rewrites79.2%
(FPCore (a b angle) :precision binary64 (fma 1.0 (* b b) (pow (* (sin (* PI (* 0.005555555555555556 angle))) a) 2.0)))
double code(double a, double b, double angle) {
return fma(1.0, (b * b), pow((sin((((double) M_PI) * (0.005555555555555556 * angle))) * a), 2.0));
}
function code(a, b, angle) return fma(1.0, Float64(b * b), (Float64(sin(Float64(pi * Float64(0.005555555555555556 * angle))) * a) ^ 2.0)) end
code[a_, b_, angle_] := N[(1.0 * N[(b * b), $MachinePrecision] + N[Power[N[(N[Sin[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1, b \cdot b, {\left(\sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot a\right)}^{2}\right)
\end{array}
Initial program 79.3%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in angle around 0
Applied rewrites79.2%
(FPCore (a b angle)
:precision binary64
(if (<= b 6.9e+115)
(fma
(fma
(*
3.08641975308642e-5
(fma (* PI PI) (* a a) (* (* -1.0 (* PI PI)) (* b b))))
angle
(* (* 0.0 (* b b)) 0.005555555555555556))
angle
(* 1.0 (* b b)))
(* (fma (cos (* 0.011111111111111112 (* PI angle))) 0.5 0.5) (* b b))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.9e+115) {
tmp = fma(fma((3.08641975308642e-5 * fma((((double) M_PI) * ((double) M_PI)), (a * a), ((-1.0 * (((double) M_PI) * ((double) M_PI))) * (b * b)))), angle, ((0.0 * (b * b)) * 0.005555555555555556)), angle, (1.0 * (b * b)));
} else {
tmp = fma(cos((0.011111111111111112 * (((double) M_PI) * angle))), 0.5, 0.5) * (b * b);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 6.9e+115) tmp = fma(fma(Float64(3.08641975308642e-5 * fma(Float64(pi * pi), Float64(a * a), Float64(Float64(-1.0 * Float64(pi * pi)) * Float64(b * b)))), angle, Float64(Float64(0.0 * Float64(b * b)) * 0.005555555555555556)), angle, Float64(1.0 * Float64(b * b))); else tmp = Float64(fma(cos(Float64(0.011111111111111112 * Float64(pi * angle))), 0.5, 0.5) * Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 6.9e+115], N[(N[(N[(3.08641975308642e-5 * N[(N[(Pi * Pi), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(N[(-1.0 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(N[(0.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]), $MachinePrecision] * angle + N[(1.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5} \cdot \mathsf{fma}\left(\pi \cdot \pi, a \cdot a, \left(-1 \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(b \cdot b\right)\right), angle, \left(0 \cdot \left(b \cdot b\right)\right) \cdot 0.005555555555555556\right), angle, 1 \cdot \left(b \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right), 0.5, 0.5\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 6.89999999999999967e115Initial program 79.3%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in angle around 0
lower-*.f6479.3
Applied rewrites79.3%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
Applied rewrites79.3%
Taylor expanded in angle around 0
Applied rewrites43.0%
if 6.89999999999999967e115 < b Initial program 79.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6456.9
Applied rewrites56.9%
(FPCore (a b angle)
:precision binary64
(if (<= b 6.9e+115)
(fma
b
b
(*
(* angle angle)
(fma
(* -3.08641975308642e-5 (* b b))
(* PI PI)
(* (* 3.08641975308642e-5 (* a a)) (* PI PI)))))
(* (fma (cos (* 0.011111111111111112 (* PI angle))) 0.5 0.5) (* b b))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.9e+115) {
tmp = fma(b, b, ((angle * angle) * fma((-3.08641975308642e-5 * (b * b)), (((double) M_PI) * ((double) M_PI)), ((3.08641975308642e-5 * (a * a)) * (((double) M_PI) * ((double) M_PI))))));
} else {
tmp = fma(cos((0.011111111111111112 * (((double) M_PI) * angle))), 0.5, 0.5) * (b * b);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 6.9e+115) tmp = fma(b, b, Float64(Float64(angle * angle) * fma(Float64(-3.08641975308642e-5 * Float64(b * b)), Float64(pi * pi), Float64(Float64(3.08641975308642e-5 * Float64(a * a)) * Float64(pi * pi))))); else tmp = Float64(fma(cos(Float64(0.011111111111111112 * Float64(pi * angle))), 0.5, 0.5) * Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 6.9e+115], N[(b * b + N[(N[(angle * angle), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(b, b, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right), \pi \cdot \pi, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right), 0.5, 0.5\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 6.89999999999999967e115Initial program 79.3%
Taylor expanded in angle around 0
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites40.6%
if 6.89999999999999967e115 < b Initial program 79.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6456.9
Applied rewrites56.9%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.95e+115)
(fma
b
b
(*
(* angle angle)
(fma
(* -3.08641975308642e-5 (* b b))
(* PI PI)
(* (* 3.08641975308642e-5 (* a a)) (* PI PI)))))
(* b b)))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.95e+115) {
tmp = fma(b, b, ((angle * angle) * fma((-3.08641975308642e-5 * (b * b)), (((double) M_PI) * ((double) M_PI)), ((3.08641975308642e-5 * (a * a)) * (((double) M_PI) * ((double) M_PI))))));
} else {
tmp = b * b;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.95e+115) tmp = fma(b, b, Float64(Float64(angle * angle) * fma(Float64(-3.08641975308642e-5 * Float64(b * b)), Float64(pi * pi), Float64(Float64(3.08641975308642e-5 * Float64(a * a)) * Float64(pi * pi))))); else tmp = Float64(b * b); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.95e+115], N[(b * b + N[(N[(angle * angle), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(b, b, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right), \pi \cdot \pi, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 1.95000000000000003e115Initial program 79.3%
Taylor expanded in angle around 0
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites40.6%
if 1.95000000000000003e115 < b Initial program 79.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
(FPCore (a b angle) :precision binary64 (if (<= a 2.5e+197) (* b b) (* (* (/ b a) (/ b a)) (* a a))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.5e+197) {
tmp = b * b;
} else {
tmp = ((b / a) * (b / a)) * (a * a);
}
return tmp;
}
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
real(8) :: tmp
if (a <= 2.5d+197) then
tmp = b * b
else
tmp = ((b / a) * (b / a)) * (a * a)
end if
code = tmp
end function
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.5e+197) {
tmp = b * b;
} else {
tmp = ((b / a) * (b / a)) * (a * a);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.5e+197: tmp = b * b else: tmp = ((b / a) * (b / a)) * (a * a) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.5e+197) tmp = Float64(b * b); else tmp = Float64(Float64(Float64(b / a) * Float64(b / a)) * Float64(a * a)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.5e+197) tmp = b * b; else tmp = ((b / a) * (b / a)) * (a * a); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.5e+197], N[(b * b), $MachinePrecision], N[(N[(N[(b / a), $MachinePrecision] * N[(b / a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.5 \cdot 10^{+197}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{b}{a} \cdot \frac{b}{a}\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 2.50000000000000004e197Initial program 79.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
if 2.50000000000000004e197 < a Initial program 79.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.1%
Taylor expanded in angle around 0
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6426.8
Applied rewrites26.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6440.9
Applied rewrites40.9%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
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 = b * b
end function
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 79.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
herbie shell --seed 2025140
(FPCore (a b angle)
:name "ab-angle->ABCF A"
:precision binary64
(+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0)))