
(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 17 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
(if (<= F -1.1e+27)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F 5.8e-6)
(fma F (/ (sqrt (/ 1.0 (fma F F 2.0))) (sin B)) (/ (- x) (tan B)))
(/ (fma -1.0 (* (cos B) x) 1.0) (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.1e+27) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= 5.8e-6) {
tmp = fma(F, (sqrt((1.0 / fma(F, F, 2.0))) / sin(B)), (-x / tan(B)));
} else {
tmp = fma(-1.0, (cos(B) * x), 1.0) / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.1e+27) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= 5.8e-6) tmp = fma(F, Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / sin(B)), Float64(Float64(-x) / tan(B))); else tmp = Float64(fma(-1.0, Float64(cos(B) * x), 1.0) / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.1e+27], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 5.8e-6], N[(F * N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.1 \cdot 10^{+27}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \cos B \cdot x, 1\right)}{\sin B}\\
\end{array}
\end{array}
if F < -1.0999999999999999e27Initial program 54.1%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.0999999999999999e27 < F < 5.8000000000000004e-6Initial 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.7%
Taylor expanded in x around 0
Applied rewrites99.7%
if 5.8000000000000004e-6 < F Initial program 60.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 rewrites82.7%
Taylor expanded in F around inf
Applied rewrites99.9%
Final simplification99.8%
(FPCore (F B x)
:precision binary64
(if (<= F -1.4)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F 5.8e-6)
(fma F (/ (sqrt 0.5) (sin B)) (/ (- x) (tan B)))
(/ (fma -1.0 (* (cos B) x) 1.0) (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.4) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= 5.8e-6) {
tmp = fma(F, (sqrt(0.5) / sin(B)), (-x / tan(B)));
} else {
tmp = fma(-1.0, (cos(B) * x), 1.0) / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.4) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= 5.8e-6) tmp = fma(F, Float64(sqrt(0.5) / sin(B)), Float64(Float64(-x) / tan(B))); else tmp = Float64(fma(-1.0, Float64(cos(B) * x), 1.0) / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.4], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 5.8e-6], N[(F * N[(N[Sqrt[0.5], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.4:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{\sqrt{0.5}}{\sin B}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \cos B \cdot x, 1\right)}{\sin B}\\
\end{array}
\end{array}
if F < -1.3999999999999999Initial program 56.1%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -1.3999999999999999 < F < 5.8000000000000004e-6Initial 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.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Taylor expanded in F around 0
Applied rewrites99.7%
if 5.8000000000000004e-6 < F Initial program 60.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 rewrites82.7%
Taylor expanded in F around inf
Applied rewrites99.9%
Final simplification99.8%
(FPCore (F B x)
:precision binary64
(if (<= F -6300.0)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F 5.8e-6)
(+ (/ (- x) (tan B)) (* (/ F B) (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(/ (fma -1.0 (* (cos B) x) 1.0) (sin B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -6300.0) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= 5.8e-6) {
tmp = (-x / tan(B)) + ((F / B) * sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))));
} else {
tmp = fma(-1.0, (cos(B) * x), 1.0) / sin(B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -6300.0) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= 5.8e-6) 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(-1.0, Float64(cos(B) * x), 1.0) / sin(B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -6300.0], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 5.8e-6], 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[(-1.0 * N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -6300:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;\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(-1, \cos B \cdot x, 1\right)}{\sin B}\\
\end{array}
\end{array}
if F < -6300Initial program 56.1%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -6300 < F < 5.8000000000000004e-6Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites82.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-/.f6482.3
Applied rewrites82.3%
if 5.8000000000000004e-6 < F Initial program 60.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 rewrites82.7%
Taylor expanded in F around inf
Applied rewrites99.9%
Final simplification91.5%
(FPCore (F B x)
:precision binary64
(if (<= F -6300.0)
(/ (- (fma (cos B) x 1.0)) (sin B))
(if (<= F 1.55e+152)
(+ (* x (/ -1.0 (tan B))) (/ F (* B (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 (F <= -6300.0) {
tmp = -fma(cos(B), x, 1.0) / sin(B);
} else if (F <= 1.55e+152) {
tmp = (x * (-1.0 / tan(B))) + (F / (B * sqrt(fma(x, 2.0, fma(F, F, 2.0)))));
} else {
tmp = -(x / B) + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -6300.0) tmp = Float64(Float64(-fma(cos(B), x, 1.0)) / sin(B)); elseif (F <= 1.55e+152) 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 = Float64(Float64(-Float64(x / B)) + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -6300.0], N[((-N[(N[Cos[B], $MachinePrecision] * x + 1.0), $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 1.55e+152], 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[((-N[(x / B), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -6300:\\
\;\;\;\;\frac{-\mathsf{fma}\left(\cos B, x, 1\right)}{\sin B}\\
\mathbf{elif}\;F \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;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}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -6300Initial program 56.1%
Taylor expanded in F around -inf
Applied rewrites99.7%
if -6300 < F < 1.55e152Initial program 97.1%
Taylor expanded in B around 0
Applied rewrites81.0%
Applied rewrites83.4%
if 1.55e152 < F Initial program 20.1%
Taylor expanded in F around inf
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites79.1%
Final simplification87.2%
(FPCore (F B x)
:precision binary64
(if (<= F -1.9e+126)
(fma F (/ -1.0 (* B F)) (/ (- x) (tan B)))
(if (<= F -9e+88)
(* (sqrt (/ 1.0 (fma F F 2.0))) (/ F (sin B)))
(if (<= F 1.55e+152)
(+ (* x (/ -1.0 (tan B))) (/ F (* B (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 (F <= -1.9e+126) {
tmp = fma(F, (-1.0 / (B * F)), (-x / tan(B)));
} else if (F <= -9e+88) {
tmp = sqrt((1.0 / fma(F, F, 2.0))) * (F / sin(B));
} else if (F <= 1.55e+152) {
tmp = (x * (-1.0 / tan(B))) + (F / (B * sqrt(fma(x, 2.0, fma(F, F, 2.0)))));
} else {
tmp = -(x / B) + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.9e+126) tmp = fma(F, Float64(-1.0 / Float64(B * F)), Float64(Float64(-x) / tan(B))); elseif (F <= -9e+88) tmp = Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) * Float64(F / sin(B))); elseif (F <= 1.55e+152) 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 = Float64(Float64(-Float64(x / B)) + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.9e+126], N[(F * N[(-1.0 / N[(B * F), $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -9e+88], N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 1.55e+152], 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[((-N[(x / B), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.9 \cdot 10^{+126}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{-1}{B \cdot F}, \frac{-x}{\tan B}\right)\\
\mathbf{elif}\;F \leq -9 \cdot 10^{+88}:\\
\;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\
\mathbf{elif}\;F \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;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}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -1.90000000000000008e126Initial program 41.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites58.8%
Taylor expanded in F around -inf
Applied rewrites99.6%
Taylor expanded in B around 0
Applied rewrites79.3%
if -1.90000000000000008e126 < F < -9e88Initial program 99.3%
Taylor expanded in x around 0
Applied rewrites82.2%
if -9e88 < F < 1.55e152Initial program 96.3%
Taylor expanded in B around 0
Applied rewrites80.1%
Applied rewrites83.3%
if 1.55e152 < F Initial program 20.1%
Taylor expanded in F around inf
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites79.1%
Final simplification82.1%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (* (* B B) F)) (t_1 (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(if (<= B 1.24e+14)
(/
(-
(fma
t_1
(fma t_0 0.16666666666666666 F)
(*
(fma
(fma (* (- F) -0.019444444444444445) t_1 (* x 0.022222222222222223))
(* B B)
(* 0.3333333333333333 x))
(* B B)))
x)
B)
(fma
F
(/ -1.0 (* (fma t_0 -0.16666666666666666 F) B))
(/ (- x) (tan B))))))
double code(double F, double B, double x) {
double t_0 = (B * B) * F;
double t_1 = sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0))));
double tmp;
if (B <= 1.24e+14) {
tmp = (fma(t_1, fma(t_0, 0.16666666666666666, F), (fma(fma((-F * -0.019444444444444445), t_1, (x * 0.022222222222222223)), (B * B), (0.3333333333333333 * x)) * (B * B))) - x) / B;
} else {
tmp = fma(F, (-1.0 / (fma(t_0, -0.16666666666666666, F) * B)), (-x / tan(B)));
}
return tmp;
}
function code(F, B, x) t_0 = Float64(Float64(B * B) * F) t_1 = sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) tmp = 0.0 if (B <= 1.24e+14) tmp = Float64(Float64(fma(t_1, fma(t_0, 0.16666666666666666, F), Float64(fma(fma(Float64(Float64(-F) * -0.019444444444444445), t_1, Float64(x * 0.022222222222222223)), Float64(B * B), Float64(0.3333333333333333 * x)) * Float64(B * B))) - x) / B); else tmp = fma(F, Float64(-1.0 / Float64(fma(t_0, -0.16666666666666666, F) * B)), Float64(Float64(-x) / tan(B))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] * F), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, 1.24e+14], N[(N[(N[(t$95$1 * N[(t$95$0 * 0.16666666666666666 + F), $MachinePrecision] + N[(N[(N[(N[((-F) * -0.019444444444444445), $MachinePrecision] * t$95$1 + N[(x * 0.022222222222222223), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision] + N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(F * N[(-1.0 / N[(N[(t$95$0 * -0.16666666666666666 + F), $MachinePrecision] * B), $MachinePrecision]), $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(B \cdot B\right) \cdot F\\
t_1 := \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{if}\;B \leq 1.24 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_1, \mathsf{fma}\left(t\_0, 0.16666666666666666, F\right), \mathsf{fma}\left(\mathsf{fma}\left(\left(-F\right) \cdot -0.019444444444444445, t\_1, x \cdot 0.022222222222222223\right), B \cdot B, 0.3333333333333333 \cdot x\right) \cdot \left(B \cdot B\right)\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(F, \frac{-1}{\mathsf{fma}\left(t\_0, -0.16666666666666666, F\right) \cdot B}, \frac{-x}{\tan B}\right)\\
\end{array}
\end{array}
if B < 1.24e14Initial program 75.8%
Taylor expanded in B around 0
Applied rewrites63.5%
if 1.24e14 < B Initial program 85.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 rewrites85.9%
Taylor expanded in F around -inf
Applied rewrites54.8%
Taylor expanded in B around 0
Applied rewrites52.4%
Final simplification61.1%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(if (<= B 1.24e+14)
(/
(-
(fma
t_0
(fma (* (* B B) F) 0.16666666666666666 F)
(*
(fma
(fma (* (- F) -0.019444444444444445) t_0 (* x 0.022222222222222223))
(* B B)
(* 0.3333333333333333 x))
(* B B)))
x)
B)
(+ (* x (/ -1.0 (tan B))) (* (/ F B) (/ 1.0 F))))))
double code(double F, double B, double x) {
double t_0 = sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0))));
double tmp;
if (B <= 1.24e+14) {
tmp = (fma(t_0, fma(((B * B) * F), 0.16666666666666666, F), (fma(fma((-F * -0.019444444444444445), t_0, (x * 0.022222222222222223)), (B * B), (0.3333333333333333 * x)) * (B * B))) - x) / B;
} else {
tmp = (x * (-1.0 / tan(B))) + ((F / B) * (1.0 / F));
}
return tmp;
}
function code(F, B, x) t_0 = sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) tmp = 0.0 if (B <= 1.24e+14) tmp = Float64(Float64(fma(t_0, fma(Float64(Float64(B * B) * F), 0.16666666666666666, F), Float64(fma(fma(Float64(Float64(-F) * -0.019444444444444445), t_0, Float64(x * 0.022222222222222223)), Float64(B * B), Float64(0.3333333333333333 * x)) * Float64(B * B))) - x) / B); else tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + Float64(Float64(F / B) * Float64(1.0 / F))); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, 1.24e+14], N[(N[(N[(t$95$0 * N[(N[(N[(B * B), $MachinePrecision] * F), $MachinePrecision] * 0.16666666666666666 + F), $MachinePrecision] + N[(N[(N[(N[((-F) * -0.019444444444444445), $MachinePrecision] * t$95$0 + N[(x * 0.022222222222222223), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision] + N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(F / B), $MachinePrecision] * N[(1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{if}\;B \leq 1.24 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \mathsf{fma}\left(\left(B \cdot B\right) \cdot F, 0.16666666666666666, F\right), \mathsf{fma}\left(\mathsf{fma}\left(\left(-F\right) \cdot -0.019444444444444445, t\_0, x \cdot 0.022222222222222223\right), B \cdot B, 0.3333333333333333 \cdot x\right) \cdot \left(B \cdot B\right)\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{F}{B} \cdot \frac{1}{F}\\
\end{array}
\end{array}
if B < 1.24e14Initial program 75.8%
Taylor expanded in B around 0
Applied rewrites63.5%
if 1.24e14 < B Initial program 85.6%
Taylor expanded in B around 0
Applied rewrites52.4%
Taylor expanded in F around inf
Applied rewrites47.4%
Final simplification60.0%
(FPCore (F B x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))))
(if (<= B 1.24e+14)
(/
(-
(fma
t_0
(fma (* (* B B) F) 0.16666666666666666 F)
(*
(fma
(fma (* (- F) -0.019444444444444445) t_0 (* x 0.022222222222222223))
(* B B)
(* 0.3333333333333333 x))
(* B B)))
x)
B)
(+ (/ (- x) (tan B)) (/ 1.0 B)))))
double code(double F, double B, double x) {
double t_0 = sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0))));
double tmp;
if (B <= 1.24e+14) {
tmp = (fma(t_0, fma(((B * B) * F), 0.16666666666666666, F), (fma(fma((-F * -0.019444444444444445), t_0, (x * 0.022222222222222223)), (B * B), (0.3333333333333333 * x)) * (B * B))) - x) / B;
} else {
tmp = (-x / tan(B)) + (1.0 / B);
}
return tmp;
}
function code(F, B, x) t_0 = sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) tmp = 0.0 if (B <= 1.24e+14) tmp = Float64(Float64(fma(t_0, fma(Float64(Float64(B * B) * F), 0.16666666666666666, F), Float64(fma(fma(Float64(Float64(-F) * -0.019444444444444445), t_0, Float64(x * 0.022222222222222223)), Float64(B * B), Float64(0.3333333333333333 * x)) * Float64(B * B))) - x) / B); else tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(1.0 / B)); end return tmp end
code[F_, B_, x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, 1.24e+14], N[(N[(N[(t$95$0 * N[(N[(N[(B * B), $MachinePrecision] * F), $MachinePrecision] * 0.16666666666666666 + F), $MachinePrecision] + N[(N[(N[(N[((-F) * -0.019444444444444445), $MachinePrecision] * t$95$0 + N[(x * 0.022222222222222223), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision] + N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\
\mathbf{if}\;B \leq 1.24 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \mathsf{fma}\left(\left(B \cdot B\right) \cdot F, 0.16666666666666666, F\right), \mathsf{fma}\left(\mathsf{fma}\left(\left(-F\right) \cdot -0.019444444444444445, t\_0, x \cdot 0.022222222222222223\right), B \cdot B, 0.3333333333333333 \cdot x\right) \cdot \left(B \cdot B\right)\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{1}{B}\\
\end{array}
\end{array}
if B < 1.24e14Initial program 75.8%
Taylor expanded in B around 0
Applied rewrites63.5%
if 1.24e14 < B Initial program 85.6%
Taylor expanded in F around inf
Applied rewrites44.3%
Taylor expanded in B around 0
Applied rewrites42.4%
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-/.f6442.6
Applied rewrites42.6%
Final simplification59.0%
(FPCore (F B x)
:precision binary64
(if (<= F -2e+90)
(/ (- -1.0 x) B)
(if (<= F 58.0)
(/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
(+ (- (/ x B)) (/ 1.0 (sin B))))))
double code(double F, double B, double x) {
double tmp;
if (F <= -2e+90) {
tmp = (-1.0 - x) / B;
} else if (F <= 58.0) {
tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
} else {
tmp = -(x / B) + (1.0 / sin(B));
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -2e+90) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 58.0) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B); else tmp = Float64(Float64(-Float64(x / B)) + Float64(1.0 / sin(B))); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -2e+90], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 58.0], 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[(x / B), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2 \cdot 10^{+90}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 58:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{1}{\sin B}\\
\end{array}
\end{array}
if F < -1.99999999999999993e90Initial program 49.8%
Taylor expanded in B around 0
Applied rewrites29.9%
Taylor expanded in F around -inf
Applied rewrites47.6%
if -1.99999999999999993e90 < F < 58Initial program 98.2%
Taylor expanded in B around 0
Applied rewrites55.8%
if 58 < F Initial program 60.0%
Taylor expanded in F around inf
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites81.0%
(FPCore (F B x)
:precision binary64
(if (<= B 1.24e+14)
(/
(-
(fma
(sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0))))
(fma (* (* B B) F) 0.16666666666666666 F)
(* 0.3333333333333333 (* (* B B) x)))
x)
B)
(+ (/ (- x) (tan B)) (/ 1.0 B))))
double code(double F, double B, double x) {
double tmp;
if (B <= 1.24e+14) {
tmp = (fma(sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))), fma(((B * B) * F), 0.16666666666666666, F), (0.3333333333333333 * ((B * B) * x))) - x) / B;
} else {
tmp = (-x / tan(B)) + (1.0 / B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (B <= 1.24e+14) tmp = Float64(Float64(fma(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))), fma(Float64(Float64(B * B) * F), 0.16666666666666666, F), Float64(0.3333333333333333 * Float64(Float64(B * B) * x))) - x) / B); else tmp = Float64(Float64(Float64(-x) / tan(B)) + Float64(1.0 / B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[B, 1.24e+14], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(B * B), $MachinePrecision] * F), $MachinePrecision] * 0.16666666666666666 + F), $MachinePrecision] + N[(0.3333333333333333 * N[(N[(B * B), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.24 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \mathsf{fma}\left(\left(B \cdot B\right) \cdot F, 0.16666666666666666, F\right), 0.3333333333333333 \cdot \left(\left(B \cdot B\right) \cdot x\right)\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan B} + \frac{1}{B}\\
\end{array}
\end{array}
if B < 1.24e14Initial program 75.8%
Taylor expanded in B around 0
Applied rewrites63.5%
if 1.24e14 < B Initial program 85.6%
Taylor expanded in F around inf
Applied rewrites44.3%
Taylor expanded in B around 0
Applied rewrites42.4%
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-/.f6442.6
Applied rewrites42.6%
(FPCore (F B x)
:precision binary64
(if (<= F -5e+105)
(/ (- -1.0 x) B)
(if (<= F 6.8e+78)
(/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
(+ (- (/ (fma (* (* B B) x) -0.3333333333333333 x) B)) (/ 1.0 B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -5e+105) {
tmp = (-1.0 - x) / B;
} else if (F <= 6.8e+78) {
tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
} else {
tmp = -(fma(((B * B) * x), -0.3333333333333333, x) / B) + (1.0 / B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -5e+105) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 6.8e+78) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B); else tmp = Float64(Float64(-Float64(fma(Float64(Float64(B * B) * x), -0.3333333333333333, x) / B)) + Float64(1.0 / B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -5e+105], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 6.8e+78], 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[(N[(B * B), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision] / B), $MachinePrecision]) + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{+105}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 6.8 \cdot 10^{+78}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{\mathsf{fma}\left(\left(B \cdot B\right) \cdot x, -0.3333333333333333, x\right)}{B}\right) + \frac{1}{B}\\
\end{array}
\end{array}
if F < -5.00000000000000046e105Initial program 47.0%
Taylor expanded in B around 0
Applied rewrites29.6%
Taylor expanded in F around -inf
Applied rewrites48.4%
if -5.00000000000000046e105 < F < 6.80000000000000014e78Initial program 98.3%
Taylor expanded in B around 0
Applied rewrites57.1%
if 6.80000000000000014e78 < F Initial program 48.5%
Taylor expanded in F around inf
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites83.5%
Taylor expanded in B around 0
Applied rewrites63.9%
(FPCore (F B x)
:precision binary64
(if (<= F -1.4)
(/ (- -1.0 x) B)
(if (<= F 5.8e-6)
(/ (- (* (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 <= -1.4) {
tmp = (-1.0 - x) / B;
} else if (F <= 5.8e-6) {
tmp = ((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 <= -1.4) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 5.8e-6) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, 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, -1.4], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 5.8e-6], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + 2.0), $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 -1.4:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, 2\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 < -1.3999999999999999Initial program 56.1%
Taylor expanded in B around 0
Applied rewrites36.7%
Taylor expanded in F around -inf
Applied rewrites51.3%
if -1.3999999999999999 < F < 5.8000000000000004e-6Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites55.0%
Taylor expanded in F around 0
Applied rewrites55.0%
if 5.8000000000000004e-6 < F Initial program 60.6%
Taylor expanded in B around 0
Applied rewrites57.6%
Taylor expanded in F around inf
Applied rewrites65.0%
(FPCore (F B x)
:precision binary64
(if (<= F -1.65e+161)
(/ (- -1.0 x) B)
(if (<= F 7.8e+79)
(/ (- (/ F (sqrt (fma x 2.0 (fma F F 2.0)))) x) B)
(+ (- (/ (fma (* (* B B) x) -0.3333333333333333 x) B)) (/ 1.0 B)))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.65e+161) {
tmp = (-1.0 - x) / B;
} else if (F <= 7.8e+79) {
tmp = ((F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B;
} else {
tmp = -(fma(((B * B) * x), -0.3333333333333333, x) / B) + (1.0 / B);
}
return tmp;
}
function code(F, B, x) tmp = 0.0 if (F <= -1.65e+161) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 7.8e+79) tmp = Float64(Float64(Float64(F / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - x) / B); else tmp = Float64(Float64(-Float64(fma(Float64(Float64(B * B) * x), -0.3333333333333333, x) / B)) + Float64(1.0 / B)); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.65e+161], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 7.8e+79], 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[(N[(B * B), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision] / B), $MachinePrecision]) + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.65 \cdot 10^{+161}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 7.8 \cdot 10^{+79}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{\mathsf{fma}\left(\left(B \cdot B\right) \cdot x, -0.3333333333333333, x\right)}{B}\right) + \frac{1}{B}\\
\end{array}
\end{array}
if F < -1.64999999999999999e161Initial program 33.6%
Taylor expanded in B around 0
Applied rewrites27.8%
Taylor expanded in F around -inf
Applied rewrites52.2%
if -1.64999999999999999e161 < F < 7.7999999999999994e79Initial program 97.8%
Taylor expanded in B around 0
Applied rewrites55.5%
Applied rewrites55.5%
if 7.7999999999999994e79 < F Initial program 48.5%
Taylor expanded in F around inf
Applied rewrites99.8%
Taylor expanded in B around 0
Applied rewrites83.5%
Taylor expanded in B around 0
Applied rewrites63.9%
Final simplification56.7%
(FPCore (F B x)
:precision binary64
(if (<= F -1.4)
(/ (- -1.0 x) B)
(if (<= F 5.8e-6)
(/ (- (* (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 <= -1.4) {
tmp = (-1.0 - x) / B;
} else if (F <= 5.8e-6) {
tmp = ((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 <= -1.4) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 5.8e-6) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, 2.0))) * F) - x) / B); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
code[F_, B_, x_] := If[LessEqual[F, -1.4], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 5.8e-6], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.4:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, 2\right)}} \cdot F - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if F < -1.3999999999999999Initial program 56.1%
Taylor expanded in B around 0
Applied rewrites36.7%
Taylor expanded in F around -inf
Applied rewrites51.3%
if -1.3999999999999999 < F < 5.8000000000000004e-6Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites55.0%
Taylor expanded in F around 0
Applied rewrites55.0%
if 5.8000000000000004e-6 < F Initial program 60.6%
Taylor expanded in B around 0
Applied rewrites57.6%
Taylor expanded in F around inf
Applied rewrites65.0%
(FPCore (F B x) :precision binary64 (if (<= F -1.45e-35) (/ (- -1.0 x) B) (if (<= F 1.45e-68) (/ (- x) B) (/ (- 1.0 x) B))))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.45e-35) {
tmp = (-1.0 - x) / B;
} else if (F <= 1.45e-68) {
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 <= (-1.45d-35)) then
tmp = ((-1.0d0) - x) / b
else if (f <= 1.45d-68) 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 <= -1.45e-35) {
tmp = (-1.0 - x) / B;
} else if (F <= 1.45e-68) {
tmp = -x / B;
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -1.45e-35: tmp = (-1.0 - x) / B elif F <= 1.45e-68: tmp = -x / B else: tmp = (1.0 - x) / B return tmp
function code(F, B, x) tmp = 0.0 if (F <= -1.45e-35) tmp = Float64(Float64(-1.0 - x) / B); elseif (F <= 1.45e-68) 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 <= -1.45e-35) tmp = (-1.0 - x) / B; elseif (F <= 1.45e-68) tmp = -x / B; else tmp = (1.0 - x) / B; end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -1.45e-35], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 1.45e-68], N[((-x) / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.45 \cdot 10^{-35}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;F \leq 1.45 \cdot 10^{-68}:\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if F < -1.4500000000000001e-35Initial program 60.2%
Taylor expanded in B around 0
Applied rewrites41.1%
Taylor expanded in F around -inf
Applied rewrites48.5%
if -1.4500000000000001e-35 < F < 1.45e-68Initial program 99.5%
Taylor expanded in B around 0
Applied rewrites55.2%
Taylor expanded in F around 0
Applied rewrites42.3%
if 1.45e-68 < F Initial program 63.8%
Taylor expanded in B around 0
Applied rewrites54.4%
Taylor expanded in F around inf
Applied rewrites60.1%
(FPCore (F B x) :precision binary64 (if (<= F -1.45e-35) (/ (- -1.0 x) B) (/ (- x) B)))
double code(double F, double B, double x) {
double tmp;
if (F <= -1.45e-35) {
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 <= (-1.45d-35)) 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 <= -1.45e-35) {
tmp = (-1.0 - x) / B;
} else {
tmp = -x / B;
}
return tmp;
}
def code(F, B, x): tmp = 0 if F <= -1.45e-35: tmp = (-1.0 - x) / B else: tmp = -x / B return tmp
function code(F, B, x) tmp = 0.0 if (F <= -1.45e-35) 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 <= -1.45e-35) tmp = (-1.0 - x) / B; else tmp = -x / B; end tmp_2 = tmp; end
code[F_, B_, x_] := If[LessEqual[F, -1.45e-35], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[((-x) / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.45 \cdot 10^{-35}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{B}\\
\end{array}
\end{array}
if F < -1.4500000000000001e-35Initial program 60.2%
Taylor expanded in B around 0
Applied rewrites41.1%
Taylor expanded in F around -inf
Applied rewrites48.5%
if -1.4500000000000001e-35 < F Initial program 85.2%
Taylor expanded in B around 0
Applied rewrites54.9%
Taylor expanded in F around 0
Applied rewrites37.8%
(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 78.0%
Taylor expanded in B around 0
Applied rewrites50.9%
Taylor expanded in F around 0
Applied rewrites33.2%
herbie shell --seed 2025018
(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))))))