
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((a + 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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((a + b)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((a + b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((a + b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((a + 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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((a + b)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((a + b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((a + b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos b) (cos a)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(b)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(a) * Math.sin(b)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(b) * math.cos(a)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(b))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\sin b \cdot r}{\cos b \cdot \cos a - \sin a \cdot \sin b}
Initial program 76.6%
lift-cos.f64N/A
lift-+.f64N/A
add-flipN/A
cos-diffN/A
cos-neg-revN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5%
Applied rewrites99.5%
Taylor expanded in r around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5%
Applied rewrites99.5%
lift-fma.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
lift-*.f64N/A
remove-double-neg99.5%
Applied rewrites99.5%
lift-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
+-commutativeN/A
lift-PI.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
sub-flipN/A
lift--.f64N/A
lift-cos.f64N/A
lower-*.f6411.2%
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (cos (+ a b))))
double code(double r, double a, double b) {
return (sin(b) * r) / cos((a + 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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (sin(b) * r) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / Math.cos((a + b));
}
def code(r, a, b): return (math.sin(b) * r) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(sin(b) * r) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\sin b \cdot r}{\cos \left(a + b\right)}
Initial program 76.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6476.6%
Applied rewrites76.6%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ a b)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((a + 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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((a + b)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((a + b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((a + b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sin b \cdot \frac{r}{\cos \left(a + b\right)}
Initial program 76.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6476.6%
Applied rewrites76.6%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b))) (t_1 (/ (sin b) t_0)))
(if (<= t_1 -0.001)
(* (/ r (cos b)) (sin b))
(if (<= t_1 0.032)
(* r (/ (* b (+ 1.0 (* -0.16666666666666666 (pow b 2.0)))) t_0))
(* r (/ (sin b) (cos b)))))))double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double tmp;
if (t_1 <= -0.001) {
tmp = (r / cos(b)) * sin(b);
} else if (t_1 <= 0.032) {
tmp = r * ((b * (1.0 + (-0.16666666666666666 * pow(b, 2.0)))) / t_0);
} else {
tmp = r * (sin(b) / cos(b));
}
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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((a + b))
t_1 = sin(b) / t_0
if (t_1 <= (-0.001d0)) then
tmp = (r / cos(b)) * sin(b)
else if (t_1 <= 0.032d0) then
tmp = r * ((b * (1.0d0 + ((-0.16666666666666666d0) * (b ** 2.0d0)))) / t_0)
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.cos((a + b));
double t_1 = Math.sin(b) / t_0;
double tmp;
if (t_1 <= -0.001) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else if (t_1 <= 0.032) {
tmp = r * ((b * (1.0 + (-0.16666666666666666 * Math.pow(b, 2.0)))) / t_0);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): t_0 = math.cos((a + b)) t_1 = math.sin(b) / t_0 tmp = 0 if t_1 <= -0.001: tmp = (r / math.cos(b)) * math.sin(b) elif t_1 <= 0.032: tmp = r * ((b * (1.0 + (-0.16666666666666666 * math.pow(b, 2.0)))) / t_0) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) tmp = 0.0 if (t_1 <= -0.001) tmp = Float64(Float64(r / cos(b)) * sin(b)); elseif (t_1 <= 0.032) tmp = Float64(r * Float64(Float64(b * Float64(1.0 + Float64(-0.16666666666666666 * (b ^ 2.0)))) / t_0)); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) t_0 = cos((a + b)); t_1 = sin(b) / t_0; tmp = 0.0; if (t_1 <= -0.001) tmp = (r / cos(b)) * sin(b); elseif (t_1 <= 0.032) tmp = r * ((b * (1.0 + (-0.16666666666666666 * (b ^ 2.0)))) / t_0); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[b], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.001], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.032], N[(r * N[(N[(b * N[(1.0 + N[(-0.16666666666666666 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
\mathbf{if}\;t\_1 \leq -0.001:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{elif}\;t\_1 \leq 0.032:\\
\;\;\;\;r \cdot \frac{b \cdot \left(1 + -0.16666666666666666 \cdot {b}^{2}\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -1e-3Initial program 76.6%
lift-cos.f64N/A
lift-+.f64N/A
add-flipN/A
cos-diffN/A
cos-neg-revN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5%
Applied rewrites99.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sum-revN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
*-commutativeN/A
Applied rewrites76.6%
Taylor expanded in a around 0
Applied rewrites60.3%
if -1e-3 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.032000000000000001Initial program 76.6%
Taylor expanded in b around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6450.9%
Applied rewrites50.9%
if 0.032000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 76.6%
Taylor expanded in a around 0
Applied rewrites60.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (/ r (cos b)) (sin b)))) (if (<= b -0.0014) t_0 (if (<= b 6.4e-9) (* (/ 1.0 (cos a)) (* b r)) t_0))))
double code(double r, double a, double b) {
double t_0 = (r / cos(b)) * sin(b);
double tmp;
if (b <= -0.0014) {
tmp = t_0;
} else if (b <= 6.4e-9) {
tmp = (1.0 / cos(a)) * (b * r);
} else {
tmp = t_0;
}
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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (r / cos(b)) * sin(b)
if (b <= (-0.0014d0)) then
tmp = t_0
else if (b <= 6.4d-9) then
tmp = (1.0d0 / cos(a)) * (b * r)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (r / Math.cos(b)) * Math.sin(b);
double tmp;
if (b <= -0.0014) {
tmp = t_0;
} else if (b <= 6.4e-9) {
tmp = (1.0 / Math.cos(a)) * (b * r);
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (r / math.cos(b)) * math.sin(b) tmp = 0 if b <= -0.0014: tmp = t_0 elif b <= 6.4e-9: tmp = (1.0 / math.cos(a)) * (b * r) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(r / cos(b)) * sin(b)) tmp = 0.0 if (b <= -0.0014) tmp = t_0; elseif (b <= 6.4e-9) tmp = Float64(Float64(1.0 / cos(a)) * Float64(b * r)); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = (r / cos(b)) * sin(b); tmp = 0.0; if (b <= -0.0014) tmp = t_0; elseif (b <= 6.4e-9) tmp = (1.0 / cos(a)) * (b * r); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0014], t$95$0, If[LessEqual[b, 6.4e-9], N[(N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[(b * r), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;b \leq -0.0014:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\cos a} \cdot \left(b \cdot r\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -0.00139999999999999999 or 6.40000000000000023e-9 < b Initial program 76.6%
lift-cos.f64N/A
lift-+.f64N/A
add-flipN/A
cos-diffN/A
cos-neg-revN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5%
Applied rewrites99.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sum-revN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
*-commutativeN/A
Applied rewrites76.6%
Taylor expanded in a around 0
Applied rewrites60.3%
if -0.00139999999999999999 < b < 6.40000000000000023e-9Initial program 76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f6451.1%
Applied rewrites51.1%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.1%
Applied rewrites51.1%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) (sin b)))
double code(double r, double a, double b) {
return (r / cos(a)) * sin(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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r / cos(a)) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos(a)) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(a)) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\frac{r}{\cos a} \cdot \sin b
Initial program 76.6%
lift-cos.f64N/A
lift-+.f64N/A
add-flipN/A
cos-diffN/A
cos-neg-revN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5%
Applied rewrites99.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sum-revN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
*-commutativeN/A
Applied rewrites76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6454.8%
Applied rewrites54.8%
(FPCore (r a b) :precision binary64 (* (/ 1.0 (cos a)) (* b r)))
double code(double r, double a, double b) {
return (1.0 / cos(a)) * (b * r);
}
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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 / cos(a)) * (b * r)
end function
public static double code(double r, double a, double b) {
return (1.0 / Math.cos(a)) * (b * r);
}
def code(r, a, b): return (1.0 / math.cos(a)) * (b * r)
function code(r, a, b) return Float64(Float64(1.0 / cos(a)) * Float64(b * r)) end
function tmp = code(r, a, b) tmp = (1.0 / cos(a)) * (b * r); end
code[r_, a_, b_] := N[(N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[(b * r), $MachinePrecision]), $MachinePrecision]
\frac{1}{\cos a} \cdot \left(b \cdot r\right)
Initial program 76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f6451.1%
Applied rewrites51.1%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.1%
Applied rewrites51.1%
(FPCore (r a b) :precision binary64 (/ (* b r) (cos a)))
double code(double r, double a, double b) {
return (b * r) / cos(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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * r) / cos(a)
end function
public static double code(double r, double a, double b) {
return (b * r) / Math.cos(a);
}
def code(r, a, b): return (b * r) / math.cos(a)
function code(r, a, b) return Float64(Float64(b * r) / cos(a)) end
function tmp = code(r, a, b) tmp = (b * r) / cos(a); end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\frac{b \cdot r}{\cos a}
Initial program 76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f6451.1%
Applied rewrites51.1%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) b))
double code(double r, double a, double b) {
return (r / cos(a)) * 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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r / cos(a)) * b
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * b;
}
def code(r, a, b): return (r / math.cos(a)) * b
function code(r, a, b) return Float64(Float64(r / cos(a)) * b) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * b; end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]
\frac{r}{\cos a} \cdot b
Initial program 76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f6451.1%
Applied rewrites51.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.1%
Applied rewrites51.1%
(FPCore (r a b) :precision binary64 (/ (* b r) 1.0))
double code(double r, double a, double b) {
return (b * r) / 1.0;
}
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(r, a, b)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * r) / 1.0d0
end function
public static double code(double r, double a, double b) {
return (b * r) / 1.0;
}
def code(r, a, b): return (b * r) / 1.0
function code(r, a, b) return Float64(Float64(b * r) / 1.0) end
function tmp = code(r, a, b) tmp = (b * r) / 1.0; end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / 1.0), $MachinePrecision]
\frac{b \cdot r}{1}
Initial program 76.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f6451.1%
Applied rewrites51.1%
Taylor expanded in a around 0
Applied rewrites34.9%
herbie shell --seed 2025183
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))