
(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}
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}
Herbie found 11 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}
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}
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(*
(*
(* 0.005555555555555556 angle)
(* (cbrt (pow PI 1.6666666666666667)) 1.1356352767378999))
(cbrt PI))))
2.0)
(pow (* b 1.0) 2.0)))double code(double a, double b, double angle) {
return pow((a * sin((((0.005555555555555556 * angle) * (cbrt(pow(((double) M_PI), 1.6666666666666667)) * 1.1356352767378999)) * cbrt(((double) M_PI))))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((((0.005555555555555556 * angle) * (Math.cbrt(Math.pow(Math.PI, 1.6666666666666667)) * 1.1356352767378999)) * Math.cbrt(Math.PI)))), 2.0) + Math.pow((b * 1.0), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(Float64(0.005555555555555556 * angle) * Float64(cbrt((pi ^ 1.6666666666666667)) * 1.1356352767378999)) * cbrt(pi)))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(N[(0.005555555555555556 * angle), $MachinePrecision] * N[(N[Power[N[Power[Pi, 1.6666666666666667], $MachinePrecision], 1/3], $MachinePrecision] * 1.1356352767378999), $MachinePrecision]), $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \left(\sqrt[3]{{\pi}^{1.6666666666666667}} \cdot 1.1356352767378999\right)\right) \cdot \sqrt[3]{\pi}\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
lift-PI.f64N/A
pow-cbrtN/A
lower-pow.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6479.5%
Applied rewrites79.5%
lift-pow.f64N/A
metadata-evalN/A
pow-addN/A
unpow-prod-downN/A
lift-PI.f64N/A
lift-PI.f64N/A
pow1/3N/A
lift-PI.f64N/A
pow1N/A
lift-PI.f64N/A
metadata-evalN/A
pow-prod-upN/A
lift-pow.f64N/A
pow1/3N/A
lift-cbrt.f64N/A
associate-*r*N/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites79.5%
Evaluated real constant79.5%
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(*
(* (* 0.005555555555555556 angle) (pow PI 0.6666666666666666))
1.4645918875615234)))
2.0)
(pow (* b 1.0) 2.0)))double code(double a, double b, double angle) {
return pow((a * sin((((0.005555555555555556 * angle) * pow(((double) M_PI), 0.6666666666666666)) * 1.4645918875615234))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((((0.005555555555555556 * angle) * Math.pow(Math.PI, 0.6666666666666666)) * 1.4645918875615234))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((((0.005555555555555556 * angle) * math.pow(math.pi, 0.6666666666666666)) * 1.4645918875615234))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(Float64(0.005555555555555556 * angle) * (pi ^ 0.6666666666666666)) * 1.4645918875615234))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((((0.005555555555555556 * angle) * (pi ^ 0.6666666666666666)) * 1.4645918875615234))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(N[(0.005555555555555556 * angle), $MachinePrecision] * N[Power[Pi, 0.6666666666666666], $MachinePrecision]), $MachinePrecision] * 1.4645918875615234), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot {\pi}^{0.6666666666666666}\right) \cdot 1.4645918875615234\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
lift-PI.f64N/A
pow-cbrtN/A
lower-pow.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6479.5%
Applied rewrites79.5%
Evaluated real constant79.6%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.017453292519943295 angle))) 2.0) (* (* (* 1.0 b) 1.0) b)))
double code(double a, double b, double angle) {
return pow((a * sin((0.017453292519943295 * angle))), 2.0) + (((1.0 * b) * 1.0) * 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 = ((a * sin((0.017453292519943295d0 * angle))) ** 2.0d0) + (((1.0d0 * b) * 1.0d0) * b)
end function
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((0.017453292519943295 * angle))), 2.0) + (((1.0 * b) * 1.0) * b);
}
def code(a, b, angle): return math.pow((a * math.sin((0.017453292519943295 * angle))), 2.0) + (((1.0 * b) * 1.0) * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.017453292519943295 * angle))) ^ 2.0) + Float64(Float64(Float64(1.0 * b) * 1.0) * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin((0.017453292519943295 * angle))) ^ 2.0) + (((1.0 * b) * 1.0) * b); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(0.017453292519943295 * angle), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(1.0 * b), $MachinePrecision] * 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(0.017453292519943295 \cdot angle\right)\right)}^{2} + \left(\left(1 \cdot b\right) \cdot 1\right) \cdot b
Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
Applied rewrites79.6%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6479.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
Applied rewrites79.6%
Evaluated real constant79.6%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs angle) 1.35e-6)
(+
(pow (* a (* 0.005555555555555556 (* (fabs angle) PI))) 2.0)
(pow (* b 1.0) 2.0))
(fma
(* (- 1.0 (cos (* 0.011111111111111112 (* PI (fabs angle))))) 0.5)
(* a a)
(* (* (* 1.0 b) b) 1.0))))double code(double a, double b, double angle) {
double tmp;
if (fabs(angle) <= 1.35e-6) {
tmp = pow((a * (0.005555555555555556 * (fabs(angle) * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
} else {
tmp = fma(((1.0 - cos((0.011111111111111112 * (((double) M_PI) * fabs(angle))))) * 0.5), (a * a), (((1.0 * b) * b) * 1.0));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (abs(angle) <= 1.35e-6) tmp = Float64((Float64(a * Float64(0.005555555555555556 * Float64(abs(angle) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)); else tmp = fma(Float64(Float64(1.0 - cos(Float64(0.011111111111111112 * Float64(pi * abs(angle))))) * 0.5), Float64(a * a), Float64(Float64(Float64(1.0 * b) * b) * 1.0)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[Abs[angle], $MachinePrecision], 1.35e-6], N[(N[Power[N[(a * N[(0.005555555555555556 * N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[Cos[N[(0.011111111111111112 * N[(Pi * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(N[(N[(1.0 * b), $MachinePrecision] * b), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|angle\right| \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(\left|angle\right| \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(1 - \cos \left(0.011111111111111112 \cdot \left(\pi \cdot \left|angle\right|\right)\right)\right) \cdot 0.5, a \cdot a, \left(\left(1 \cdot b\right) \cdot b\right) \cdot 1\right)\\
\end{array}
if angle < 1.34999999999999999e-6Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6474.4%
Applied rewrites74.4%
if 1.34999999999999999e-6 < angle Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
lift-PI.f64N/A
pow-cbrtN/A
lower-pow.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6479.5%
Applied rewrites79.5%
lift-pow.f64N/A
metadata-evalN/A
pow-addN/A
unpow-prod-downN/A
lift-PI.f64N/A
lift-PI.f64N/A
pow1/3N/A
lift-PI.f64N/A
pow1N/A
lift-PI.f64N/A
metadata-evalN/A
pow-prod-upN/A
lift-pow.f64N/A
pow1/3N/A
lift-cbrt.f64N/A
associate-*r*N/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites79.5%
Applied rewrites62.8%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs a) 1.02e-94)
(* b b)
(+
(pow (* (fabs a) (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (* b 1.0) 2.0))))double code(double a, double b, double angle) {
double tmp;
if (fabs(a) <= 1.02e-94) {
tmp = b * b;
} else {
tmp = pow((fabs(a) * (0.005555555555555556 * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.abs(a) <= 1.02e-94) {
tmp = b * b;
} else {
tmp = Math.pow((Math.abs(a) * (0.005555555555555556 * (angle * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.fabs(a) <= 1.02e-94: tmp = b * b else: tmp = math.pow((math.fabs(a) * (0.005555555555555556 * (angle * math.pi))), 2.0) + math.pow((b * 1.0), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (abs(a) <= 1.02e-94) tmp = Float64(b * b); else tmp = Float64((Float64(abs(a) * Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (abs(a) <= 1.02e-94) tmp = b * b; else tmp = ((abs(a) * (0.005555555555555556 * (angle * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Abs[a], $MachinePrecision], 1.02e-94], N[(b * b), $MachinePrecision], N[(N[Power[N[(N[Abs[a], $MachinePrecision] * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 1.02 \cdot 10^{-94}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(\left|a\right| \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\
\end{array}
if a < 1.02e-94Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
if 1.02e-94 < a Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6474.4%
Applied rewrites74.4%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs a) 1.02e-94)
(* b b)
(+
(pow (* 0.005555555555555556 (* (fabs a) (* angle PI))) 2.0)
(pow (* b 1.0) 2.0))))double code(double a, double b, double angle) {
double tmp;
if (fabs(a) <= 1.02e-94) {
tmp = b * b;
} else {
tmp = pow((0.005555555555555556 * (fabs(a) * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.abs(a) <= 1.02e-94) {
tmp = b * b;
} else {
tmp = Math.pow((0.005555555555555556 * (Math.abs(a) * (angle * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.fabs(a) <= 1.02e-94: tmp = b * b else: tmp = math.pow((0.005555555555555556 * (math.fabs(a) * (angle * math.pi))), 2.0) + math.pow((b * 1.0), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (abs(a) <= 1.02e-94) tmp = Float64(b * b); else tmp = Float64((Float64(0.005555555555555556 * Float64(abs(a) * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (abs(a) <= 1.02e-94) tmp = b * b; else tmp = ((0.005555555555555556 * (abs(a) * (angle * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Abs[a], $MachinePrecision], 1.02e-94], N[(b * b), $MachinePrecision], N[(N[Power[N[(0.005555555555555556 * N[(N[Abs[a], $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 1.02 \cdot 10^{-94}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(0.005555555555555556 \cdot \left(\left|a\right| \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\
\end{array}
if a < 1.02e-94Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
if 1.02e-94 < a Initial program 79.6%
Taylor expanded in angle around 0
Applied rewrites79.6%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6474.4%
Applied rewrites74.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.75e+149)
(fma
(*
(*
(* PI PI)
(fma -3.08641975308642e-5 t_0 (* (* a a) 3.08641975308642e-5)))
angle)
angle
t_0)
t_0)))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.75e+149) {
tmp = fma((((((double) M_PI) * ((double) M_PI)) * fma(-3.08641975308642e-5, t_0, ((a * a) * 3.08641975308642e-5))) * angle), angle, t_0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.75e+149) tmp = fma(Float64(Float64(Float64(pi * pi) * fma(-3.08641975308642e-5, t_0, Float64(Float64(a * a) * 3.08641975308642e-5))) * angle), angle, t_0); else tmp = t_0; end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.75e+149], N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(-3.08641975308642e-5 * t$95$0 + N[(N[(a * a), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision] * angle + t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.75 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5}, t\_0, \left(a \cdot a\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot angle, angle, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < 1.75000000000000006e149Initial program 79.6%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites39.9%
lift-fma.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites42.4%
if 1.75000000000000006e149 < b Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.7e+149)
(fma
(* angle angle)
(*
(* PI PI)
(fma -3.08641975308642e-5 t_0 (* (* a a) 3.08641975308642e-5)))
t_0)
t_0)))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.7e+149) {
tmp = fma((angle * angle), ((((double) M_PI) * ((double) M_PI)) * fma(-3.08641975308642e-5, t_0, ((a * a) * 3.08641975308642e-5))), t_0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.7e+149) tmp = fma(Float64(angle * angle), Float64(Float64(pi * pi) * fma(-3.08641975308642e-5, t_0, Float64(Float64(a * a) * 3.08641975308642e-5))), t_0); else tmp = t_0; end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.7e+149], N[(N[(angle * angle), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(-3.08641975308642e-5 * t$95$0 + N[(N[(a * a), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.7 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \left(\pi \cdot \pi\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5}, t\_0, \left(a \cdot a\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < 1.6999999999999999e149Initial program 79.6%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites39.9%
Applied rewrites40.0%
if 1.6999999999999999e149 < b Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* b b) b) b)) (t_1 (* (/ angle 180.0) PI)))
(if (<= (+ (pow (* a (sin t_1)) 2.0) (pow (* b (cos t_1)) 2.0)) 1e+307)
(* b b)
(sqrt (sqrt (* t_0 t_0))))))double code(double a, double b, double angle) {
double t_0 = ((b * b) * b) * b;
double t_1 = (angle / 180.0) * ((double) M_PI);
double tmp;
if ((pow((a * sin(t_1)), 2.0) + pow((b * cos(t_1)), 2.0)) <= 1e+307) {
tmp = b * b;
} else {
tmp = sqrt(sqrt((t_0 * t_0)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = ((b * b) * b) * b;
double t_1 = (angle / 180.0) * Math.PI;
double tmp;
if ((Math.pow((a * Math.sin(t_1)), 2.0) + Math.pow((b * Math.cos(t_1)), 2.0)) <= 1e+307) {
tmp = b * b;
} else {
tmp = Math.sqrt(Math.sqrt((t_0 * t_0)));
}
return tmp;
}
def code(a, b, angle): t_0 = ((b * b) * b) * b t_1 = (angle / 180.0) * math.pi tmp = 0 if (math.pow((a * math.sin(t_1)), 2.0) + math.pow((b * math.cos(t_1)), 2.0)) <= 1e+307: tmp = b * b else: tmp = math.sqrt(math.sqrt((t_0 * t_0))) return tmp
function code(a, b, angle) t_0 = Float64(Float64(Float64(b * b) * b) * b) t_1 = Float64(Float64(angle / 180.0) * pi) tmp = 0.0 if (Float64((Float64(a * sin(t_1)) ^ 2.0) + (Float64(b * cos(t_1)) ^ 2.0)) <= 1e+307) tmp = Float64(b * b); else tmp = sqrt(sqrt(Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = ((b * b) * b) * b; t_1 = (angle / 180.0) * pi; tmp = 0.0; if ((((a * sin(t_1)) ^ 2.0) + ((b * cos(t_1)) ^ 2.0)) <= 1e+307) tmp = b * b; else tmp = sqrt(sqrt((t_0 * t_0))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(a * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 1e+307], N[(b * b), $MachinePrecision], N[Sqrt[N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(b \cdot b\right) \cdot b\right) \cdot b\\
t_1 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_1\right)}^{2} + {\left(b \cdot \cos t\_1\right)}^{2} \leq 10^{+307}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{t\_0 \cdot t\_0}}\\
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 9.99999999999999986e306Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
if 9.99999999999999986e306 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-sqrt.f64N/A
lower-unsound-*.f6450.3%
lift-pow.f64N/A
pow2N/A
lift-*.f6450.3%
lift-pow.f64N/A
pow2N/A
lift-*.f6450.3%
Applied rewrites50.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6445.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.8%
Applied rewrites45.8%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI)))
(if (<= (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)) 1e+307)
(* b b)
(sqrt (* (* b b) (* b b))))))double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double tmp;
if ((pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0)) <= 1e+307) {
tmp = b * b;
} else {
tmp = sqrt(((b * b) * (b * b)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
double tmp;
if ((Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0)) <= 1e+307) {
tmp = b * b;
} else {
tmp = Math.sqrt(((b * b) * (b * b)));
}
return tmp;
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi tmp = 0 if (math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)) <= 1e+307: tmp = b * b else: tmp = math.sqrt(((b * b) * (b * b))) return tmp
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) tmp = 0.0 if (Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) <= 1e+307) tmp = Float64(b * b); else tmp = sqrt(Float64(Float64(b * b) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = 0.0; if ((((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0)) <= 1e+307) tmp = b * b; else tmp = sqrt(((b * b) * (b * b))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[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], 1e+307], N[(b * b), $MachinePrecision], N[Sqrt[N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 10^{+307}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(b \cdot b\right) \cdot \left(b \cdot b\right)}\\
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 9.99999999999999986e306Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
if 9.99999999999999986e306 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-sqrt.f64N/A
lower-unsound-*.f6450.3%
lift-pow.f64N/A
pow2N/A
lift-*.f6450.3%
lift-pow.f64N/A
pow2N/A
lift-*.f6450.3%
Applied rewrites50.3%
(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]
b \cdot b
Initial program 79.6%
Taylor expanded in angle around 0
lower-pow.f6457.9%
Applied rewrites57.9%
lift-pow.f64N/A
pow2N/A
lift-*.f6457.9%
Applied rewrites57.9%
herbie shell --seed 2025188
(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)))