
(FPCore (F B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
double code(double F, double B, double x) {
return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x): return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
function code(F, B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0))))) end
function tmp = code(F, B, x) tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0))); end
code[F_, B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (F B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
double code(double F, double B, double x) {
return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x): return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
function code(F, B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0))))) end
function tmp = code(F, B, x) tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0))); end
code[F_, B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\end{array}
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -5e+129)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 1.6e-30)
(- (/ (* (pow (fma x 2.0 (fma F F 2.0)) -0.5) F) (sin B)) t_0)
(- (/ 1.0 (sin B)) t_0)))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -5e+129) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 1.6e-30) {
tmp = ((pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) * F) / sin(B)) - t_0;
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -5e+129) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 1.6e-30) tmp = Float64(Float64(Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) * F) / sin(B)) - t_0); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -5e+129], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 1.6e-30], N[(N[(N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] * F), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -5 \cdot 10^{+129}:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} \cdot F}{\sin B} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t\_0\\
\end{array}
\end{array}
if F < -5.0000000000000003e129Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -5.0000000000000003e129 < F < 1.6e-30Initial program 76.6%
Applied rewrites85.3%
if 1.6e-30 < F Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around inf
Applied rewrites55.4%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -3.1e+30)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 1.6e-30)
(- (* (pow (fma x 2.0 (fma F F 2.0)) -0.5) (/ F (sin B))) t_0)
(- (/ 1.0 (sin B)) t_0)))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -3.1e+30) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 1.6e-30) {
tmp = (pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) * (F / sin(B))) - t_0;
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -3.1e+30) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 1.6e-30) tmp = Float64(Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) * Float64(F / sin(B))) - t_0); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -3.1e+30], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 1.6e-30], N[(N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -3.1 \cdot 10^{+30}:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{-30}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} \cdot \frac{F}{\sin B} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t\_0\\
\end{array}
\end{array}
if F < -3.0999999999999998e30Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -3.0999999999999998e30 < F < 1.6e-30Initial program 76.6%
Applied rewrites85.3%
Applied rewrites76.7%
if 1.6e-30 < F Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around inf
Applied rewrites55.4%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -1.65)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 1.6e-30)
(- (/ (* (pow (fma x 2.0 2.0) -0.5) F) (sin B)) t_0)
(- (/ 1.0 (sin B)) t_0)))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -1.65) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 1.6e-30) {
tmp = ((pow(fma(x, 2.0, 2.0), -0.5) * F) / sin(B)) - t_0;
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -1.65) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 1.6e-30) tmp = Float64(Float64(Float64((fma(x, 2.0, 2.0) ^ -0.5) * F) / sin(B)) - t_0); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -1.65], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 1.6e-30], N[(N[(N[(N[Power[N[(x * 2.0 + 2.0), $MachinePrecision], -0.5], $MachinePrecision] * F), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -1.65:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, 2, 2\right)\right)}^{-0.5} \cdot F}{\sin B} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t\_0\\
\end{array}
\end{array}
if F < -1.6499999999999999Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -1.6499999999999999 < F < 1.6e-30Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around 0
Applied rewrites55.9%
if 1.6e-30 < F Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around inf
Applied rewrites55.4%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -2.5e-25)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 1.6e-30)
(/ (- (* F (pow (+ 2.0 (fma 2.0 x (pow F 2.0))) -0.5)) x) (tan B))
(- (/ 1.0 (sin B)) t_0)))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -2.5e-25) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 1.6e-30) {
tmp = ((F * pow((2.0 + fma(2.0, x, pow(F, 2.0))), -0.5)) - x) / tan(B);
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -2.5e-25) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 1.6e-30) tmp = Float64(Float64(Float64(F * (Float64(2.0 + fma(2.0, x, (F ^ 2.0))) ^ -0.5)) - x) / tan(B)); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.5e-25], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 1.6e-30], N[(N[(N[(F * N[Power[N[(2.0 + N[(2.0 * x + N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -2.5 \cdot 10^{-25}:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{F \cdot {\left(2 + \mathsf{fma}\left(2, x, {F}^{2}\right)\right)}^{-0.5} - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t\_0\\
\end{array}
\end{array}
if F < -2.49999999999999981e-25Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -2.49999999999999981e-25 < F < 1.6e-30Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in B around 0
Applied rewrites72.1%
if 1.6e-30 < F Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around inf
Applied rewrites55.4%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -2.5e-25)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 1.6e-30)
(- (/ (* (pow (fma x 2.0 (fma F F 2.0)) -0.5) F) B) t_0)
(- (/ 1.0 (sin B)) t_0)))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -2.5e-25) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 1.6e-30) {
tmp = ((pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) * F) / B) - t_0;
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -2.5e-25) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 1.6e-30) tmp = Float64(Float64(Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) * F) / B) - t_0); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.5e-25], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 1.6e-30], N[(N[(N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] * F), $MachinePrecision] / B), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -2.5 \cdot 10^{-25}:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} \cdot F}{B} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t\_0\\
\end{array}
\end{array}
if F < -2.49999999999999981e-25Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -2.49999999999999981e-25 < F < 1.6e-30Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in B around 0
Applied rewrites71.1%
if 1.6e-30 < F Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around inf
Applied rewrites55.4%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -2.5e-25)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 3e+271)
(- (/ (* (pow (fma x 2.0 (fma F F 2.0)) -0.5) F) B) t_0)
(/ 1.0 (sin B))))))
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -2.5e-25) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 3e+271) {
tmp = ((pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) * F) / B) - t_0;
} else {
tmp = 1.0 / sin(B);
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -2.5e-25) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 3e+271) tmp = Float64(Float64(Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) * F) / B) - t_0); else tmp = Float64(1.0 / sin(B)); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.5e-25], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 3e+271], N[(N[(N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] * F), $MachinePrecision] / B), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -2.5 \cdot 10^{-25}:\\
\;\;\;\;\frac{-1}{\sin B} - t\_0\\
\mathbf{elif}\;F \leq 3 \cdot 10^{+271}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} \cdot F}{B} - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -2.49999999999999981e-25Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in F around -inf
Applied rewrites55.0%
if -2.49999999999999981e-25 < F < 3e271Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in B around 0
Applied rewrites71.1%
if 3e271 < F Initial program 76.6%
Taylor expanded in F around inf
Applied rewrites17.1%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (pow (fma x 2.0 (fma F F 2.0)) -0.5))
(t_1 (- (/ (* t_0 F) B) (/ x (tan B)))))
(if (<= x -6.6e-100)
t_1
(if (<= x 4.3e-107) (fma F (/ t_0 (sin B)) (* -1.0 (/ x B))) t_1))))
double code(double F, double B, double x) {
double t_0 = pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5);
double t_1 = ((t_0 * F) / B) - (x / tan(B));
double tmp;
if (x <= -6.6e-100) {
tmp = t_1;
} else if (x <= 4.3e-107) {
tmp = fma(F, (t_0 / sin(B)), (-1.0 * (x / B)));
} else {
tmp = t_1;
}
return tmp;
}
function code(F, B, x) t_0 = fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5 t_1 = Float64(Float64(Float64(t_0 * F) / B) - Float64(x / tan(B))) tmp = 0.0 if (x <= -6.6e-100) tmp = t_1; elseif (x <= 4.3e-107) tmp = fma(F, Float64(t_0 / sin(B)), Float64(-1.0 * Float64(x / B))); else tmp = t_1; end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(t$95$0 * F), $MachinePrecision] / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e-100], t$95$1, If[LessEqual[x, 4.3e-107], N[(F * N[(t$95$0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}\\
t_1 := \frac{t\_0 \cdot F}{B} - \frac{x}{\tan B}\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{-100}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-107}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{t\_0}{\sin B}, -1 \cdot \frac{x}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -6.59999999999999993e-100 or 4.2999999999999997e-107 < x Initial program 76.6%
Applied rewrites85.3%
Taylor expanded in B around 0
Applied rewrites71.1%
if -6.59999999999999993e-100 < x < 4.2999999999999997e-107Initial program 76.6%
Applied rewrites85.2%
Taylor expanded in B around 0
Applied rewrites58.8%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ (* -1.0 x) (tan B))))
(if (<= x -7.2e-75)
t_0
(if (<= x 1.38e-101)
(fma
F
(/ (pow (fma x 2.0 (fma F F 2.0)) -0.5) (sin B))
(* -1.0 (/ x B)))
t_0))))
double code(double F, double B, double x) {
double t_0 = (-1.0 * x) / tan(B);
double tmp;
if (x <= -7.2e-75) {
tmp = t_0;
} else if (x <= 1.38e-101) {
tmp = fma(F, (pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) / sin(B)), (-1.0 * (x / B)));
} else {
tmp = t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(Float64(-1.0 * x) / tan(B)) tmp = 0.0 if (x <= -7.2e-75) tmp = t_0; elseif (x <= 1.38e-101) tmp = fma(F, Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) / sin(B)), Float64(-1.0 * Float64(x / B))); else tmp = t_0; end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[(-1.0 * x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.2e-75], t$95$0, If[LessEqual[x, 1.38e-101], N[(F * N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1 \cdot x}{\tan B}\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{-75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.38 \cdot 10^{-101}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}, -1 \cdot \frac{x}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.2000000000000001e-75 or 1.38e-101 < x Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in F around 0
Applied rewrites56.0%
if -7.2000000000000001e-75 < x < 1.38e-101Initial program 76.6%
Applied rewrites85.2%
Taylor expanded in B around 0
Applied rewrites58.8%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ (* -1.0 x) (tan B))))
(if (<= x -3e-103)
t_0
(if (<= x 4.25e-106) (* (/ (pow (fma F F 2.0) -0.5) (sin B)) F) t_0))))
double code(double F, double B, double x) {
double t_0 = (-1.0 * x) / tan(B);
double tmp;
if (x <= -3e-103) {
tmp = t_0;
} else if (x <= 4.25e-106) {
tmp = (pow(fma(F, F, 2.0), -0.5) / sin(B)) * F;
} else {
tmp = t_0;
}
return tmp;
}
function code(F, B, x) t_0 = Float64(Float64(-1.0 * x) / tan(B)) tmp = 0.0 if (x <= -3e-103) tmp = t_0; elseif (x <= 4.25e-106) tmp = Float64(Float64((fma(F, F, 2.0) ^ -0.5) / sin(B)) * F); else tmp = t_0; end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[(-1.0 * x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3e-103], t$95$0, If[LessEqual[x, 4.25e-106], N[(N[(N[Power[N[(F * F + 2.0), $MachinePrecision], -0.5], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1 \cdot x}{\tan B}\\
\mathbf{if}\;x \leq -3 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.25 \cdot 10^{-106}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-0.5}}{\sin B} \cdot F\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3e-103 or 4.2499999999999999e-106 < x Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in F around 0
Applied rewrites56.0%
if -3e-103 < x < 4.2499999999999999e-106Initial program 76.6%
Taylor expanded in x around 0
Applied rewrites30.7%
Applied rewrites30.7%
(FPCore (F B x) :precision binary64 (if (<= B 1.8e-5) (/ (- (* F (pow (+ 2.0 (fma 2.0 x (pow F 2.0))) -0.5)) x) B) (/ (* -1.0 x) (tan B))))
double code(double F, double B, double x) {
double tmp;
if (B <= 1.8e-5) {
tmp = ((F * pow((2.0 + fma(2.0, x, pow(F, 2.0))), -0.5)) - x) / B;
} else {
tmp = (-1.0 * x) / tan(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 1.8e-5) tmp = Float64(Float64(Float64(F * (Float64(2.0 + fma(2.0, x, (F ^ 2.0))) ^ -0.5)) - x) / B); else tmp = Float64(Float64(-1.0 * x) / tan(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 1.8e-5], N[(N[(N[(F * N[Power[N[(2.0 + N[(2.0 * x + N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(-1.0 * x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{F \cdot {\left(2 + \mathsf{fma}\left(2, x, {F}^{2}\right)\right)}^{-0.5} - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot x}{\tan B}\\
\end{array}
\end{array}
if B < 1.80000000000000005e-5Initial program 76.6%
Taylor expanded in B around 0
Applied rewrites45.3%
if 1.80000000000000005e-5 < B Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in F around 0
Applied rewrites56.0%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ (* -1.0 x) (tan B))))
(if (<= x -2.9e-118)
t_0
(if (<= x 4.1e-106)
(+
(* -1.0 (/ x B))
(* (/ F B) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0)))))
t_0))))
double code(double F, double B, double x) {
double t_0 = (-1.0 * x) / tan(B);
double tmp;
if (x <= -2.9e-118) {
tmp = t_0;
} else if (x <= 4.1e-106) {
tmp = (-1.0 * (x / B)) + ((F / B) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
} 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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
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.9d-118)) then
tmp = t_0
else if (x <= 4.1d-106) then
tmp = ((-1.0d0) * (x / b)) + ((f / b) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double t_0 = (-1.0 * x) / Math.tan(B);
double tmp;
if (x <= -2.9e-118) {
tmp = t_0;
} else if (x <= 4.1e-106) {
tmp = (-1.0 * (x / B)) + ((F / B) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(F, B, x): t_0 = (-1.0 * x) / math.tan(B) tmp = 0 if x <= -2.9e-118: tmp = t_0 elif x <= 4.1e-106: tmp = (-1.0 * (x / B)) + ((F / B) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0))) else: tmp = t_0 return tmp
function code(F, B, x) t_0 = Float64(Float64(-1.0 * x) / tan(B)) tmp = 0.0 if (x <= -2.9e-118) tmp = t_0; elseif (x <= 4.1e-106) tmp = Float64(Float64(-1.0 * Float64(x / B)) + Float64(Float64(F / B) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0))))); else tmp = t_0; end return tmp end
function tmp_2 = code(F, B, x) t_0 = (-1.0 * x) / tan(B); tmp = 0.0; if (x <= -2.9e-118) tmp = t_0; elseif (x <= 4.1e-106) tmp = (-1.0 * (x / B)) + ((F / B) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0))); else tmp = t_0; end tmp_2 = tmp; end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[(-1.0 * x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.9e-118], t$95$0, If[LessEqual[x, 4.1e-106], N[(N[(-1.0 * N[(x / B), $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1 \cdot x}{\tan B}\\
\mathbf{if}\;x \leq -2.9 \cdot 10^{-118}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-106}:\\
\;\;\;\;-1 \cdot \frac{x}{B} + \frac{F}{B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.8999999999999998e-118 or 4.0999999999999999e-106 < x Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in F around 0
Applied rewrites56.0%
if -2.8999999999999998e-118 < x < 4.0999999999999999e-106Initial program 76.6%
Taylor expanded in B around 0
Applied rewrites62.5%
Taylor expanded in B around 0
Applied rewrites36.8%
(FPCore (F B x) :precision binary64 (if (<= F 3.2e+45) (/ (* -1.0 x) (tan B)) (/ 1.0 (sin B))))
double code(double F, double B, double x) {
double tmp;
if (F <= 3.2e+45) {
tmp = (-1.0 * x) / tan(B);
} else {
tmp = 1.0 / sin(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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (f <= 3.2d+45) then
tmp = ((-1.0d0) * x) / tan(b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double tmp;
if (F <= 3.2e+45) {
tmp = (-1.0 * x) / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= 3.2e+45: tmp = (-1.0 * x) / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(F, B, x) tmp = 0.0 if (F <= 3.2e+45) tmp = Float64(Float64(-1.0 * x) / tan(B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(F, B, x) tmp = 0.0; if (F <= 3.2e+45) tmp = (-1.0 * x) / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, 3.2e+45], N[(N[(-1.0 * x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq 3.2 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1 \cdot x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if F < 3.2000000000000003e45Initial program 76.6%
Applied rewrites85.3%
Applied rewrites83.1%
Taylor expanded in F around 0
Applied rewrites56.0%
if 3.2000000000000003e45 < F Initial program 76.6%
Taylor expanded in F around inf
Applied rewrites17.1%
(FPCore (F B x)
:precision binary64
(if (<= F -85000000000000.0)
(/ -1.0 (sin B))
(if (<= F 3.8e+18)
(+ (- (/ x B)) (/ (* F (pow (+ 2.0 (* 2.0 x)) -0.5)) B))
(/ 1.0 (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -85000000000000.0) {
tmp = -1.0 / sin(B);
} else if (F <= 3.8e+18) {
tmp = -(x / B) + ((F * pow((2.0 + (2.0 * x)), -0.5)) / B);
} else {
tmp = 1.0 / sin(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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (f <= (-85000000000000.0d0)) then
tmp = (-1.0d0) / sin(b)
else if (f <= 3.8d+18) then
tmp = -(x / b) + ((f * ((2.0d0 + (2.0d0 * x)) ** (-0.5d0))) / b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double tmp;
if (F <= -85000000000000.0) {
tmp = -1.0 / Math.sin(B);
} else if (F <= 3.8e+18) {
tmp = -(x / B) + ((F * Math.pow((2.0 + (2.0 * x)), -0.5)) / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -85000000000000.0: tmp = -1.0 / math.sin(B) elif F <= 3.8e+18: tmp = -(x / B) + ((F * math.pow((2.0 + (2.0 * x)), -0.5)) / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(F, B, x) tmp = 0.0 if (F <= -85000000000000.0) tmp = Float64(-1.0 / sin(B)); elseif (F <= 3.8e+18) tmp = Float64(Float64(-Float64(x / B)) + Float64(Float64(F * (Float64(2.0 + Float64(2.0 * x)) ^ -0.5)) / B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(F, B, x) tmp = 0.0; if (F <= -85000000000000.0) tmp = -1.0 / sin(B); elseif (F <= 3.8e+18) tmp = -(x / B) + ((F * ((2.0 + (2.0 * x)) ^ -0.5)) / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -85000000000000.0], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 3.8e+18], N[((-N[(x / B), $MachinePrecision]) + N[(N[(F * N[Power[N[(2.0 + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -85000000000000:\\
\;\;\;\;\frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 3.8 \cdot 10^{+18}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{F \cdot {\left(2 + 2 \cdot x\right)}^{-0.5}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -8.5e13Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
if -8.5e13 < F < 3.8e18Initial program 76.6%
Taylor expanded in F around 0
Applied rewrites55.9%
Taylor expanded in B around 0
Applied rewrites50.6%
Taylor expanded in B around 0
Applied rewrites30.4%
if 3.8e18 < F Initial program 76.6%
Taylor expanded in F around inf
Applied rewrites17.1%
(FPCore (F B x)
:precision binary64
(if (<= F -85000000000000.0)
(/ -1.0 (sin B))
(if (<= F 1.6e+39)
(+ (- (/ x B)) (/ (* F (pow (+ 2.0 (* 2.0 x)) -0.5)) B))
(/ (- 1.0 (/ 1.0 (pow F 2.0))) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -85000000000000.0) {
tmp = -1.0 / sin(B);
} else if (F <= 1.6e+39) {
tmp = -(x / B) + ((F * pow((2.0 + (2.0 * x)), -0.5)) / B);
} else {
tmp = (1.0 - (1.0 / pow(F, 2.0))) / 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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (f <= (-85000000000000.0d0)) then
tmp = (-1.0d0) / sin(b)
else if (f <= 1.6d+39) then
tmp = -(x / b) + ((f * ((2.0d0 + (2.0d0 * x)) ** (-0.5d0))) / b)
else
tmp = (1.0d0 - (1.0d0 / (f ** 2.0d0))) / b
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double tmp;
if (F <= -85000000000000.0) {
tmp = -1.0 / Math.sin(B);
} else if (F <= 1.6e+39) {
tmp = -(x / B) + ((F * Math.pow((2.0 + (2.0 * x)), -0.5)) / B);
} else {
tmp = (1.0 - (1.0 / Math.pow(F, 2.0))) / B;
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -85000000000000.0: tmp = -1.0 / math.sin(B) elif F <= 1.6e+39: tmp = -(x / B) + ((F * math.pow((2.0 + (2.0 * x)), -0.5)) / B) else: tmp = (1.0 - (1.0 / math.pow(F, 2.0))) / B return tmp
function code(F, B, x) tmp = 0.0 if (F <= -85000000000000.0) tmp = Float64(-1.0 / sin(B)); elseif (F <= 1.6e+39) tmp = Float64(Float64(-Float64(x / B)) + Float64(Float64(F * (Float64(2.0 + Float64(2.0 * x)) ^ -0.5)) / B)); else tmp = Float64(Float64(1.0 - Float64(1.0 / (F ^ 2.0))) / B); end return tmp end
function tmp_2 = code(F, B, x) tmp = 0.0; if (F <= -85000000000000.0) tmp = -1.0 / sin(B); elseif (F <= 1.6e+39) tmp = -(x / B) + ((F * ((2.0 + (2.0 * x)) ^ -0.5)) / B); else tmp = (1.0 - (1.0 / (F ^ 2.0))) / B; end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -85000000000000.0], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 1.6e+39], N[((-N[(x / B), $MachinePrecision]) + N[(N[(F * N[Power[N[(2.0 + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(1.0 / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -85000000000000:\\
\;\;\;\;\frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{+39}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{F \cdot {\left(2 + 2 \cdot x\right)}^{-0.5}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{1}{{F}^{2}}}{B}\\
\end{array}
\end{array}
if F < -8.5e13Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
if -8.5e13 < F < 1.59999999999999996e39Initial program 76.6%
Taylor expanded in F around 0
Applied rewrites55.9%
Taylor expanded in B around 0
Applied rewrites50.6%
Taylor expanded in B around 0
Applied rewrites30.4%
if 1.59999999999999996e39 < F Initial program 76.6%
Taylor expanded in x around 0
Applied rewrites30.7%
Taylor expanded in F around inf
Applied rewrites17.3%
Applied rewrites20.2%
Taylor expanded in B around 0
Applied rewrites13.1%
(FPCore (F B x)
:precision binary64
(if (<= F -1.9e+132)
(fma (fma (* B -0.019444444444444445) B -0.16666666666666666) B (/ -1.0 B))
(if (<= F 1.6e+39)
(+ (- (/ x B)) (/ (* F (pow (+ 2.0 (* 2.0 x)) -0.5)) B))
(/ (- 1.0 (/ 1.0 (pow F 2.0))) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.9e+132) {
tmp = fma(fma((B * -0.019444444444444445), B, -0.16666666666666666), B, (-1.0 / B));
} else if (F <= 1.6e+39) {
tmp = -(x / B) + ((F * pow((2.0 + (2.0 * x)), -0.5)) / B);
} else {
tmp = (1.0 - (1.0 / pow(F, 2.0))) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.9e+132) tmp = fma(fma(Float64(B * -0.019444444444444445), B, -0.16666666666666666), B, Float64(-1.0 / B)); elseif (F <= 1.6e+39) tmp = Float64(Float64(-Float64(x / B)) + Float64(Float64(F * (Float64(2.0 + Float64(2.0 * x)) ^ -0.5)) / B)); else tmp = Float64(Float64(1.0 - Float64(1.0 / (F ^ 2.0))) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.9e+132], N[(N[(N[(B * -0.019444444444444445), $MachinePrecision] * B + -0.16666666666666666), $MachinePrecision] * B + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 1.6e+39], N[((-N[(x / B), $MachinePrecision]) + N[(N[(F * N[Power[N[(2.0 + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(1.0 / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.9 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(B \cdot -0.019444444444444445, B, -0.16666666666666666\right), B, \frac{-1}{B}\right)\\
\mathbf{elif}\;F \leq 1.6 \cdot 10^{+39}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{F \cdot {\left(2 + 2 \cdot x\right)}^{-0.5}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{1}{{F}^{2}}}{B}\\
\end{array}
\end{array}
if F < -1.90000000000000003e132Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
Taylor expanded in B around 0
Applied rewrites10.0%
Applied rewrites10.0%
if -1.90000000000000003e132 < F < 1.59999999999999996e39Initial program 76.6%
Taylor expanded in F around 0
Applied rewrites55.9%
Taylor expanded in B around 0
Applied rewrites50.6%
Taylor expanded in B around 0
Applied rewrites30.4%
if 1.59999999999999996e39 < F Initial program 76.6%
Taylor expanded in x around 0
Applied rewrites30.7%
Taylor expanded in F around inf
Applied rewrites17.3%
Applied rewrites20.2%
Taylor expanded in B around 0
Applied rewrites13.1%
(FPCore (F B x) :precision binary64 (if (<= F -5.7e+54) (fma (fma (* B -0.019444444444444445) B -0.16666666666666666) B (/ -1.0 B)) (/ (- 1.0 (/ 1.0 (pow F 2.0))) B)))
double code(double F, double B, double x) {
double tmp;
if (F <= -5.7e+54) {
tmp = fma(fma((B * -0.019444444444444445), B, -0.16666666666666666), B, (-1.0 / B));
} else {
tmp = (1.0 - (1.0 / pow(F, 2.0))) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -5.7e+54) tmp = fma(fma(Float64(B * -0.019444444444444445), B, -0.16666666666666666), B, Float64(-1.0 / B)); else tmp = Float64(Float64(1.0 - Float64(1.0 / (F ^ 2.0))) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -5.7e+54], N[(N[(N[(B * -0.019444444444444445), $MachinePrecision] * B + -0.16666666666666666), $MachinePrecision] * B + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(1.0 / N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5.7 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(B \cdot -0.019444444444444445, B, -0.16666666666666666\right), B, \frac{-1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{1}{{F}^{2}}}{B}\\
\end{array}
\end{array}
if F < -5.6999999999999997e54Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
Taylor expanded in B around 0
Applied rewrites10.0%
Applied rewrites10.0%
if -5.6999999999999997e54 < F Initial program 76.6%
Taylor expanded in x around 0
Applied rewrites30.7%
Taylor expanded in F around inf
Applied rewrites17.3%
Applied rewrites20.2%
Taylor expanded in B around 0
Applied rewrites13.1%
(FPCore (F B x) :precision binary64 (if (<= F -5.7e+54) (fma (fma (* B -0.019444444444444445) B -0.16666666666666666) B (/ -1.0 B)) (* F (* (/ (- 1.0 (/ 1.0 (* F F))) F) (/ 1.0 B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -5.7e+54) {
tmp = fma(fma((B * -0.019444444444444445), B, -0.16666666666666666), B, (-1.0 / B));
} else {
tmp = F * (((1.0 - (1.0 / (F * F))) / F) * (1.0 / B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -5.7e+54) tmp = fma(fma(Float64(B * -0.019444444444444445), B, -0.16666666666666666), B, Float64(-1.0 / B)); else tmp = Float64(F * Float64(Float64(Float64(1.0 - Float64(1.0 / Float64(F * F))) / F) * Float64(1.0 / B))); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -5.7e+54], N[(N[(N[(B * -0.019444444444444445), $MachinePrecision] * B + -0.16666666666666666), $MachinePrecision] * B + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], N[(F * N[(N[(N[(1.0 - N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5.7 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(B \cdot -0.019444444444444445, B, -0.16666666666666666\right), B, \frac{-1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;F \cdot \left(\frac{1 - \frac{1}{F \cdot F}}{F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if F < -5.6999999999999997e54Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
Taylor expanded in B around 0
Applied rewrites10.0%
Applied rewrites10.0%
if -5.6999999999999997e54 < F Initial program 76.6%
Taylor expanded in x around 0
Applied rewrites30.7%
Taylor expanded in F around inf
Applied rewrites17.3%
Applied rewrites20.2%
Taylor expanded in B around 0
Applied rewrites13.1%
(FPCore (F B x) :precision binary64 (/ -1.0 B))
double code(double F, double B, double x) {
return -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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (-1.0d0) / b
end function
public static double code(double F, double B, double x) {
return -1.0 / B;
}
def code(F, B, x): return -1.0 / B
function code(F, B, x) return Float64(-1.0 / B) end
function tmp = code(F, B, x) tmp = -1.0 / B; end
code[F_, B_, x_] := N[(-1.0 / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{B}
\end{array}
Initial program 76.6%
Taylor expanded in F around -inf
Applied rewrites17.2%
Taylor expanded in B around 0
Applied rewrites10.4%
herbie shell --seed 2025161
(FPCore (F B x)
:name "VandenBroeck and Keller, Equation (23)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))