
(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}
Sampling outcomes in binary64 precision:
Herbie found 26 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 (/ -1.0 (tan B)))))
(if (<= F -2.05e+115)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F 9.6e-21)
(fma
F
(/ (pow (fma 2.0 x (fma F F 2.0)) -0.5) (sin B))
(/ (- x) (tan B)))
(+ t_0 (/ 1.0 (sin B)))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -2.05e+115) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= 9.6e-21) {
tmp = fma(F, (pow(fma(2.0, x, fma(F, F, 2.0)), -0.5) / sin(B)), (-x / tan(B)));
} else {
tmp = t_0 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -2.05e+115) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= 9.6e-21) tmp = fma(F, Float64((fma(2.0, x, fma(F, F, 2.0)) ^ -0.5) / sin(B)), Float64(Float64(-x) / tan(B))); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.05e+115], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(F * N[(N[Power[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -2.05 \cdot 10^{+115}:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -2.04999999999999981e115Initial program 53.3%
Taylor expanded in F around -inf
Applied rewrites99.8%
if -2.04999999999999981e115 < F < 9.5999999999999997e-21Initial program 96.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.6%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification99.7%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= F -2.05e+115)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F 9.6e-21)
(fma
F
(/ (/ 1.0 (sqrt (fma x 2.0 (fma F F 2.0)))) (sin B))
(/ (- x) (tan B)))
(+ t_0 (/ 1.0 (sin B)))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -2.05e+115) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= 9.6e-21) {
tmp = fma(F, ((1.0 / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) / sin(B)), (-x / tan(B)));
} else {
tmp = t_0 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -2.05e+115) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= 9.6e-21) tmp = fma(F, Float64(Float64(1.0 / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) / sin(B)), Float64(Float64(-x) / tan(B))); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.05e+115], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(F * N[(N[(1.0 / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -2.05 \cdot 10^{+115}:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\frac{1}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}}{\sin B}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -2.04999999999999981e115Initial program 53.3%
Taylor expanded in F around -inf
Applied rewrites99.8%
if -2.04999999999999981e115 < F < 9.5999999999999997e-21Initial program 96.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.6%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.5
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification99.6%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= F -2.35e+31)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F 9.6e-21)
(+ t_0 (* (/ F (sin B)) (sqrt (/ 1.0 (fma F F 2.0)))))
(+ t_0 (/ 1.0 (sin B)))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -2.35e+31) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= 9.6e-21) {
tmp = t_0 + ((F / sin(B)) * sqrt((1.0 / fma(F, F, 2.0))));
} else {
tmp = t_0 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -2.35e+31) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= 9.6e-21) tmp = Float64(t_0 + Float64(Float64(F / sin(B)) * sqrt(Float64(1.0 / fma(F, F, 2.0))))); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.35e+31], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(t$95$0 + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -2.35 \cdot 10^{+31}:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;t\_0 + \frac{F}{\sin B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -2.3500000000000001e31Initial program 61.1%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -2.3500000000000001e31 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification99.6%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= F -2.0)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F 9.6e-21)
(/ (fma (sqrt (/ 1.0 (fma 2.0 x 2.0))) F (* (- x) (cos B))) (sin B))
(+ t_0 (/ 1.0 (sin B)))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -2.0) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= 9.6e-21) {
tmp = fma(sqrt((1.0 / fma(2.0, x, 2.0))), F, (-x * cos(B))) / sin(B);
} else {
tmp = t_0 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -2.0) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= 9.6e-21) tmp = Float64(fma(sqrt(Float64(1.0 / fma(2.0, x, 2.0))), F, Float64(Float64(-x) * cos(B))) / sin(B)); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -2.0], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F + N[((-x) * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -2:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{1}{\mathsf{fma}\left(2, x, 2\right)}}, F, \left(-x\right) \cdot \cos B\right)}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -2Initial program 63.3%
Taylor expanded in F around -inf
Applied rewrites99.3%
if -2 < F < 9.5999999999999997e-21Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.6%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.4
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.4
Applied rewrites99.4%
Taylor expanded in F around 0
Applied rewrites98.9%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification99.3%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= F -1.42)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F 9.6e-21)
(+ t_0 (* (/ F (sin B)) (sqrt 0.5)))
(+ t_0 (/ 1.0 (sin B)))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -1.42) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= 9.6e-21) {
tmp = t_0 + ((F / sin(B)) * sqrt(0.5));
} else {
tmp = t_0 + (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) :: t_0
real(8) :: tmp
t_0 = x * ((-1.0d0) / tan(b))
if (f <= (-1.42d0)) then
tmp = t_0 + ((-1.0d0) / sin(b))
else if (f <= 9.6d-21) then
tmp = t_0 + ((f / sin(b)) * sqrt(0.5d0))
else
tmp = t_0 + (1.0d0 / sin(b))
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double t_0 = x * (-1.0 / Math.tan(B));
double tmp;
if (F <= -1.42) {
tmp = t_0 + (-1.0 / Math.sin(B));
} else if (F <= 9.6e-21) {
tmp = t_0 + ((F / Math.sin(B)) * Math.sqrt(0.5));
} else {
tmp = t_0 + (1.0 / Math.sin(B));
}
return tmp;
}
def code(F, B, x): t_0 = x * (-1.0 / math.tan(B)) tmp = 0 if F <= -1.42: tmp = t_0 + (-1.0 / math.sin(B)) elif F <= 9.6e-21: tmp = t_0 + ((F / math.sin(B)) * math.sqrt(0.5)) else: tmp = t_0 + (1.0 / math.sin(B)) return tmp
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -1.42) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= 9.6e-21) tmp = Float64(t_0 + Float64(Float64(F / sin(B)) * sqrt(0.5))); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
function tmp_2 = code(F, B, x) t_0 = x * (-1.0 / tan(B)); tmp = 0.0; if (F <= -1.42) tmp = t_0 + (-1.0 / sin(B)); elseif (F <= 9.6e-21) tmp = t_0 + ((F / sin(B)) * sqrt(0.5)); else tmp = t_0 + (1.0 / sin(B)); end tmp_2 = tmp; end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -1.42], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(t$95$0 + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -1.42:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;t\_0 + \frac{F}{\sin B} \cdot \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -1.4199999999999999Initial program 63.3%
Taylor expanded in F around -inf
Applied rewrites99.3%
if -1.4199999999999999 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
Taylor expanded in F around 0
Applied rewrites98.8%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification99.3%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (fma 2.0 x (fma F F 2.0))) (t_1 (* x (/ -1.0 (tan B)))))
(if (<= F -1.28e+20)
(+ t_1 (/ -1.0 (sin B)))
(if (<= F -1.4e-128)
(fma F (/ (pow t_0 -0.5) (sin B)) (/ (- x) B))
(if (<= F 9.6e-21)
(+ (/ (- x) (tan B)) (* (/ F B) (sqrt (/ 1.0 t_0))))
(+ t_1 (/ 1.0 (sin B))))))))
double code(double F, double B, double x) {
double t_0 = fma(2.0, x, fma(F, F, 2.0));
double t_1 = x * (-1.0 / tan(B));
double tmp;
if (F <= -1.28e+20) {
tmp = t_1 + (-1.0 / sin(B));
} else if (F <= -1.4e-128) {
tmp = fma(F, (pow(t_0, -0.5) / sin(B)), (-x / B));
} else if (F <= 9.6e-21) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / t_0)));
} else {
tmp = t_1 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = fma(2.0, x, fma(F, F, 2.0)) t_1 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -1.28e+20) tmp = Float64(t_1 + Float64(-1.0 / sin(B))); elseif (F <= -1.4e-128) tmp = fma(F, Float64((t_0 ^ -0.5) / sin(B)), Float64(Float64(-x) / B)); elseif (F <= 9.6e-21) tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(Float64(F / B) * sqrt(Float64(1.0 / t_0)))); else tmp = Float64(t_1 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -1.28e+20], N[(t$95$1 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.4e-128], N[(F * N[(N[Power[t$95$0, -0.5], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\\
t_1 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;t\_1 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{{t\_0}^{-0.5}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{F}{B} \cdot \sqrt{\frac{1}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -1.28e20Initial program 61.7%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.28e20 < F < -1.3999999999999999e-128Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in B around 0
Applied rewrites91.5%
if -1.3999999999999999e-128 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites87.3%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
distribute-neg-fracN/A
*-rgt-identityN/A
lift-neg.f64N/A
lift-/.f6487.4
Applied rewrites87.4%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification94.8%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= F -1.28e+20)
(+ t_0 (/ -1.0 (sin B)))
(if (<= F -1.4e-128)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))
(if (<= F 9.6e-21)
(+
(/ (- x) (tan B))
(* (/ F B) (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(+ t_0 (/ 1.0 (sin B))))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (F <= -1.28e+20) {
tmp = t_0 + (-1.0 / sin(B));
} else if (F <= -1.4e-128) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
} else if (F <= 9.6e-21) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))));
} else {
tmp = t_0 + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (F <= -1.28e+20) tmp = Float64(t_0 + Float64(-1.0 / sin(B))); elseif (F <= -1.4e-128) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); elseif (F <= 9.6e-21) tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(Float64(F / B) * sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))))); else tmp = Float64(t_0 + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -1.28e+20], N[(t$95$0 + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.4e-128], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;F \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;t\_0 + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{F}{B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -1.28e20Initial program 61.7%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.28e20 < F < -1.3999999999999999e-128Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.0
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in B around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites91.5%
if -1.3999999999999999e-128 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites87.3%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
distribute-neg-fracN/A
*-rgt-identityN/A
lift-neg.f64N/A
lift-/.f6487.4
Applied rewrites87.4%
if 9.5999999999999997e-21 < F Initial program 60.7%
Taylor expanded in F around inf
Applied rewrites99.8%
Final simplification94.8%
(FPCore (F B x)
:precision binary64
(if (<= F -1.28e+20)
(+ (* x (/ -1.0 (tan B))) (/ -1.0 (sin B)))
(if (<= F -1.4e-128)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))
(if (<= F 9.6e-21)
(+
(/ (- x) (tan B))
(* (/ F B) (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(/ (fma (- x) (cos B) 1.0) (sin B))))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.28e+20) {
tmp = (x * (-1.0 / tan(B))) + (-1.0 / sin(B));
} else if (F <= -1.4e-128) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
} else if (F <= 9.6e-21) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))));
} else {
tmp = fma(-x, cos(B), 1.0) / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.28e+20) tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(-1.0 / sin(B))); elseif (F <= -1.4e-128) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); elseif (F <= 9.6e-21) tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(Float64(F / B) * sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))))); else tmp = Float64(fma(Float64(-x), cos(B), 1.0) / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.28e+20], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.4e-128], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) * N[Cos[B], $MachinePrecision] + 1.0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\
\mathbf{elif}\;F \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{F}{B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x, \cos B, 1\right)}{\sin B}\\
\end{array}
\end{array}
if F < -1.28e20Initial program 61.7%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.28e20 < F < -1.3999999999999999e-128Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.0
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in B around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites91.5%
if -1.3999999999999999e-128 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites87.3%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
distribute-neg-fracN/A
*-rgt-identityN/A
lift-neg.f64N/A
lift-/.f6487.4
Applied rewrites87.4%
if 9.5999999999999997e-21 < F Initial program 60.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites78.6%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6478.7
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6478.7
Applied rewrites78.7%
Taylor expanded in F around inf
Applied rewrites99.6%
Final simplification94.7%
(FPCore (F B x)
:precision binary64
(if (<= F -1.28e+20)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F -1.4e-128)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))
(if (<= F 9.6e-21)
(+
(/ (- x) (tan B))
(* (/ F B) (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(/ (fma (- x) (cos B) 1.0) (sin B))))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.28e+20) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= -1.4e-128) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
} else if (F <= 9.6e-21) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))));
} else {
tmp = fma(-x, cos(B), 1.0) / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.28e+20) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= -1.4e-128) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); elseif (F <= 9.6e-21) tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(Float64(F / B) * sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))))); else tmp = Float64(fma(Float64(-x), cos(B), 1.0) / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.28e+20], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.4e-128], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 9.6e-21], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) * N[Cos[B], $MachinePrecision] + 1.0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{elif}\;F \leq 9.6 \cdot 10^{-21}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{F}{B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x, \cos B, 1\right)}{\sin B}\\
\end{array}
\end{array}
if F < -1.28e20Initial program 61.7%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.28e20 < F < -1.3999999999999999e-128Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.0
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in B around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites91.5%
if -1.3999999999999999e-128 < F < 9.5999999999999997e-21Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites87.3%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
distribute-neg-fracN/A
*-rgt-identityN/A
lift-neg.f64N/A
lift-/.f6487.4
Applied rewrites87.4%
if 9.5999999999999997e-21 < F Initial program 60.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites78.6%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6478.7
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6478.7
Applied rewrites78.7%
Taylor expanded in F around inf
Applied rewrites99.6%
Final simplification94.7%
(FPCore (F B x)
:precision binary64
(if (<= F -1.28e+20)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F -1.4e-128)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))
(if (<= F 4.6e-25)
(+
(/ (- x) (tan B))
(* (/ F B) (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(+ (* x (/ -1.0 (tan B))) (/ 1.0 B))))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.28e+20) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= -1.4e-128) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
} else if (F <= 4.6e-25) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))));
} else {
tmp = (x * (-1.0 / tan(B))) + (1.0 / B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.28e+20) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= -1.4e-128) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); elseif (F <= 4.6e-25) tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(Float64(F / B) * sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))))); else tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(1.0 / B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.28e+20], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.4e-128], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 4.6e-25], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{elif}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{F}{B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{1}{B}\\
\end{array}
\end{array}
if F < -1.28e20Initial program 61.7%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.28e20 < F < -1.3999999999999999e-128Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6499.0
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in B around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites91.5%
if -1.3999999999999999e-128 < F < 4.5999999999999998e-25Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites87.2%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
distribute-neg-fracN/A
*-rgt-identityN/A
lift-neg.f64N/A
lift-/.f6487.3
Applied rewrites87.3%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites53.9%
Taylor expanded in F around inf
Applied rewrites78.8%
Final simplification88.3%
(FPCore (F B x)
:precision binary64
(if (or (<= x -3.1e-140) (not (<= x 2.2e-22)))
(fma
F
(* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) (/ 1.0 B))
(/ (- x) (tan B)))
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))))
double code(double F, double B, double x) {
double tmp;
if ((x <= -3.1e-140) || !(x <= 2.2e-22)) {
tmp = fma(F, (sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * (1.0 / B)), (-x / tan(B)));
} else {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if ((x <= -3.1e-140) || !(x <= 2.2e-22)) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * Float64(1.0 / B)), Float64(Float64(-x) / tan(B))); else tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); end return tmp end
code[F_, B_, x_] := If[Or[LessEqual[x, -3.1e-140], N[Not[LessEqual[x, 2.2e-22]], $MachinePrecision]], N[(F * N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-140} \lor \neg \left(x \leq 2.2 \cdot 10^{-22}\right):\\
\;\;\;\;\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{1}{B}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\end{array}
\end{array}
if x < -3.0999999999999999e-140 or 2.2000000000000001e-22 < x Initial program 82.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites95.4%
Taylor expanded in B around 0
Applied rewrites93.5%
if -3.0999999999999999e-140 < x < 2.2000000000000001e-22Initial program 72.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites79.0%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6478.9
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6478.9
Applied rewrites78.9%
Taylor expanded in B around 0
Applied rewrites67.8%
Taylor expanded in x around 0
Applied rewrites67.9%
Final simplification82.3%
(FPCore (F B x) :precision binary64 (if (or (<= x -3.1e-140) (not (<= x 1.6e-19))) (+ (* x (/ -1.0 (tan B))) (/ F (* B (sqrt (fma x 2.0 (fma F F 2.0)))))) (fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))))
double code(double F, double B, double x) {
double tmp;
if ((x <= -3.1e-140) || !(x <= 1.6e-19)) {
tmp = (x * (-1.0 / tan(B))) + (F / (B * sqrt(fma(x, 2.0, fma(F, F, 2.0)))));
} else {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if ((x <= -3.1e-140) || !(x <= 1.6e-19)) tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(F / Float64(B * sqrt(fma(x, 2.0, fma(F, F, 2.0)))))); else tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); end return tmp end
code[F_, B_, x_] := If[Or[LessEqual[x, -3.1e-140], N[Not[LessEqual[x, 1.6e-19]], $MachinePrecision]], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(F / N[(B * N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-140} \lor \neg \left(x \leq 1.6 \cdot 10^{-19}\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{F}{B \cdot \sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\end{array}
\end{array}
if x < -3.0999999999999999e-140 or 1.59999999999999991e-19 < x Initial program 82.1%
Taylor expanded in B around 0
Applied rewrites80.2%
Applied rewrites93.4%
if -3.0999999999999999e-140 < x < 1.59999999999999991e-19Initial program 72.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites79.0%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6478.9
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6478.9
Applied rewrites78.9%
Taylor expanded in B around 0
Applied rewrites67.8%
Taylor expanded in x around 0
Applied rewrites67.9%
Final simplification82.2%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* x (/ -1.0 (tan B)))))
(if (<= x -1.55e-27)
(+ t_0 (/ 1.0 B))
(if (<= x 27500000.0)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) B))
(+ t_0 (/ -1.0 B))))))
double code(double F, double B, double x) {
double t_0 = x * (-1.0 / tan(B));
double tmp;
if (x <= -1.55e-27) {
tmp = t_0 + (1.0 / B);
} else if (x <= 27500000.0) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / B));
} else {
tmp = t_0 + (-1.0 / B);
}
return tmp;
}
function code(F, B, x) t_0 = Float64(x * Float64(-1.0 / tan(B))) tmp = 0.0 if (x <= -1.55e-27) tmp = Float64(t_0 + Float64(1.0 / B)); elseif (x <= 27500000.0) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / B)); else tmp = Float64(t_0 + Float64(-1.0 / B)); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.55e-27], N[(t$95$0 + N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 27500000.0], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / B), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-1}{\tan B}\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{-27}:\\
\;\;\;\;t\_0 + \frac{1}{B}\\
\mathbf{elif}\;x \leq 27500000:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{-1}{B}\\
\end{array}
\end{array}
if x < -1.5499999999999999e-27Initial program 74.9%
Taylor expanded in B around 0
Applied rewrites74.9%
Taylor expanded in F around inf
Applied rewrites94.3%
if -1.5499999999999999e-27 < x < 2.75e7Initial program 73.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites79.3%
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6479.3
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6479.3
Applied rewrites79.3%
Taylor expanded in B around 0
Applied rewrites65.4%
Taylor expanded in x around 0
Applied rewrites65.4%
if 2.75e7 < x Initial program 87.8%
Taylor expanded in B around 0
Applied rewrites87.8%
Taylor expanded in F around -inf
Applied rewrites99.7%
Final simplification80.3%
(FPCore (F B x) :precision binary64 (if (or (<= x -5.4e-132) (not (<= x 1.15e-16))) (+ (* x (/ -1.0 (tan B))) (/ 1.0 B)) (/ F (* (sin B) (sqrt (fma F F 2.0))))))
double code(double F, double B, double x) {
double tmp;
if ((x <= -5.4e-132) || !(x <= 1.15e-16)) {
tmp = (x * (-1.0 / tan(B))) + (1.0 / B);
} else {
tmp = F / (sin(B) * sqrt(fma(F, F, 2.0)));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if ((x <= -5.4e-132) || !(x <= 1.15e-16)) tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(1.0 / B)); else tmp = Float64(F / Float64(sin(B) * sqrt(fma(F, F, 2.0)))); end return tmp end
code[F_, B_, x_] := If[Or[LessEqual[x, -5.4e-132], N[Not[LessEqual[x, 1.15e-16]], $MachinePrecision]], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision], N[(F / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{-132} \lor \neg \left(x \leq 1.15 \cdot 10^{-16}\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{F}{\sin B \cdot \sqrt{\mathsf{fma}\left(F, F, 2\right)}}\\
\end{array}
\end{array}
if x < -5.3999999999999998e-132 or 1.15e-16 < x Initial program 81.8%
Taylor expanded in B around 0
Applied rewrites80.5%
Taylor expanded in F around inf
Applied rewrites88.5%
if -5.3999999999999998e-132 < x < 1.15e-16Initial program 72.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites79.5%
Taylor expanded in x around 0
Applied rewrites51.3%
Applied rewrites57.7%
Final simplification74.7%
(FPCore (F B x) :precision binary64 (if (<= B 1.85e+24) (/ (- (/ F (sqrt (fma x 2.0 (fma F F 2.0)))) x) B) (if (<= B 1.25e+229) (/ (* (sqrt 0.5) F) (sin B)) (/ -1.0 (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (B <= 1.85e+24) {
tmp = ((F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B;
} else if (B <= 1.25e+229) {
tmp = (sqrt(0.5) * F) / sin(B);
} else {
tmp = -1.0 / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 1.85e+24) tmp = Float64(Float64(Float64(F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B); elseif (B <= 1.25e+229) tmp = Float64(Float64(sqrt(0.5) * F) / sin(B)); else tmp = Float64(-1.0 / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 1.85e+24], N[(N[(N[(F / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, 1.25e+229], N[(N[(N[Sqrt[0.5], $MachinePrecision] * F), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.85 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - x}{B}\\
\mathbf{elif}\;B \leq 1.25 \cdot 10^{+229}:\\
\;\;\;\;\frac{\sqrt{0.5} \cdot F}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sin B}\\
\end{array}
\end{array}
if B < 1.85e24Initial program 74.3%
Taylor expanded in B around 0
Applied rewrites54.0%
Applied rewrites54.0%
if 1.85e24 < B < 1.25000000000000012e229Initial program 87.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites87.3%
Taylor expanded in x around 0
Applied rewrites30.1%
Taylor expanded in F around 0
Applied rewrites19.6%
if 1.25000000000000012e229 < B Initial program 92.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites91.9%
Taylor expanded in x around 0
Applied rewrites32.5%
Taylor expanded in F around -inf
Applied rewrites19.6%
Final simplification45.5%
(FPCore (F B x) :precision binary64 (if (<= B 2.75e-21) (/ (- (/ F (sqrt (fma x 2.0 (fma F F 2.0)))) x) B) (+ (* x (/ -1.0 (tan B))) (/ -1.0 B))))
double code(double F, double B, double x) {
double tmp;
if (B <= 2.75e-21) {
tmp = ((F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B;
} else {
tmp = (x * (-1.0 / tan(B))) + (-1.0 / B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 2.75e-21) tmp = Float64(Float64(Float64(F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B); else tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(-1.0 / B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 2.75e-21], N[(N[(N[(F / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.75 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - x}{B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{B}\\
\end{array}
\end{array}
if B < 2.74999999999999989e-21Initial program 74.0%
Taylor expanded in B around 0
Applied rewrites55.7%
Applied rewrites55.7%
if 2.74999999999999989e-21 < B Initial program 87.2%
Taylor expanded in B around 0
Applied rewrites62.4%
Taylor expanded in F around -inf
Applied rewrites57.0%
Final simplification56.1%
(FPCore (F B x)
:precision binary64
(if (<= B 3.7e+18)
(/
(-
(fma
(sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))
(fma (* 0.16666666666666666 F) (* B B) F)
(* (* 0.3333333333333333 (* B B)) x))
x)
B)
(if (<= B 3.8e+216) (/ 1.0 (sin B)) (/ -1.0 (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (B <= 3.7e+18) {
tmp = (fma(sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))), fma((0.16666666666666666 * F), (B * B), F), ((0.3333333333333333 * (B * B)) * x)) - x) / B;
} else if (B <= 3.8e+216) {
tmp = 1.0 / sin(B);
} else {
tmp = -1.0 / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 3.7e+18) tmp = Float64(Float64(fma(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))), fma(Float64(0.16666666666666666 * F), Float64(B * B), F), Float64(Float64(0.3333333333333333 * Float64(B * B)) * x)) - x) / B); elseif (B <= 3.8e+216) tmp = Float64(1.0 / sin(B)); else tmp = Float64(-1.0 / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 3.7e+18], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(0.16666666666666666 * F), $MachinePrecision] * N[(B * B), $MachinePrecision] + F), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(B * B), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, 3.8e+216], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.7 \cdot 10^{+18}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \mathsf{fma}\left(0.16666666666666666 \cdot F, B \cdot B, F\right), \left(0.3333333333333333 \cdot \left(B \cdot B\right)\right) \cdot x\right) - x}{B}\\
\mathbf{elif}\;B \leq 3.8 \cdot 10^{+216}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sin B}\\
\end{array}
\end{array}
if B < 3.7e18Initial program 74.6%
Taylor expanded in B around 0
Applied rewrites54.0%
if 3.7e18 < B < 3.80000000000000014e216Initial program 84.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites27.6%
Taylor expanded in F around inf
Applied rewrites21.4%
if 3.80000000000000014e216 < B Initial program 94.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites93.9%
Taylor expanded in x around 0
Applied rewrites35.2%
Taylor expanded in F around -inf
Applied rewrites15.5%
Final simplification45.3%
(FPCore (F B x) :precision binary64 (if (<= B 8.2e+24) (/ (- (/ F (sqrt (fma x 2.0 (fma F F 2.0)))) x) B) (/ -1.0 (sin B))))
double code(double F, double B, double x) {
double tmp;
if (B <= 8.2e+24) {
tmp = ((F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B;
} else {
tmp = -1.0 / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 8.2e+24) tmp = Float64(Float64(Float64(F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B); else tmp = Float64(-1.0 / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 8.2e+24], N[(N[(N[(F / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 8.2 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sin B}\\
\end{array}
\end{array}
if B < 8.2000000000000002e24Initial program 74.4%
Taylor expanded in B around 0
Applied rewrites53.7%
Applied rewrites53.8%
if 8.2000000000000002e24 < B Initial program 88.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites88.1%
Taylor expanded in x around 0
Applied rewrites29.5%
Taylor expanded in F around -inf
Applied rewrites12.4%
Final simplification43.7%
(FPCore (F B x)
:precision binary64
(if (<= F -4.9e-11)
(/ (- -1.0 x) B)
(if (<= F 4.6e-25)
(/ (fma (sqrt (/ 1.0 (fma 2.0 x 2.0))) F (- x)) B)
(/ (- (fma (/ -0.5 F) (/ (fma 2.0 x 2.0) F) 1.0) x) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -4.9e-11) {
tmp = (-1.0 - x) / B;
} else if (F <= 4.6e-25) {
tmp = fma(sqrt((1.0 / fma(2.0, x, 2.0))), F, -x) / B;
} else {
tmp = (fma((-0.5 / F), (fma(2.0, x, 2.0) / F), 1.0) - x) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -4.9e-11) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 4.6e-25) tmp = Float64(fma(sqrt(Float64(1.0 / fma(2.0, x, 2.0))), F, Float64(-x)) / B); else tmp = Float64(Float64(fma(Float64(-0.5 / F), Float64(fma(2.0, x, 2.0) / F), 1.0) - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -4.9e-11], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 4.6e-25], N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F + (-x)), $MachinePrecision] / B), $MachinePrecision], N[(N[(N[(N[(-0.5 / F), $MachinePrecision] * N[(N[(2.0 * x + 2.0), $MachinePrecision] / F), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -4.9 \cdot 10^{-11}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{1}{\mathsf{fma}\left(2, x, 2\right)}}, F, -x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-0.5}{F}, \frac{\mathsf{fma}\left(2, x, 2\right)}{F}, 1\right) - x}{B}\\
\end{array}
\end{array}
if F < -4.8999999999999999e-11Initial program 64.8%
Taylor expanded in B around 0
Applied rewrites36.5%
Taylor expanded in F around -inf
Applied rewrites41.8%
if -4.8999999999999999e-11 < F < 4.5999999999999998e-25Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites43.7%
Taylor expanded in F around 0
Applied rewrites43.7%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around inf
Applied rewrites50.9%
(FPCore (F B x)
:precision binary64
(if (<= F -4.9e-11)
(/ (- -1.0 x) B)
(if (<= F 4.6e-25)
(/ (fma (sqrt (/ 1.0 (fma 2.0 x 2.0))) F (- x)) B)
(/ (- 1.0 x) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -4.9e-11) {
tmp = (-1.0 - x) / B;
} else if (F <= 4.6e-25) {
tmp = fma(sqrt((1.0 / fma(2.0, x, 2.0))), F, -x) / B;
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -4.9e-11) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 4.6e-25) tmp = Float64(fma(sqrt(Float64(1.0 / fma(2.0, x, 2.0))), F, Float64(-x)) / B); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -4.9e-11], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 4.6e-25], N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F + (-x)), $MachinePrecision] / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -4.9 \cdot 10^{-11}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{1}{\mathsf{fma}\left(2, x, 2\right)}}, F, -x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if F < -4.8999999999999999e-11Initial program 64.8%
Taylor expanded in B around 0
Applied rewrites36.5%
Taylor expanded in F around -inf
Applied rewrites41.8%
if -4.8999999999999999e-11 < F < 4.5999999999999998e-25Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites43.7%
Taylor expanded in F around 0
Applied rewrites43.7%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around inf
Applied rewrites50.8%
(FPCore (F B x) :precision binary64 (if (<= F 4.6e-25) (/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B) (/ (- (fma (/ -0.5 F) (/ (fma 2.0 x 2.0) F) 1.0) x) B)))
double code(double F, double B, double x) {
double tmp;
if (F <= 4.6e-25) {
tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
} else {
tmp = (fma((-0.5 / F), (fma(2.0, x, 2.0) / F), 1.0) - x) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= 4.6e-25) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B); else tmp = Float64(Float64(fma(Float64(-0.5 / F), Float64(fma(2.0, x, 2.0) / F), 1.0) - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, 4.6e-25], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(N[(N[(-0.5 / F), $MachinePrecision] * N[(N[(2.0 * x + 2.0), $MachinePrecision] / F), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-0.5}{F}, \frac{\mathsf{fma}\left(2, x, 2\right)}{F}, 1\right) - x}{B}\\
\end{array}
\end{array}
if F < 4.5999999999999998e-25Initial program 85.2%
Taylor expanded in B around 0
Applied rewrites40.7%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around inf
Applied rewrites50.9%
(FPCore (F B x) :precision binary64 (if (<= F 4.6e-25) (/ (- (/ F (sqrt (fma x 2.0 (fma F F 2.0)))) x) B) (/ (- (fma (/ -0.5 F) (/ (fma 2.0 x 2.0) F) 1.0) x) B)))
double code(double F, double B, double x) {
double tmp;
if (F <= 4.6e-25) {
tmp = ((F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B;
} else {
tmp = (fma((-0.5 / F), (fma(2.0, x, 2.0) / F), 1.0) - x) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= 4.6e-25) tmp = Float64(Float64(Float64(F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B); else tmp = Float64(Float64(fma(Float64(-0.5 / F), Float64(fma(2.0, x, 2.0) / F), 1.0) - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, 4.6e-25], N[(N[(N[(F / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(N[(N[(-0.5 / F), $MachinePrecision] * N[(N[(2.0 * x + 2.0), $MachinePrecision] / F), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-0.5}{F}, \frac{\mathsf{fma}\left(2, x, 2\right)}{F}, 1\right) - x}{B}\\
\end{array}
\end{array}
if F < 4.5999999999999998e-25Initial program 85.2%
Taylor expanded in B around 0
Applied rewrites40.7%
Applied rewrites40.7%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around inf
Applied rewrites50.9%
Final simplification43.9%
(FPCore (F B x) :precision binary64 (if (<= F -4.9e-11) (/ (- -1.0 x) B) (if (<= F 4.6e-25) (/ (fma (sqrt 0.5) F (- x)) B) (/ (- 1.0 x) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -4.9e-11) {
tmp = (-1.0 - x) / B;
} else if (F <= 4.6e-25) {
tmp = fma(sqrt(0.5), F, -x) / B;
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -4.9e-11) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 4.6e-25) tmp = Float64(fma(sqrt(0.5), F, Float64(-x)) / B); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -4.9e-11], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 4.6e-25], N[(N[(N[Sqrt[0.5], $MachinePrecision] * F + (-x)), $MachinePrecision] / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -4.9 \cdot 10^{-11}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 4.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{0.5}, F, -x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if F < -4.8999999999999999e-11Initial program 64.8%
Taylor expanded in B around 0
Applied rewrites36.5%
Taylor expanded in F around -inf
Applied rewrites41.8%
if -4.8999999999999999e-11 < F < 4.5999999999999998e-25Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites43.7%
Taylor expanded in F around 0
Applied rewrites43.7%
Taylor expanded in x around 0
Applied rewrites43.7%
if 4.5999999999999998e-25 < F Initial program 61.2%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around inf
Applied rewrites50.8%
(FPCore (F B x) :precision binary64 (if (<= F -2.2e-19) (/ (- -1.0 x) B) (if (<= F 1.8e-168) (/ (- x) B) (/ (- 1.0 x) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -2.2e-19) {
tmp = (-1.0 - x) / B;
} else if (F <= 1.8e-168) {
tmp = -x / B;
} else {
tmp = (1.0 - x) / 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 <= (-2.2d-19)) then
tmp = ((-1.0d0) - x) / b
else if (f <= 1.8d-168) then
tmp = -x / b
else
tmp = (1.0d0 - x) / b
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double tmp;
if (F <= -2.2e-19) {
tmp = (-1.0 - x) / B;
} else if (F <= 1.8e-168) {
tmp = -x / B;
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -2.2e-19: tmp = (-1.0 - x) / B elif F <= 1.8e-168: tmp = -x / B else: tmp = (1.0 - x) / B return tmp
function code(F, B, x) tmp = 0.0 if (F <= -2.2e-19) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 1.8e-168) tmp = Float64(Float64(-x) / B); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
function tmp_2 = code(F, B, x) tmp = 0.0; if (F <= -2.2e-19) tmp = (-1.0 - x) / B; elseif (F <= 1.8e-168) tmp = -x / B; else tmp = (1.0 - x) / B; end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -2.2e-19], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 1.8e-168], N[((-x) / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.2 \cdot 10^{-19}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 1.8 \cdot 10^{-168}:\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if F < -2.1999999999999998e-19Initial program 64.8%
Taylor expanded in B around 0
Applied rewrites36.5%
Taylor expanded in F around -inf
Applied rewrites41.8%
if -2.1999999999999998e-19 < F < 1.7999999999999999e-168Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites46.9%
Taylor expanded in F around 0
Applied rewrites35.3%
if 1.7999999999999999e-168 < F Initial program 69.2%
Taylor expanded in B around 0
Applied rewrites40.9%
Taylor expanded in F around inf
Applied rewrites43.9%
(FPCore (F B x) :precision binary64 (if (<= F -2.2e-19) (/ (- -1.0 x) B) (/ (- x) B)))
double code(double F, double B, double x) {
double tmp;
if (F <= -2.2e-19) {
tmp = (-1.0 - x) / B;
} else {
tmp = -x / 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 <= (-2.2d-19)) then
tmp = ((-1.0d0) - x) / b
else
tmp = -x / b
end if
code = tmp
end function
public static double code(double F, double B, double x) {
double tmp;
if (F <= -2.2e-19) {
tmp = (-1.0 - x) / B;
} else {
tmp = -x / B;
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -2.2e-19: tmp = (-1.0 - x) / B else: tmp = -x / B return tmp
function code(F, B, x) tmp = 0.0 if (F <= -2.2e-19) tmp = Float64(Float64(-1.0 - x) / B); else tmp = Float64(Float64(-x) / B); end return tmp end
function tmp_2 = code(F, B, x) tmp = 0.0; if (F <= -2.2e-19) tmp = (-1.0 - x) / B; else tmp = -x / B; end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -2.2e-19], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[((-x) / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.2 \cdot 10^{-19}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{B}\\
\end{array}
\end{array}
if F < -2.1999999999999998e-19Initial program 64.8%
Taylor expanded in B around 0
Applied rewrites36.5%
Taylor expanded in F around -inf
Applied rewrites41.8%
if -2.1999999999999998e-19 < F Initial program 82.9%
Taylor expanded in B around 0
Applied rewrites43.6%
Taylor expanded in F around 0
Applied rewrites31.2%
(FPCore (F B x) :precision binary64 (/ (- x) B))
double code(double F, 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(f, b, x)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -x / b
end function
public static double code(double F, double B, double x) {
return -x / B;
}
def code(F, B, x): return -x / B
function code(F, B, x) return Float64(Float64(-x) / B) end
function tmp = code(F, B, x) tmp = -x / B; end
code[F_, B_, x_] := N[((-x) / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{-x}{B}
\end{array}
Initial program 77.8%
Taylor expanded in B around 0
Applied rewrites41.6%
Taylor expanded in F around 0
Applied rewrites29.0%
herbie shell --seed 2025019
(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))))))