
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
(FPCore (B x) :precision binary64 (/ (- (* (/ 1.0 (sin B)) (tan B)) x) (tan B)))
double code(double B, double x) {
return (((1.0 / sin(B)) * tan(B)) - x) / tan(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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (((1.0d0 / sin(b)) * tan(b)) - x) / tan(b)
end function
public static double code(double B, double x) {
return (((1.0 / Math.sin(B)) * Math.tan(B)) - x) / Math.tan(B);
}
def code(B, x): return (((1.0 / math.sin(B)) * math.tan(B)) - x) / math.tan(B)
function code(B, x) return Float64(Float64(Float64(Float64(1.0 / sin(B)) * tan(B)) - x) / tan(B)) end
function tmp = code(B, x) tmp = (((1.0 / sin(B)) * tan(B)) - x) / tan(B); end
code[B_, x_] := N[(N[(N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Tan[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]
\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}
Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
sub-to-fractionN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
(FPCore (B x) :precision binary64 (- (/ 1.0 (sin B)) (/ x (tan B))))
double code(double B, double x) {
return (1.0 / sin(B)) - (x / tan(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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / sin(b)) - (x / tan(b))
end function
public static double code(double B, double x) {
return (1.0 / Math.sin(B)) - (x / Math.tan(B));
}
def code(B, x): return (1.0 / math.sin(B)) - (x / math.tan(B))
function code(B, x) return Float64(Float64(1.0 / sin(B)) - Float64(x / tan(B))) end
function tmp = code(B, x) tmp = (1.0 / sin(B)) - (x / tan(B)); end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sin B} - \frac{x}{\tan B}
Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6499.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.8%
Applied rewrites99.8%
(FPCore (B x)
:precision binary64
(let* ((t_0 (sin (fabs B))) (t_1 (cos (fabs B))))
(*
(copysign 1.0 B)
(if (<= (fabs B) 0.000325)
(* (/ (- 1.0 x) t_0) t_1)
(* (/ (- (/ 1.0 x) t_1) t_0) x)))))double code(double B, double x) {
double t_0 = sin(fabs(B));
double t_1 = cos(fabs(B));
double tmp;
if (fabs(B) <= 0.000325) {
tmp = ((1.0 - x) / t_0) * t_1;
} else {
tmp = (((1.0 / x) - t_1) / t_0) * x;
}
return copysign(1.0, B) * tmp;
}
public static double code(double B, double x) {
double t_0 = Math.sin(Math.abs(B));
double t_1 = Math.cos(Math.abs(B));
double tmp;
if (Math.abs(B) <= 0.000325) {
tmp = ((1.0 - x) / t_0) * t_1;
} else {
tmp = (((1.0 / x) - t_1) / t_0) * x;
}
return Math.copySign(1.0, B) * tmp;
}
def code(B, x): t_0 = math.sin(math.fabs(B)) t_1 = math.cos(math.fabs(B)) tmp = 0 if math.fabs(B) <= 0.000325: tmp = ((1.0 - x) / t_0) * t_1 else: tmp = (((1.0 / x) - t_1) / t_0) * x return math.copysign(1.0, B) * tmp
function code(B, x) t_0 = sin(abs(B)) t_1 = cos(abs(B)) tmp = 0.0 if (abs(B) <= 0.000325) tmp = Float64(Float64(Float64(1.0 - x) / t_0) * t_1); else tmp = Float64(Float64(Float64(Float64(1.0 / x) - t_1) / t_0) * x); end return Float64(copysign(1.0, B) * tmp) end
function tmp_2 = code(B, x) t_0 = sin(abs(B)); t_1 = cos(abs(B)); tmp = 0.0; if (abs(B) <= 0.000325) tmp = ((1.0 - x) / t_0) * t_1; else tmp = (((1.0 / x) - t_1) / t_0) * x; end tmp_2 = (sign(B) * abs(1.0)) * tmp; end
code[B_, x_] := Block[{t$95$0 = N[Sin[N[Abs[B], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[Abs[B], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[B], $MachinePrecision], 0.000325], N[(N[(N[(1.0 - x), $MachinePrecision] / t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(1.0 / x), $MachinePrecision] - t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\left|B\right|\right)\\
t_1 := \cos \left(\left|B\right|\right)\\
\mathsf{copysign}\left(1, B\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|B\right| \leq 0.000325:\\
\;\;\;\;\frac{1 - x}{t\_0} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - t\_1}{t\_0} \cdot x\\
\end{array}
\end{array}
if B < 3.2499999999999999e-4Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
sub-to-fractionN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites77.0%
lift-/.f64N/A
mult-flipN/A
lift-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-tan.f64N/A
lower-/.f6476.9%
Applied rewrites76.9%
lift-*.f64N/A
*-commutativeN/A
lift-tan.f64N/A
lift-/.f64N/A
mult-flip-revN/A
tan-quotN/A
lift-cos.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6477.0%
Applied rewrites77.0%
if 3.2499999999999999e-4 < B Initial program 99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6487.7%
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.7%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6487.7%
Applied rewrites87.7%
(FPCore (B x)
:precision binary64
(let* ((t_0 (tan (fabs B)))
(t_1 (/ 1.0 (sin (fabs B))))
(t_2 (+ (- (* x (/ 1.0 t_0))) t_1)))
(*
(copysign 1.0 B)
(if (<= t_2 -5e+22)
(/ (- 1.0 x) t_0)
(if (<= t_2 40.0)
(- t_1 (/ x (fabs B)))
(- (/ 1.0 (fabs B)) (/ x t_0)))))))double code(double B, double x) {
double t_0 = tan(fabs(B));
double t_1 = 1.0 / sin(fabs(B));
double t_2 = -(x * (1.0 / t_0)) + t_1;
double tmp;
if (t_2 <= -5e+22) {
tmp = (1.0 - x) / t_0;
} else if (t_2 <= 40.0) {
tmp = t_1 - (x / fabs(B));
} else {
tmp = (1.0 / fabs(B)) - (x / t_0);
}
return copysign(1.0, B) * tmp;
}
public static double code(double B, double x) {
double t_0 = Math.tan(Math.abs(B));
double t_1 = 1.0 / Math.sin(Math.abs(B));
double t_2 = -(x * (1.0 / t_0)) + t_1;
double tmp;
if (t_2 <= -5e+22) {
tmp = (1.0 - x) / t_0;
} else if (t_2 <= 40.0) {
tmp = t_1 - (x / Math.abs(B));
} else {
tmp = (1.0 / Math.abs(B)) - (x / t_0);
}
return Math.copySign(1.0, B) * tmp;
}
def code(B, x): t_0 = math.tan(math.fabs(B)) t_1 = 1.0 / math.sin(math.fabs(B)) t_2 = -(x * (1.0 / t_0)) + t_1 tmp = 0 if t_2 <= -5e+22: tmp = (1.0 - x) / t_0 elif t_2 <= 40.0: tmp = t_1 - (x / math.fabs(B)) else: tmp = (1.0 / math.fabs(B)) - (x / t_0) return math.copysign(1.0, B) * tmp
function code(B, x) t_0 = tan(abs(B)) t_1 = Float64(1.0 / sin(abs(B))) t_2 = Float64(Float64(-Float64(x * Float64(1.0 / t_0))) + t_1) tmp = 0.0 if (t_2 <= -5e+22) tmp = Float64(Float64(1.0 - x) / t_0); elseif (t_2 <= 40.0) tmp = Float64(t_1 - Float64(x / abs(B))); else tmp = Float64(Float64(1.0 / abs(B)) - Float64(x / t_0)); end return Float64(copysign(1.0, B) * tmp) end
function tmp_2 = code(B, x) t_0 = tan(abs(B)); t_1 = 1.0 / sin(abs(B)); t_2 = -(x * (1.0 / t_0)) + t_1; tmp = 0.0; if (t_2 <= -5e+22) tmp = (1.0 - x) / t_0; elseif (t_2 <= 40.0) tmp = t_1 - (x / abs(B)); else tmp = (1.0 / abs(B)) - (x / t_0); end tmp_2 = (sign(B) * abs(1.0)) * tmp; end
code[B_, x_] := Block[{t$95$0 = N[Tan[N[Abs[B], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sin[N[Abs[B], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]) + t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -5e+22], N[(N[(1.0 - x), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 40.0], N[(t$95$1 - N[(x / N[Abs[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Abs[B], $MachinePrecision]), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \tan \left(\left|B\right|\right)\\
t_1 := \frac{1}{\sin \left(\left|B\right|\right)}\\
t_2 := \left(-x \cdot \frac{1}{t\_0}\right) + t\_1\\
\mathsf{copysign}\left(1, B\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+22}:\\
\;\;\;\;\frac{1 - x}{t\_0}\\
\mathbf{elif}\;t\_2 \leq 40:\\
\;\;\;\;t\_1 - \frac{x}{\left|B\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left|B\right|} - \frac{x}{t\_0}\\
\end{array}
\end{array}
if (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) < -4.9999999999999996e22Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
sub-to-fractionN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites77.0%
if -4.9999999999999996e22 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) < 40Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6499.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
lower-/.f6475.2%
Applied rewrites75.2%
if 40 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (/.f64 #s(literal 1 binary64) (sin.f64 B))) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6499.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
lower-/.f6475.2%
Applied rewrites75.2%
(FPCore (B x) :precision binary64 (let* ((t_0 (/ (- 1.0 x) (tan B)))) (if (<= x -2.9) t_0 (if (<= x 3.2e+20) (/ 1.0 (sin B)) t_0))))
double code(double B, double x) {
double t_0 = (1.0 - x) / tan(B);
double tmp;
if (x <= -2.9) {
tmp = t_0;
} else if (x <= 3.2e+20) {
tmp = 1.0 / sin(B);
} 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 - x) / tan(b)
if (x <= (-2.9d0)) then
tmp = t_0
else if (x <= 3.2d+20) then
tmp = 1.0d0 / sin(b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = (1.0 - x) / Math.tan(B);
double tmp;
if (x <= -2.9) {
tmp = t_0;
} else if (x <= 3.2e+20) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = t_0;
}
return tmp;
}
def code(B, x): t_0 = (1.0 - x) / math.tan(B) tmp = 0 if x <= -2.9: tmp = t_0 elif x <= 3.2e+20: tmp = 1.0 / math.sin(B) else: tmp = t_0 return tmp
function code(B, x) t_0 = Float64(Float64(1.0 - x) / tan(B)) tmp = 0.0 if (x <= -2.9) tmp = t_0; elseif (x <= 3.2e+20) tmp = Float64(1.0 / sin(B)); else tmp = t_0; end return tmp end
function tmp_2 = code(B, x) t_0 = (1.0 - x) / tan(B); tmp = 0.0; if (x <= -2.9) tmp = t_0; elseif (x <= 3.2e+20) tmp = 1.0 / sin(B); else tmp = t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.9], t$95$0, If[LessEqual[x, 3.2e+20], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{1 - x}{\tan B}\\
\mathbf{if}\;x \leq -2.9:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.8999999999999999 or 3.2e20 < x Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
sub-to-fractionN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites77.0%
if -2.8999999999999999 < x < 3.2e20Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6499.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.8%
Applied rewrites99.8%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-tan.f64N/A
sub-flipN/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f6450.2%
Applied rewrites50.2%
(FPCore (B x)
:precision binary64
(*
(copysign 1.0 B)
(if (<= (fabs B) 820000.0)
(/
(-
(+
1.0
(*
(pow (fabs B) 2.0)
(+ 0.16666666666666666 (* 0.3333333333333333 x))))
x)
(fabs B))
(/ 1.0 (sin (fabs B))))))double code(double B, double x) {
double tmp;
if (fabs(B) <= 820000.0) {
tmp = ((1.0 + (pow(fabs(B), 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / fabs(B);
} else {
tmp = 1.0 / sin(fabs(B));
}
return copysign(1.0, B) * tmp;
}
public static double code(double B, double x) {
double tmp;
if (Math.abs(B) <= 820000.0) {
tmp = ((1.0 + (Math.pow(Math.abs(B), 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / Math.abs(B);
} else {
tmp = 1.0 / Math.sin(Math.abs(B));
}
return Math.copySign(1.0, B) * tmp;
}
def code(B, x): tmp = 0 if math.fabs(B) <= 820000.0: tmp = ((1.0 + (math.pow(math.fabs(B), 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / math.fabs(B) else: tmp = 1.0 / math.sin(math.fabs(B)) return math.copysign(1.0, B) * tmp
function code(B, x) tmp = 0.0 if (abs(B) <= 820000.0) tmp = Float64(Float64(Float64(1.0 + Float64((abs(B) ^ 2.0) * Float64(0.16666666666666666 + Float64(0.3333333333333333 * x)))) - x) / abs(B)); else tmp = Float64(1.0 / sin(abs(B))); end return Float64(copysign(1.0, B) * tmp) end
function tmp_2 = code(B, x) tmp = 0.0; if (abs(B) <= 820000.0) tmp = ((1.0 + ((abs(B) ^ 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / abs(B); else tmp = 1.0 / sin(abs(B)); end tmp_2 = (sign(B) * abs(1.0)) * tmp; end
code[B_, x_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[B], $MachinePrecision], 820000.0], N[(N[(N[(1.0 + N[(N[Power[N[Abs[B], $MachinePrecision], 2.0], $MachinePrecision] * N[(0.16666666666666666 + N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Abs[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[N[Abs[B], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, B\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|B\right| \leq 820000:\\
\;\;\;\;\frac{\left(1 + {\left(\left|B\right|\right)}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{\left|B\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin \left(\left|B\right|\right)}\\
\end{array}
if B < 8.2e5Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6451.4%
Applied rewrites51.4%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6451.5%
Applied rewrites51.5%
if 8.2e5 < B Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6499.7%
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.8%
Applied rewrites99.8%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-tan.f64N/A
sub-flipN/A
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f6450.2%
Applied rewrites50.2%
(FPCore (B x) :precision binary64 (+ (/ (- (* 0.3333333333333333 (* (pow B 2.0) x)) x) B) (/ 1.0 B)))
double code(double B, double x) {
return (((0.3333333333333333 * (pow(B, 2.0) * x)) - x) / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (((0.3333333333333333d0 * ((b ** 2.0d0) * x)) - x) / b) + (1.0d0 / b)
end function
public static double code(double B, double x) {
return (((0.3333333333333333 * (Math.pow(B, 2.0) * x)) - x) / B) + (1.0 / B);
}
def code(B, x): return (((0.3333333333333333 * (math.pow(B, 2.0) * x)) - x) / B) + (1.0 / B)
function code(B, x) return Float64(Float64(Float64(Float64(0.3333333333333333 * Float64((B ^ 2.0) * x)) - x) / B) + Float64(1.0 / B)) end
function tmp = code(B, x) tmp = (((0.3333333333333333 * ((B ^ 2.0) * x)) - x) / B) + (1.0 / B); end
code[B_, x_] := N[(N[(N[(N[(0.3333333333333333 * N[(N[Power[B, 2.0], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]
\frac{0.3333333333333333 \cdot \left({B}^{2} \cdot x\right) - x}{B} + \frac{1}{B}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6460.3%
Applied rewrites60.3%
Taylor expanded in B around 0
lower-/.f6451.4%
Applied rewrites51.4%
(FPCore (B x) :precision binary64 (/ (- (+ 1.0 (* (pow B 2.0) (+ 0.16666666666666666 (* 0.3333333333333333 x)))) x) B))
double code(double B, double x) {
return ((1.0 + (pow(B, 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 + ((b ** 2.0d0) * (0.16666666666666666d0 + (0.3333333333333333d0 * x)))) - x) / b
end function
public static double code(double B, double x) {
return ((1.0 + (Math.pow(B, 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / B;
}
def code(B, x): return ((1.0 + (math.pow(B, 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / B
function code(B, x) return Float64(Float64(Float64(1.0 + Float64((B ^ 2.0) * Float64(0.16666666666666666 + Float64(0.3333333333333333 * x)))) - x) / B) end
function tmp = code(B, x) tmp = ((1.0 + ((B ^ 2.0) * (0.16666666666666666 + (0.3333333333333333 * x)))) - x) / B; end
code[B_, x_] := N[(N[(N[(1.0 + N[(N[Power[B, 2.0], $MachinePrecision] * N[(0.16666666666666666 + N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]
\frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6451.4%
Applied rewrites51.4%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6451.5%
Applied rewrites51.5%
(FPCore (B x) :precision binary64 (* (/ (+ 1.0 (* -0.3333333333333333 (pow B 2.0))) B) (- 1.0 x)))
double code(double B, double x) {
return ((1.0 + (-0.3333333333333333 * pow(B, 2.0))) / B) * (1.0 - x);
}
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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 + ((-0.3333333333333333d0) * (b ** 2.0d0))) / b) * (1.0d0 - x)
end function
public static double code(double B, double x) {
return ((1.0 + (-0.3333333333333333 * Math.pow(B, 2.0))) / B) * (1.0 - x);
}
def code(B, x): return ((1.0 + (-0.3333333333333333 * math.pow(B, 2.0))) / B) * (1.0 - x)
function code(B, x) return Float64(Float64(Float64(1.0 + Float64(-0.3333333333333333 * (B ^ 2.0))) / B) * Float64(1.0 - x)) end
function tmp = code(B, x) tmp = ((1.0 + (-0.3333333333333333 * (B ^ 2.0))) / B) * (1.0 - x); end
code[B_, x_] := N[(N[(N[(1.0 + N[(-0.3333333333333333 * N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\frac{1 + -0.3333333333333333 \cdot {B}^{2}}{B} \cdot \left(1 - x\right)
Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
sub-to-fractionN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites77.0%
lift-/.f64N/A
mult-flipN/A
lift-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-tan.f64N/A
lower-/.f6476.9%
Applied rewrites76.9%
Taylor expanded in B around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6451.3%
Applied rewrites51.3%
(FPCore (B x) :precision binary64 (/ (/ (* B (- 1.0 x)) B) B))
double code(double B, double x) {
return ((B * (1.0 - x)) / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((b * (1.0d0 - x)) / b) / b
end function
public static double code(double B, double x) {
return ((B * (1.0 - x)) / B) / B;
}
def code(B, x): return ((B * (1.0 - x)) / B) / B
function code(B, x) return Float64(Float64(Float64(B * Float64(1.0 - x)) / B) / B) end
function tmp = code(B, x) tmp = ((B * (1.0 - x)) / B) / B; end
code[B_, x_] := N[(N[(N[(B * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision] / B), $MachinePrecision]
\frac{\frac{B \cdot \left(1 - x\right)}{B}}{B}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6451.4%
Applied rewrites51.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6436.8%
lift-pow.f64N/A
unpow2N/A
lower-*.f6436.8%
Applied rewrites36.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6451.5%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
lift--.f64N/A
lower-*.f6451.5%
Applied rewrites51.5%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) B))
double code(double B, double x) {
return (1.0 - x) / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / b
end function
public static double code(double B, double x) {
return (1.0 - x) / B;
}
def code(B, x): return (1.0 - x) / B
function code(B, x) return Float64(Float64(1.0 - x) / B) end
function tmp = code(B, x) tmp = (1.0 - x) / B; end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]
\frac{1 - x}{B}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6451.4%
Applied rewrites51.4%
(FPCore (B x) :precision binary64 (/ (- x) B))
double code(double B, double x) {
return -x / 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(b, x)
use fmin_fmax_functions
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -x / b
end function
public static double code(double B, double x) {
return -x / B;
}
def code(B, x): return -x / B
function code(B, x) return Float64(Float64(-x) / B) end
function tmp = code(B, x) tmp = -x / B; end
code[B_, x_] := N[((-x) / B), $MachinePrecision]
\frac{-x}{B}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6451.4%
Applied rewrites51.4%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.3%
Applied rewrites51.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6427.0%
Applied rewrites27.0%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6427.0%
Applied rewrites27.0%
herbie shell --seed 2025212
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))