VandenBroeck and Keller, Equation (24)

Percentage Accurate: 99.7% → 99.8%
Time: 4.0s
Alternatives: 12
Speedup: 1.1×

Specification

?
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(b, x)
use fmin_fmax_functions
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.7% accurate, 1.0× speedup?

\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(b, x)
use fmin_fmax_functions
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}

Alternative 1: 99.8% accurate, 1.1× speedup?

\[\frac{1}{\sin B} - \frac{x}{\tan B} \]
(FPCore (B x) :precision binary64 (- (/ 1.0 (sin B)) (/ x (tan B))))
double code(double B, double x) {
	return (1.0 / sin(B)) - (x / tan(B));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(b, x)
use fmin_fmax_functions
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = (1.0d0 / sin(b)) - (x / tan(b))
end function
public static double code(double B, double x) {
	return (1.0 / Math.sin(B)) - (x / Math.tan(B));
}
def code(B, x):
	return (1.0 / math.sin(B)) - (x / math.tan(B))
function code(B, x)
	return Float64(Float64(1.0 / sin(B)) - Float64(x / tan(B)))
end
function tmp = code(B, x)
	tmp = (1.0 / sin(B)) - (x / tan(B));
end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sin B} - \frac{x}{\tan B}
Derivation
  1. Initial program 99.7%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
    3. lift-neg.f64N/A

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
    4. sub-flip-reverseN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    5. lower--.f6499.7

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
    7. lift-/.f64N/A

      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
    8. mult-flip-revN/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
    9. lower-/.f6499.8

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
  4. Add Preprocessing

Alternative 2: 99.7% accurate, 1.1× speedup?

\[\frac{1 - \cos B \cdot x}{\sin B} \]
(FPCore (B x) :precision binary64 (/ (- 1.0 (* (cos B) x)) (sin B)))
double code(double B, double x) {
	return (1.0 - (cos(B) * x)) / sin(B);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(b, x)
use fmin_fmax_functions
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = (1.0d0 - (cos(b) * x)) / sin(b)
end function
public static double code(double B, double x) {
	return (1.0 - (Math.cos(B) * x)) / Math.sin(B);
}
def code(B, x):
	return (1.0 - (math.cos(B) * x)) / math.sin(B)
function code(B, x)
	return Float64(Float64(1.0 - Float64(cos(B) * x)) / sin(B))
end
function tmp = code(B, x)
	tmp = (1.0 - (cos(B) * x)) / sin(B);
end
code[B_, x_] := N[(N[(1.0 - N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\frac{1 - \cos B \cdot x}{\sin B}
Derivation
  1. Initial program 99.7%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
    3. lift-neg.f64N/A

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
    4. sub-flip-reverseN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    5. lower--.f6499.7

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
    7. lift-/.f64N/A

      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
    8. mult-flip-revN/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
    9. lower-/.f6499.8

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    2. lift-/.f64N/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
    3. lift-tan.f64N/A

      \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\tan B}} \]
    4. tan-quotN/A

      \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\frac{\sin B}{\cos B}}} \]
    5. lift-sin.f64N/A

      \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\color{blue}{\sin B}}{\cos B}} \]
    6. lift-cos.f64N/A

      \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\sin B}{\color{blue}{\cos B}}} \]
    7. associate-/r/N/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B} \cdot \cos B} \]
    8. mult-flip-revN/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\left(x \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
    9. lift-/.f64N/A

      \[\leadsto \frac{1}{\sin B} - \left(x \cdot \color{blue}{\frac{1}{\sin B}}\right) \cdot \cos B \]
    10. fp-cancel-sub-signN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\sin B}\right)\right) \cdot \cos B} \]
    11. distribute-lft-neg-outN/A

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
    12. lift-neg.f64N/A

      \[\leadsto \frac{1}{\sin B} + \left(\color{blue}{\left(-x\right)} \cdot \frac{1}{\sin B}\right) \cdot \cos B \]
    13. lift-*.f64N/A

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
    14. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \frac{1}{\sin B}} \]
    15. lift-/.f64N/A

      \[\leadsto \left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \color{blue}{\frac{1}{\sin B}} \]
  5. Applied rewrites99.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-x, \cos B, 1\right)}{\sin B}} \]
  6. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\left(-x\right) \cdot \cos B + 1}}{\sin B} \]
    2. +-commutativeN/A

      \[\leadsto \frac{\color{blue}{1 + \left(-x\right) \cdot \cos B}}{\sin B} \]
    3. lift-neg.f64N/A

      \[\leadsto \frac{1 + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \cos B}{\sin B} \]
    4. fp-cancel-sub-signN/A

      \[\leadsto \frac{\color{blue}{1 - x \cdot \cos B}}{\sin B} \]
    5. lower--.f64N/A

      \[\leadsto \frac{\color{blue}{1 - x \cdot \cos B}}{\sin B} \]
    6. *-commutativeN/A

      \[\leadsto \frac{1 - \color{blue}{\cos B \cdot x}}{\sin B} \]
    7. lower-*.f6499.7

      \[\leadsto \frac{1 - \color{blue}{\cos B \cdot x}}{\sin B} \]
  7. Applied rewrites99.7%

    \[\leadsto \frac{\color{blue}{1 - \cos B \cdot x}}{\sin B} \]
  8. Add Preprocessing

Alternative 3: 98.6% accurate, 1.5× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -55:\\ \;\;\;\;\frac{1 - x}{\tan B}\\ \mathbf{elif}\;x \leq 400000:\\ \;\;\;\;\frac{\frac{B}{\sin B} - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (<= x -55.0)
   (/ (- 1.0 x) (tan B))
   (if (<= x 400000.0) (/ (- (/ B (sin B)) x) B) (- (/ 1.0 B) (/ x (tan B))))))
double code(double B, double x) {
	double tmp;
	if (x <= -55.0) {
		tmp = (1.0 - x) / tan(B);
	} else if (x <= 400000.0) {
		tmp = ((B / sin(B)) - x) / B;
	} else {
		tmp = (1.0 / B) - (x / tan(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(b, x)
use fmin_fmax_functions
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-55.0d0)) then
        tmp = (1.0d0 - x) / tan(b)
    else if (x <= 400000.0d0) then
        tmp = ((b / sin(b)) - x) / b
    else
        tmp = (1.0d0 / b) - (x / tan(b))
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if (x <= -55.0) {
		tmp = (1.0 - x) / Math.tan(B);
	} else if (x <= 400000.0) {
		tmp = ((B / Math.sin(B)) - x) / B;
	} else {
		tmp = (1.0 / B) - (x / Math.tan(B));
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if x <= -55.0:
		tmp = (1.0 - x) / math.tan(B)
	elif x <= 400000.0:
		tmp = ((B / math.sin(B)) - x) / B
	else:
		tmp = (1.0 / B) - (x / math.tan(B))
	return tmp
function code(B, x)
	tmp = 0.0
	if (x <= -55.0)
		tmp = Float64(Float64(1.0 - x) / tan(B));
	elseif (x <= 400000.0)
		tmp = Float64(Float64(Float64(B / sin(B)) - x) / B);
	else
		tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B)));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if (x <= -55.0)
		tmp = (1.0 - x) / tan(B);
	elseif (x <= 400000.0)
		tmp = ((B / sin(B)) - x) / B;
	else
		tmp = (1.0 / B) - (x / tan(B));
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[LessEqual[x, -55.0], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 400000.0], N[(N[(N[(B / N[Sin[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -55:\\
\;\;\;\;\frac{1 - x}{\tan B}\\

\mathbf{elif}\;x \leq 400000:\\
\;\;\;\;\frac{\frac{B}{\sin B} - x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -55

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
      4. sub-flip-reverseN/A

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      5. lower--.f6499.7

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
      8. mult-flip-revN/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
      9. lower-/.f6499.8

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    4. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
      3. sub-to-fractionN/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
      5. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
      6. lift-tan.f64N/A

        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
      7. tan-quotN/A

        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
      9. lift-cos.f64N/A

        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
      10. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
      12. inv-powN/A

        \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
      13. pow-plusN/A

        \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
      16. lower-/.f6499.7

        \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
    5. Applied rewrites99.7%

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
    6. Taylor expanded in B around 0

      \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]
    7. Step-by-step derivation
      1. Applied rewrites76.9%

        \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]

      if -55 < x < 4e5

      1. Initial program 99.7%

        \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
        2. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
        3. lift-neg.f64N/A

          \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
        4. sub-flip-reverseN/A

          \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
        5. lower--.f6499.7

          \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
        6. lift-*.f64N/A

          \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
        7. lift-/.f64N/A

          \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
        8. mult-flip-revN/A

          \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
        9. lower-/.f6499.8

          \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
      3. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
      4. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
        3. sub-to-fractionN/A

          \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
        4. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
        5. lower--.f64N/A

          \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
        6. lift-tan.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
        7. tan-quotN/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
        8. lift-sin.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
        9. lift-cos.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
        10. associate-*r/N/A

          \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
        11. lift-/.f64N/A

          \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
        12. inv-powN/A

          \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
        13. pow-plusN/A

          \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
        14. metadata-evalN/A

          \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
        15. metadata-evalN/A

          \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
        16. lower-/.f6499.7

          \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
      5. Applied rewrites99.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
      6. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
        2. mult-flipN/A

          \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{\cos B}} - x}{\tan B} \]
        3. metadata-evalN/A

          \[\leadsto \frac{\color{blue}{{\sin B}^{0}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
        4. metadata-evalN/A

          \[\leadsto \frac{{\sin B}^{\color{blue}{\left(-1 + 1\right)}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
        5. pow-plusN/A

          \[\leadsto \frac{\color{blue}{\left({\sin B}^{-1} \cdot \sin B\right)} \cdot \frac{1}{\cos B} - x}{\tan B} \]
        6. inv-powN/A

          \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
        7. lift-/.f64N/A

          \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
        8. lift-/.f64N/A

          \[\leadsto \frac{\left(\frac{1}{\sin B} \cdot \sin B\right) \cdot \color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
        9. associate-*r*N/A

          \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \left(\sin B \cdot \frac{1}{\cos B}\right)} - x}{\tan B} \]
        10. lift-/.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \left(\sin B \cdot \color{blue}{\frac{1}{\cos B}}\right) - x}{\tan B} \]
        11. mult-flipN/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
        12. lift-sin.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
        13. lift-cos.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
        14. quot-tanN/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
        15. lift-tan.f64N/A

          \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
        16. lift-/.f64N/A

          \[\leadsto \frac{\color{blue}{\frac{1}{\sin B}} \cdot \tan B - x}{\tan B} \]
        17. associate-*l/N/A

          \[\leadsto \frac{\color{blue}{\frac{1 \cdot \tan B}{\sin B}} - x}{\tan B} \]
        18. *-lft-identityN/A

          \[\leadsto \frac{\frac{\color{blue}{\tan B}}{\sin B} - x}{\tan B} \]
        19. lower-/.f6499.8

          \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
      7. Applied rewrites99.8%

        \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
      8. Taylor expanded in B around 0

        \[\leadsto \frac{\frac{\color{blue}{B}}{\sin B} - x}{\tan B} \]
      9. Step-by-step derivation
        1. Applied rewrites62.5%

          \[\leadsto \frac{\frac{\color{blue}{B}}{\sin B} - x}{\tan B} \]
        2. Taylor expanded in B around 0

          \[\leadsto \frac{\frac{B}{\sin B} - x}{\color{blue}{B}} \]
        3. Step-by-step derivation
          1. Applied rewrites74.6%

            \[\leadsto \frac{\frac{B}{\sin B} - x}{\color{blue}{B}} \]

          if 4e5 < x

          1. Initial program 99.7%

            \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
          2. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
            2. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
            3. lift-neg.f64N/A

              \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
            4. sub-flip-reverseN/A

              \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
            5. lower--.f6499.7

              \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
            6. lift-*.f64N/A

              \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
            7. lift-/.f64N/A

              \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
            8. mult-flip-revN/A

              \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
            9. lower-/.f6499.8

              \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
          3. Applied rewrites99.8%

            \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
          4. Taylor expanded in B around 0

            \[\leadsto \frac{1}{\color{blue}{B}} - \frac{x}{\tan B} \]
          5. Step-by-step derivation
            1. Applied rewrites75.0%

              \[\leadsto \frac{1}{\color{blue}{B}} - \frac{x}{\tan B} \]
          6. Recombined 3 regimes into one program.
          7. Add Preprocessing

          Alternative 4: 98.6% accurate, 1.6× speedup?

          \[\begin{array}{l} t_0 := \frac{1 - x}{\tan B}\\ \mathbf{if}\;x \leq -55:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.14 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{B}{\sin B} - x}{B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (B x)
           :precision binary64
           (let* ((t_0 (/ (- 1.0 x) (tan B))))
             (if (<= x -55.0) t_0 (if (<= x 1.14e-10) (/ (- (/ B (sin B)) x) B) t_0))))
          double code(double B, double x) {
          	double t_0 = (1.0 - x) / tan(B);
          	double tmp;
          	if (x <= -55.0) {
          		tmp = t_0;
          	} else if (x <= 1.14e-10) {
          		tmp = ((B / sin(B)) - x) / B;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(b, x)
          use fmin_fmax_functions
              real(8), intent (in) :: b
              real(8), intent (in) :: x
              real(8) :: t_0
              real(8) :: tmp
              t_0 = (1.0d0 - x) / tan(b)
              if (x <= (-55.0d0)) then
                  tmp = t_0
              else if (x <= 1.14d-10) then
                  tmp = ((b / sin(b)) - x) / b
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double B, double x) {
          	double t_0 = (1.0 - x) / Math.tan(B);
          	double tmp;
          	if (x <= -55.0) {
          		tmp = t_0;
          	} else if (x <= 1.14e-10) {
          		tmp = ((B / Math.sin(B)) - x) / B;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(B, x):
          	t_0 = (1.0 - x) / math.tan(B)
          	tmp = 0
          	if x <= -55.0:
          		tmp = t_0
          	elif x <= 1.14e-10:
          		tmp = ((B / math.sin(B)) - x) / B
          	else:
          		tmp = t_0
          	return tmp
          
          function code(B, x)
          	t_0 = Float64(Float64(1.0 - x) / tan(B))
          	tmp = 0.0
          	if (x <= -55.0)
          		tmp = t_0;
          	elseif (x <= 1.14e-10)
          		tmp = Float64(Float64(Float64(B / sin(B)) - x) / B);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(B, x)
          	t_0 = (1.0 - x) / tan(B);
          	tmp = 0.0;
          	if (x <= -55.0)
          		tmp = t_0;
          	elseif (x <= 1.14e-10)
          		tmp = ((B / sin(B)) - x) / B;
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -55.0], t$95$0, If[LessEqual[x, 1.14e-10], N[(N[(N[(B / N[Sin[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          t_0 := \frac{1 - x}{\tan B}\\
          \mathbf{if}\;x \leq -55:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq 1.14 \cdot 10^{-10}:\\
          \;\;\;\;\frac{\frac{B}{\sin B} - x}{B}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -55 or 1.1399999999999999e-10 < x

            1. Initial program 99.7%

              \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
              2. +-commutativeN/A

                \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
              3. lift-neg.f64N/A

                \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
              4. sub-flip-reverseN/A

                \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
              5. lower--.f6499.7

                \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
              6. lift-*.f64N/A

                \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
              7. lift-/.f64N/A

                \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
              8. mult-flip-revN/A

                \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
              9. lower-/.f6499.8

                \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
            3. Applied rewrites99.8%

              \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
            4. Step-by-step derivation
              1. lift--.f64N/A

                \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
              2. lift-/.f64N/A

                \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
              3. sub-to-fractionN/A

                \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
              4. lower-/.f64N/A

                \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
              5. lower--.f64N/A

                \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
              6. lift-tan.f64N/A

                \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
              7. tan-quotN/A

                \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
              8. lift-sin.f64N/A

                \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
              9. lift-cos.f64N/A

                \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
              10. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
              11. lift-/.f64N/A

                \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
              12. inv-powN/A

                \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
              13. pow-plusN/A

                \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
              14. metadata-evalN/A

                \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
              15. metadata-evalN/A

                \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
              16. lower-/.f6499.7

                \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
            5. Applied rewrites99.7%

              \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
            6. Taylor expanded in B around 0

              \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]
            7. Step-by-step derivation
              1. Applied rewrites76.9%

                \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]

              if -55 < x < 1.1399999999999999e-10

              1. Initial program 99.7%

                \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                2. +-commutativeN/A

                  \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                3. lift-neg.f64N/A

                  \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                4. sub-flip-reverseN/A

                  \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                5. lower--.f6499.7

                  \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                6. lift-*.f64N/A

                  \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                7. lift-/.f64N/A

                  \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                8. mult-flip-revN/A

                  \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                9. lower-/.f6499.8

                  \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
              3. Applied rewrites99.8%

                \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
              4. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                2. lift-/.f64N/A

                  \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                3. sub-to-fractionN/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                4. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                5. lower--.f64N/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
                6. lift-tan.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                7. tan-quotN/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
                8. lift-sin.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
                9. lift-cos.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
                10. associate-*r/N/A

                  \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
                11. lift-/.f64N/A

                  \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                12. inv-powN/A

                  \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                13. pow-plusN/A

                  \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
                14. metadata-evalN/A

                  \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
                15. metadata-evalN/A

                  \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
                16. lower-/.f6499.7

                  \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
              5. Applied rewrites99.7%

                \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
              6. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                2. mult-flipN/A

                  \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{\cos B}} - x}{\tan B} \]
                3. metadata-evalN/A

                  \[\leadsto \frac{\color{blue}{{\sin B}^{0}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                4. metadata-evalN/A

                  \[\leadsto \frac{{\sin B}^{\color{blue}{\left(-1 + 1\right)}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                5. pow-plusN/A

                  \[\leadsto \frac{\color{blue}{\left({\sin B}^{-1} \cdot \sin B\right)} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                6. inv-powN/A

                  \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
                7. lift-/.f64N/A

                  \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
                8. lift-/.f64N/A

                  \[\leadsto \frac{\left(\frac{1}{\sin B} \cdot \sin B\right) \cdot \color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                9. associate-*r*N/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \left(\sin B \cdot \frac{1}{\cos B}\right)} - x}{\tan B} \]
                10. lift-/.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \left(\sin B \cdot \color{blue}{\frac{1}{\cos B}}\right) - x}{\tan B} \]
                11. mult-flipN/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
                12. lift-sin.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
                13. lift-cos.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
                14. quot-tanN/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                15. lift-tan.f64N/A

                  \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                16. lift-/.f64N/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{\sin B}} \cdot \tan B - x}{\tan B} \]
                17. associate-*l/N/A

                  \[\leadsto \frac{\color{blue}{\frac{1 \cdot \tan B}{\sin B}} - x}{\tan B} \]
                18. *-lft-identityN/A

                  \[\leadsto \frac{\frac{\color{blue}{\tan B}}{\sin B} - x}{\tan B} \]
                19. lower-/.f6499.8

                  \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
              7. Applied rewrites99.8%

                \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
              8. Taylor expanded in B around 0

                \[\leadsto \frac{\frac{\color{blue}{B}}{\sin B} - x}{\tan B} \]
              9. Step-by-step derivation
                1. Applied rewrites62.5%

                  \[\leadsto \frac{\frac{\color{blue}{B}}{\sin B} - x}{\tan B} \]
                2. Taylor expanded in B around 0

                  \[\leadsto \frac{\frac{B}{\sin B} - x}{\color{blue}{B}} \]
                3. Step-by-step derivation
                  1. Applied rewrites74.6%

                    \[\leadsto \frac{\frac{B}{\sin B} - x}{\color{blue}{B}} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 5: 98.5% accurate, 1.6× speedup?

                \[\begin{array}{l} t_0 := \frac{1 - x}{\tan B}\\ \mathbf{if}\;x \leq -50:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.14 \cdot 10^{-10}:\\ \;\;\;\;\frac{1 + -1 \cdot x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                (FPCore (B x)
                 :precision binary64
                 (let* ((t_0 (/ (- 1.0 x) (tan B))))
                   (if (<= x -50.0)
                     t_0
                     (if (<= x 1.14e-10) (/ (+ 1.0 (* -1.0 x)) (sin B)) t_0))))
                double code(double B, double x) {
                	double t_0 = (1.0 - x) / tan(B);
                	double tmp;
                	if (x <= -50.0) {
                		tmp = t_0;
                	} else if (x <= 1.14e-10) {
                		tmp = (1.0 + (-1.0 * x)) / sin(B);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(b, x)
                use fmin_fmax_functions
                    real(8), intent (in) :: b
                    real(8), intent (in) :: x
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = (1.0d0 - x) / tan(b)
                    if (x <= (-50.0d0)) then
                        tmp = t_0
                    else if (x <= 1.14d-10) then
                        tmp = (1.0d0 + ((-1.0d0) * x)) / sin(b)
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                public static double code(double B, double x) {
                	double t_0 = (1.0 - x) / Math.tan(B);
                	double tmp;
                	if (x <= -50.0) {
                		tmp = t_0;
                	} else if (x <= 1.14e-10) {
                		tmp = (1.0 + (-1.0 * x)) / Math.sin(B);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(B, x):
                	t_0 = (1.0 - x) / math.tan(B)
                	tmp = 0
                	if x <= -50.0:
                		tmp = t_0
                	elif x <= 1.14e-10:
                		tmp = (1.0 + (-1.0 * x)) / math.sin(B)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(B, x)
                	t_0 = Float64(Float64(1.0 - x) / tan(B))
                	tmp = 0.0
                	if (x <= -50.0)
                		tmp = t_0;
                	elseif (x <= 1.14e-10)
                		tmp = Float64(Float64(1.0 + Float64(-1.0 * x)) / sin(B));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(B, x)
                	t_0 = (1.0 - x) / tan(B);
                	tmp = 0.0;
                	if (x <= -50.0)
                		tmp = t_0;
                	elseif (x <= 1.14e-10)
                		tmp = (1.0 + (-1.0 * x)) / sin(B);
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -50.0], t$95$0, If[LessEqual[x, 1.14e-10], N[(N[(1.0 + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                t_0 := \frac{1 - x}{\tan B}\\
                \mathbf{if}\;x \leq -50:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;x \leq 1.14 \cdot 10^{-10}:\\
                \;\;\;\;\frac{1 + -1 \cdot x}{\sin B}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < -50 or 1.1399999999999999e-10 < x

                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                    3. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                    4. sub-flip-reverseN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    5. lower--.f6499.7

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                    7. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    9. lower-/.f6499.8

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                  3. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                  4. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                    2. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    3. sub-to-fractionN/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                    4. lower-/.f64N/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                    5. lower--.f64N/A

                      \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
                    6. lift-tan.f64N/A

                      \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                    7. tan-quotN/A

                      \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
                    8. lift-sin.f64N/A

                      \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
                    9. lift-cos.f64N/A

                      \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
                    10. associate-*r/N/A

                      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
                    11. lift-/.f64N/A

                      \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                    12. inv-powN/A

                      \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                    13. pow-plusN/A

                      \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
                    14. metadata-evalN/A

                      \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
                    15. metadata-evalN/A

                      \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
                    16. lower-/.f6499.7

                      \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                  5. Applied rewrites99.7%

                    \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
                  6. Taylor expanded in B around 0

                    \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]
                  7. Step-by-step derivation
                    1. Applied rewrites76.9%

                      \[\leadsto \frac{\color{blue}{1} - x}{\tan B} \]

                    if -50 < x < 1.1399999999999999e-10

                    1. Initial program 99.7%

                      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                    2. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                      2. +-commutativeN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                      3. lift-neg.f64N/A

                        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                      4. sub-flip-reverseN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      5. lower--.f6499.7

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      6. lift-*.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                      7. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                      8. mult-flip-revN/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                      9. lower-/.f6499.8

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    3. Applied rewrites99.8%

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                    4. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                      2. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                      3. lift-tan.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\tan B}} \]
                      4. tan-quotN/A

                        \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\frac{\sin B}{\cos B}}} \]
                      5. lift-sin.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\color{blue}{\sin B}}{\cos B}} \]
                      6. lift-cos.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\sin B}{\color{blue}{\cos B}}} \]
                      7. associate-/r/N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B} \cdot \cos B} \]
                      8. mult-flip-revN/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\left(x \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                      9. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \left(x \cdot \color{blue}{\frac{1}{\sin B}}\right) \cdot \cos B \]
                      10. fp-cancel-sub-signN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\sin B}\right)\right) \cdot \cos B} \]
                      11. distribute-lft-neg-outN/A

                        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                      12. lift-neg.f64N/A

                        \[\leadsto \frac{1}{\sin B} + \left(\color{blue}{\left(-x\right)} \cdot \frac{1}{\sin B}\right) \cdot \cos B \]
                      13. lift-*.f64N/A

                        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                      14. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \frac{1}{\sin B}} \]
                      15. lift-/.f64N/A

                        \[\leadsto \left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \color{blue}{\frac{1}{\sin B}} \]
                    5. Applied rewrites99.7%

                      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-x, \cos B, 1\right)}{\sin B}} \]
                    6. Taylor expanded in B around 0

                      \[\leadsto \frac{\color{blue}{1 + -1 \cdot x}}{\sin B} \]
                    7. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto \frac{1 + \color{blue}{-1 \cdot x}}{\sin B} \]
                      2. lower-*.f6476.6

                        \[\leadsto \frac{1 + -1 \cdot \color{blue}{x}}{\sin B} \]
                    8. Applied rewrites76.6%

                      \[\leadsto \frac{\color{blue}{1 + -1 \cdot x}}{\sin B} \]
                  8. Recombined 2 regimes into one program.
                  9. Add Preprocessing

                  Alternative 6: 76.6% accurate, 1.9× speedup?

                  \[\frac{1 + -1 \cdot x}{\sin B} \]
                  (FPCore (B x) :precision binary64 (/ (+ 1.0 (* -1.0 x)) (sin B)))
                  double code(double B, double x) {
                  	return (1.0 + (-1.0 * x)) / sin(B);
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(b, x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: b
                      real(8), intent (in) :: x
                      code = (1.0d0 + ((-1.0d0) * x)) / sin(b)
                  end function
                  
                  public static double code(double B, double x) {
                  	return (1.0 + (-1.0 * x)) / Math.sin(B);
                  }
                  
                  def code(B, x):
                  	return (1.0 + (-1.0 * x)) / math.sin(B)
                  
                  function code(B, x)
                  	return Float64(Float64(1.0 + Float64(-1.0 * x)) / sin(B))
                  end
                  
                  function tmp = code(B, x)
                  	tmp = (1.0 + (-1.0 * x)) / sin(B);
                  end
                  
                  code[B_, x_] := N[(N[(1.0 + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
                  
                  \frac{1 + -1 \cdot x}{\sin B}
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                    3. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                    4. sub-flip-reverseN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    5. lower--.f6499.7

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                    7. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    9. lower-/.f6499.8

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                  3. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                  4. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                    2. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    3. lift-tan.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\tan B}} \]
                    4. tan-quotN/A

                      \[\leadsto \frac{1}{\sin B} - \frac{x}{\color{blue}{\frac{\sin B}{\cos B}}} \]
                    5. lift-sin.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\color{blue}{\sin B}}{\cos B}} \]
                    6. lift-cos.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \frac{x}{\frac{\sin B}{\color{blue}{\cos B}}} \]
                    7. associate-/r/N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B} \cdot \cos B} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\left(x \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                    9. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \left(x \cdot \color{blue}{\frac{1}{\sin B}}\right) \cdot \cos B \]
                    10. fp-cancel-sub-signN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\sin B}\right)\right) \cdot \cos B} \]
                    11. distribute-lft-neg-outN/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                    12. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \left(\color{blue}{\left(-x\right)} \cdot \frac{1}{\sin B}\right) \cdot \cos B \]
                    13. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right)} \cdot \cos B \]
                    14. +-commutativeN/A

                      \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \frac{1}{\sin B}} \]
                    15. lift-/.f64N/A

                      \[\leadsto \left(\left(-x\right) \cdot \frac{1}{\sin B}\right) \cdot \cos B + \color{blue}{\frac{1}{\sin B}} \]
                  5. Applied rewrites99.7%

                    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-x, \cos B, 1\right)}{\sin B}} \]
                  6. Taylor expanded in B around 0

                    \[\leadsto \frac{\color{blue}{1 + -1 \cdot x}}{\sin B} \]
                  7. Step-by-step derivation
                    1. lower-+.f64N/A

                      \[\leadsto \frac{1 + \color{blue}{-1 \cdot x}}{\sin B} \]
                    2. lower-*.f6476.6

                      \[\leadsto \frac{1 + -1 \cdot \color{blue}{x}}{\sin B} \]
                  8. Applied rewrites76.6%

                    \[\leadsto \frac{\color{blue}{1 + -1 \cdot x}}{\sin B} \]
                  9. Add Preprocessing

                  Alternative 7: 74.6% accurate, 1.7× speedup?

                  \[\mathsf{copysign}\left(1, B\right) \cdot \begin{array}{l} \mathbf{if}\;\left|B\right| \leq 2.3:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.022222222222222223, x, 0.019444444444444445\right) \cdot \left|B\right|, \left|B\right|, \mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right)\right), \left|B\right|, \frac{1 - x}{\left|B\right|}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin \left(\left|B\right|\right)}\\ \end{array} \]
                  (FPCore (B x)
                   :precision binary64
                   (*
                    (copysign 1.0 B)
                    (if (<= (fabs B) 2.3)
                      (fma
                       (fma
                        (* (fma 0.022222222222222223 x 0.019444444444444445) (fabs B))
                        (fabs B)
                        (fma 0.3333333333333333 x 0.16666666666666666))
                       (fabs B)
                       (/ (- 1.0 x) (fabs B)))
                      (/ 1.0 (sin (fabs B))))))
                  double code(double B, double x) {
                  	double tmp;
                  	if (fabs(B) <= 2.3) {
                  		tmp = fma(fma((fma(0.022222222222222223, x, 0.019444444444444445) * fabs(B)), fabs(B), fma(0.3333333333333333, x, 0.16666666666666666)), fabs(B), ((1.0 - x) / fabs(B)));
                  	} else {
                  		tmp = 1.0 / sin(fabs(B));
                  	}
                  	return copysign(1.0, B) * tmp;
                  }
                  
                  function code(B, x)
                  	tmp = 0.0
                  	if (abs(B) <= 2.3)
                  		tmp = fma(fma(Float64(fma(0.022222222222222223, x, 0.019444444444444445) * abs(B)), abs(B), fma(0.3333333333333333, x, 0.16666666666666666)), abs(B), Float64(Float64(1.0 - x) / abs(B)));
                  	else
                  		tmp = Float64(1.0 / sin(abs(B)));
                  	end
                  	return Float64(copysign(1.0, B) * tmp)
                  end
                  
                  code[B_, x_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[B]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[B], $MachinePrecision], 2.3], N[(N[(N[(N[(0.022222222222222223 * x + 0.019444444444444445), $MachinePrecision] * N[Abs[B], $MachinePrecision]), $MachinePrecision] * N[Abs[B], $MachinePrecision] + N[(0.3333333333333333 * x + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[Abs[B], $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / N[Abs[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[N[Abs[B], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                  
                  \mathsf{copysign}\left(1, B\right) \cdot \begin{array}{l}
                  \mathbf{if}\;\left|B\right| \leq 2.3:\\
                  \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.022222222222222223, x, 0.019444444444444445\right) \cdot \left|B\right|, \left|B\right|, \mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right)\right), \left|B\right|, \frac{1 - x}{\left|B\right|}\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{1}{\sin \left(\left|B\right|\right)}\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if B < 2.2999999999999998

                    1. Initial program 99.7%

                      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                    2. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                      2. +-commutativeN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                      3. lift-neg.f64N/A

                        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                      4. sub-flip-reverseN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      5. lower--.f6499.7

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      6. lift-*.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                      7. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                      8. mult-flip-revN/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                      9. lower-/.f6499.8

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    3. Applied rewrites99.8%

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                    4. Taylor expanded in B around 0

                      \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \left(\frac{1}{3} \cdot x + {B}^{2} \cdot \left(\frac{7}{360} + \left(\frac{-1}{9} \cdot x + \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}{B}} \]
                    5. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \left(\frac{1}{3} \cdot x + {B}^{2} \cdot \left(\frac{7}{360} + \left(\frac{-1}{9} \cdot x + \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}{\color{blue}{B}} \]
                    6. Applied rewrites50.6%

                      \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + \mathsf{fma}\left(0.3333333333333333, x, {B}^{2} \cdot \left(0.019444444444444445 + \mathsf{fma}\left(-0.1111111111111111, x, 0.13333333333333333 \cdot x\right)\right)\right)\right)\right) - x}{B}} \]
                    7. Step-by-step derivation
                      1. lift-/.f64N/A

                        \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}{\color{blue}{B}} \]
                      2. div-flipN/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{B}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}}} \]
                      3. lower-unsound-/.f64N/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{B}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}}} \]
                      4. lower-unsound-/.f6450.5

                        \[\leadsto \frac{1}{\frac{B}{\color{blue}{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + \mathsf{fma}\left(0.3333333333333333, x, {B}^{2} \cdot \left(0.019444444444444445 + \mathsf{fma}\left(-0.1111111111111111, x, 0.13333333333333333 \cdot x\right)\right)\right)\right)\right) - x}}} \]
                      5. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{B}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - \color{blue}{x}}} \]
                      6. lift-+.f64N/A

                        \[\leadsto \frac{1}{\frac{B}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right)\right) - x}} \]
                      7. +-commutativeN/A

                        \[\leadsto \frac{1}{\frac{B}{\left({B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right) + 1\right) - x}} \]
                      8. associate--l+N/A

                        \[\leadsto \frac{1}{\frac{B}{{B}^{2} \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{1}{3}, x, {B}^{2} \cdot \left(\frac{7}{360} + \mathsf{fma}\left(\frac{-1}{9}, x, \frac{2}{15} \cdot x\right)\right)\right)\right) + \color{blue}{\left(1 - x\right)}}} \]
                    8. Applied rewrites50.5%

                      \[\leadsto \frac{1}{\color{blue}{\frac{B}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.022222222222222223, x, 0.019444444444444445\right) \cdot B, B, \mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right)\right) \cdot B, B, 1 - x\right)}}} \]
                    9. Step-by-step derivation
                      1. lift-/.f64N/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{B}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B, B, 1 - x\right)}}} \]
                      2. lift-/.f64N/A

                        \[\leadsto \frac{1}{\frac{B}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B, B, 1 - x\right)}}} \]
                      3. div-flip-revN/A

                        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B, B, 1 - x\right)}{\color{blue}{B}} \]
                      4. lift-fma.f64N/A

                        \[\leadsto \frac{\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B\right) \cdot B + \left(1 - x\right)}{B} \]
                      5. add-to-fraction-revN/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B + \color{blue}{\frac{1 - x}{B}} \]
                      6. lift-*.f64N/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right) \cdot B + \frac{\color{blue}{1 - x}}{B} \]
                      7. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{45}, x, \frac{7}{360}\right) \cdot B, B, \mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right)\right), \color{blue}{B}, \frac{1 - x}{B}\right) \]
                      8. lower-/.f6450.6

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.022222222222222223, x, 0.019444444444444445\right) \cdot B, B, \mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right)\right), B, \frac{1 - x}{B}\right) \]
                    10. Applied rewrites50.6%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.022222222222222223, x, 0.019444444444444445\right) \cdot B, B, \mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right)\right), \color{blue}{B}, \frac{1 - x}{B}\right) \]

                    if 2.2999999999999998 < B

                    1. Initial program 99.7%

                      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                    2. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                      2. +-commutativeN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                      3. lift-neg.f64N/A

                        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                      4. sub-flip-reverseN/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      5. lower--.f6499.7

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                      6. lift-*.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                      7. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                      8. mult-flip-revN/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                      9. lower-/.f6499.8

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    3. Applied rewrites99.8%

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                    4. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                      2. lift-/.f64N/A

                        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                      3. sub-to-fractionN/A

                        \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                      4. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{\frac{1}{\sin B} \cdot \tan B - x}{\tan B}} \]
                      5. lower--.f64N/A

                        \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \tan B - x}}{\tan B} \]
                      6. lift-tan.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                      7. tan-quotN/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
                      8. lift-sin.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
                      9. lift-cos.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
                      10. associate-*r/N/A

                        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sin B} \cdot \sin B}{\cos B}} - x}{\tan B} \]
                      11. lift-/.f64N/A

                        \[\leadsto \frac{\frac{\color{blue}{\frac{1}{\sin B}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                      12. inv-powN/A

                        \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{-1}} \cdot \sin B}{\cos B} - x}{\tan B} \]
                      13. pow-plusN/A

                        \[\leadsto \frac{\frac{\color{blue}{{\sin B}^{\left(-1 + 1\right)}}}{\cos B} - x}{\tan B} \]
                      14. metadata-evalN/A

                        \[\leadsto \frac{\frac{{\sin B}^{\color{blue}{0}}}{\cos B} - x}{\tan B} \]
                      15. metadata-evalN/A

                        \[\leadsto \frac{\frac{\color{blue}{1}}{\cos B} - x}{\tan B} \]
                      16. lower-/.f6499.7

                        \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                    5. Applied rewrites99.7%

                      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
                    6. Step-by-step derivation
                      1. lift-/.f64N/A

                        \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                      2. mult-flipN/A

                        \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{\cos B}} - x}{\tan B} \]
                      3. metadata-evalN/A

                        \[\leadsto \frac{\color{blue}{{\sin B}^{0}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                      4. metadata-evalN/A

                        \[\leadsto \frac{{\sin B}^{\color{blue}{\left(-1 + 1\right)}} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                      5. pow-plusN/A

                        \[\leadsto \frac{\color{blue}{\left({\sin B}^{-1} \cdot \sin B\right)} \cdot \frac{1}{\cos B} - x}{\tan B} \]
                      6. inv-powN/A

                        \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
                      7. lift-/.f64N/A

                        \[\leadsto \frac{\left(\color{blue}{\frac{1}{\sin B}} \cdot \sin B\right) \cdot \frac{1}{\cos B} - x}{\tan B} \]
                      8. lift-/.f64N/A

                        \[\leadsto \frac{\left(\frac{1}{\sin B} \cdot \sin B\right) \cdot \color{blue}{\frac{1}{\cos B}} - x}{\tan B} \]
                      9. associate-*r*N/A

                        \[\leadsto \frac{\color{blue}{\frac{1}{\sin B} \cdot \left(\sin B \cdot \frac{1}{\cos B}\right)} - x}{\tan B} \]
                      10. lift-/.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \left(\sin B \cdot \color{blue}{\frac{1}{\cos B}}\right) - x}{\tan B} \]
                      11. mult-flipN/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\frac{\sin B}{\cos B}} - x}{\tan B} \]
                      12. lift-sin.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\color{blue}{\sin B}}{\cos B} - x}{\tan B} \]
                      13. lift-cos.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \frac{\sin B}{\color{blue}{\cos B}} - x}{\tan B} \]
                      14. quot-tanN/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                      15. lift-tan.f64N/A

                        \[\leadsto \frac{\frac{1}{\sin B} \cdot \color{blue}{\tan B} - x}{\tan B} \]
                      16. lift-/.f64N/A

                        \[\leadsto \frac{\color{blue}{\frac{1}{\sin B}} \cdot \tan B - x}{\tan B} \]
                      17. associate-*l/N/A

                        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \tan B}{\sin B}} - x}{\tan B} \]
                      18. *-lft-identityN/A

                        \[\leadsto \frac{\frac{\color{blue}{\tan B}}{\sin B} - x}{\tan B} \]
                      19. lower-/.f6499.8

                        \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
                    7. Applied rewrites99.8%

                      \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B}} - x}{\tan B} \]
                    8. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{\frac{1}{\sin B}} \]
                    9. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{1}{\color{blue}{\sin B}} \]
                      2. lower-sin.f6450.3

                        \[\leadsto \frac{1}{\sin B} \]
                    10. Applied rewrites50.3%

                      \[\leadsto \color{blue}{\frac{1}{\sin B}} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 8: 50.8% accurate, 3.5× speedup?

                  \[\mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                  (FPCore (B x)
                   :precision binary64
                   (fma
                    0.16666666666666666
                    B
                    (fma x (- (* 0.3333333333333333 B) (/ 1.0 B)) (/ 1.0 B))))
                  double code(double B, double x) {
                  	return fma(0.16666666666666666, B, fma(x, ((0.3333333333333333 * B) - (1.0 / B)), (1.0 / B)));
                  }
                  
                  function code(B, x)
                  	return fma(0.16666666666666666, B, fma(x, Float64(Float64(0.3333333333333333 * B) - Float64(1.0 / B)), Float64(1.0 / B)))
                  end
                  
                  code[B_, x_] := N[(0.16666666666666666 * B + N[(x * N[(N[(0.3333333333333333 * B), $MachinePrecision] - N[(1.0 / B), $MachinePrecision]), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right)
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                    3. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                    4. sub-flip-reverseN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    5. lower--.f6499.7

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                    7. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    9. lower-/.f6499.8

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                  3. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                  4. Taylor expanded in B around 0

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B}} \]
                  5. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{\color{blue}{B}} \]
                    2. lower--.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    3. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    5. lower-pow.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    6. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    7. lower-*.f6450.8

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B} \]
                  6. Applied rewrites50.8%

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B}} \]
                  7. Taylor expanded in x around 0

                    \[\leadsto \frac{1}{6} \cdot B + \color{blue}{\left(x \cdot \left(\frac{1}{3} \cdot B - \frac{1}{B}\right) + \frac{1}{B}\right)} \]
                  8. Step-by-step derivation
                    1. lower-fma.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, x \cdot \left(\frac{1}{3} \cdot B - \frac{1}{B}\right) + \frac{1}{B}\right) \]
                    2. lower-fma.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    3. lower--.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    4. lower-*.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    5. lower-/.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    6. lower-/.f6450.8

                      \[\leadsto \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                  9. Applied rewrites50.8%

                    \[\leadsto \mathsf{fma}\left(0.16666666666666666, \color{blue}{B}, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                  10. Add Preprocessing

                  Alternative 9: 50.8% accurate, 4.1× speedup?

                  \[\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1 - x\right)}{B} \]
                  (FPCore (B x)
                   :precision binary64
                   (/ (fma (fma 0.3333333333333333 x 0.16666666666666666) (* B B) (- 1.0 x)) B))
                  double code(double B, double x) {
                  	return fma(fma(0.3333333333333333, x, 0.16666666666666666), (B * B), (1.0 - x)) / B;
                  }
                  
                  function code(B, x)
                  	return Float64(fma(fma(0.3333333333333333, x, 0.16666666666666666), Float64(B * B), Float64(1.0 - x)) / B)
                  end
                  
                  code[B_, x_] := N[(N[(N[(0.3333333333333333 * x + 0.16666666666666666), $MachinePrecision] * N[(B * B), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]
                  
                  \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1 - x\right)}{B}
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                    3. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                    4. sub-flip-reverseN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    5. lower--.f6499.7

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                    7. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    9. lower-/.f6499.8

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                  3. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                  4. Taylor expanded in B around 0

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B}} \]
                  5. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{\color{blue}{B}} \]
                    2. lower--.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    3. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    5. lower-pow.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    6. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    7. lower-*.f6450.8

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B} \]
                  6. Applied rewrites50.8%

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B}} \]
                  7. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    2. lift-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    3. +-commutativeN/A

                      \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + 1\right) - x}{B} \]
                    4. associate--l+N/A

                      \[\leadsto \frac{{B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + \left(1 - x\right)}{B} \]
                    5. lift-*.f64N/A

                      \[\leadsto \frac{{B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + \left(1 - x\right)}{B} \]
                    6. *-commutativeN/A

                      \[\leadsto \frac{\left(\frac{1}{6} + \frac{1}{3} \cdot x\right) \cdot {B}^{2} + \left(1 - x\right)}{B} \]
                    7. lift--.f64N/A

                      \[\leadsto \frac{\left(\frac{1}{6} + \frac{1}{3} \cdot x\right) \cdot {B}^{2} + \left(1 - x\right)}{B} \]
                    8. lower-fma.f6450.8

                      \[\leadsto \frac{\mathsf{fma}\left(0.16666666666666666 + 0.3333333333333333 \cdot x, {B}^{2}, 1 - x\right)}{B} \]
                    9. lift-+.f64N/A

                      \[\leadsto \frac{\mathsf{fma}\left(\frac{1}{6} + \frac{1}{3} \cdot x, {B}^{2}, 1 - x\right)}{B} \]
                    10. +-commutativeN/A

                      \[\leadsto \frac{\mathsf{fma}\left(\frac{1}{3} \cdot x + \frac{1}{6}, {B}^{2}, 1 - x\right)}{B} \]
                    11. lift-*.f64N/A

                      \[\leadsto \frac{\mathsf{fma}\left(\frac{1}{3} \cdot x + \frac{1}{6}, {B}^{2}, 1 - x\right)}{B} \]
                    12. lower-fma.f6450.8

                      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), {B}^{2}, 1 - x\right)}{B} \]
                    13. lift-pow.f64N/A

                      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right), {B}^{2}, 1 - x\right)}{B} \]
                    14. unpow2N/A

                      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{3}, x, \frac{1}{6}\right), B \cdot B, 1 - x\right)}{B} \]
                    15. lower-*.f6450.8

                      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1 - x\right)}{B} \]
                  8. Applied rewrites50.8%

                    \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1 - x\right)}{B} \]
                  9. Add Preprocessing

                  Alternative 10: 50.8% accurate, 4.6× speedup?

                  \[\mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, \frac{-1}{B}, \frac{1}{B}\right)\right) \]
                  (FPCore (B x)
                   :precision binary64
                   (fma 0.16666666666666666 B (fma x (/ -1.0 B) (/ 1.0 B))))
                  double code(double B, double x) {
                  	return fma(0.16666666666666666, B, fma(x, (-1.0 / B), (1.0 / B)));
                  }
                  
                  function code(B, x)
                  	return fma(0.16666666666666666, B, fma(x, Float64(-1.0 / B), Float64(1.0 / B)))
                  end
                  
                  code[B_, x_] := N[(0.16666666666666666 * B + N[(x * N[(-1.0 / B), $MachinePrecision] + N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, \frac{-1}{B}, \frac{1}{B}\right)\right)
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]
                    3. lift-neg.f64N/A

                      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
                    4. sub-flip-reverseN/A

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    5. lower--.f6499.7

                      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
                    6. lift-*.f64N/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
                    7. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sin B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
                    8. mult-flip-revN/A

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                    9. lower-/.f6499.8

                      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\tan B}} \]
                  3. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
                  4. Taylor expanded in B around 0

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B}} \]
                  5. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{\color{blue}{B}} \]
                    2. lower--.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    3. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    5. lower-pow.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    6. lower-+.f64N/A

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right) - x}{B} \]
                    7. lower-*.f6450.8

                      \[\leadsto \frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B} \]
                  6. Applied rewrites50.8%

                    \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right)\right) - x}{B}} \]
                  7. Taylor expanded in x around 0

                    \[\leadsto \frac{1}{6} \cdot B + \color{blue}{\left(x \cdot \left(\frac{1}{3} \cdot B - \frac{1}{B}\right) + \frac{1}{B}\right)} \]
                  8. Step-by-step derivation
                    1. lower-fma.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, x \cdot \left(\frac{1}{3} \cdot B - \frac{1}{B}\right) + \frac{1}{B}\right) \]
                    2. lower-fma.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    3. lower--.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    4. lower-*.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    5. lower-/.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{1}{3} \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                    6. lower-/.f6450.8

                      \[\leadsto \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                  9. Applied rewrites50.8%

                    \[\leadsto \mathsf{fma}\left(0.16666666666666666, \color{blue}{B}, \mathsf{fma}\left(x, 0.3333333333333333 \cdot B - \frac{1}{B}, \frac{1}{B}\right)\right) \]
                  10. Taylor expanded in B around 0

                    \[\leadsto \mathsf{fma}\left(\frac{1}{6}, B, \mathsf{fma}\left(x, \frac{-1}{B}, \frac{1}{B}\right)\right) \]
                  11. Step-by-step derivation
                    1. lower-/.f6450.8

                      \[\leadsto \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, \frac{-1}{B}, \frac{1}{B}\right)\right) \]
                  12. Applied rewrites50.8%

                    \[\leadsto \mathsf{fma}\left(0.16666666666666666, B, \mathsf{fma}\left(x, \frac{-1}{B}, \frac{1}{B}\right)\right) \]
                  13. Add Preprocessing

                  Alternative 11: 50.8% accurate, 11.6× speedup?

                  \[\frac{1 - x}{B} \]
                  (FPCore (B x) :precision binary64 (/ (- 1.0 x) B))
                  double code(double B, double x) {
                  	return (1.0 - x) / B;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(b, x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: b
                      real(8), intent (in) :: x
                      code = (1.0d0 - x) / b
                  end function
                  
                  public static double code(double B, double x) {
                  	return (1.0 - x) / B;
                  }
                  
                  def code(B, x):
                  	return (1.0 - x) / B
                  
                  function code(B, x)
                  	return Float64(Float64(1.0 - x) / B)
                  end
                  
                  function tmp = code(B, x)
                  	tmp = (1.0 - x) / B;
                  end
                  
                  code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]
                  
                  \frac{1 - x}{B}
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Taylor expanded in B around 0

                    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
                  3. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{1 - x}{\color{blue}{B}} \]
                    2. lower--.f6450.8

                      \[\leadsto \frac{1 - x}{B} \]
                  4. Applied rewrites50.8%

                    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
                  5. Add Preprocessing

                  Alternative 12: 26.4% accurate, 15.2× speedup?

                  \[\frac{-x}{B} \]
                  (FPCore (B x) :precision binary64 (/ (- x) B))
                  double code(double B, double x) {
                  	return -x / B;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(b, x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: b
                      real(8), intent (in) :: x
                      code = -x / b
                  end function
                  
                  public static double code(double B, double x) {
                  	return -x / B;
                  }
                  
                  def code(B, x):
                  	return -x / B
                  
                  function code(B, x)
                  	return Float64(Float64(-x) / B)
                  end
                  
                  function tmp = code(B, x)
                  	tmp = -x / B;
                  end
                  
                  code[B_, x_] := N[((-x) / B), $MachinePrecision]
                  
                  \frac{-x}{B}
                  
                  Derivation
                  1. Initial program 99.7%

                    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
                  2. Taylor expanded in B around 0

                    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
                  3. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{1 - x}{\color{blue}{B}} \]
                    2. lower--.f6450.8

                      \[\leadsto \frac{1 - x}{B} \]
                  4. Applied rewrites50.8%

                    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
                  5. Step-by-step derivation
                    1. lift-/.f64N/A

                      \[\leadsto \frac{1 - x}{\color{blue}{B}} \]
                    2. mult-flipN/A

                      \[\leadsto \left(1 - x\right) \cdot \color{blue}{\frac{1}{B}} \]
                    3. *-commutativeN/A

                      \[\leadsto \frac{1}{B} \cdot \color{blue}{\left(1 - x\right)} \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{1}{B} \cdot \color{blue}{\left(1 - x\right)} \]
                    5. lower-/.f6450.7

                      \[\leadsto \frac{1}{B} \cdot \left(\color{blue}{1} - x\right) \]
                  6. Applied rewrites50.7%

                    \[\leadsto \frac{1}{B} \cdot \color{blue}{\left(1 - x\right)} \]
                  7. Taylor expanded in x around inf

                    \[\leadsto -1 \cdot \color{blue}{\frac{x}{B}} \]
                  8. Step-by-step derivation
                    1. lower-*.f64N/A

                      \[\leadsto -1 \cdot \frac{x}{\color{blue}{B}} \]
                    2. lower-/.f6426.4

                      \[\leadsto -1 \cdot \frac{x}{B} \]
                  9. Applied rewrites26.4%

                    \[\leadsto -1 \cdot \color{blue}{\frac{x}{B}} \]
                  10. Step-by-step derivation
                    1. lift-*.f64N/A

                      \[\leadsto -1 \cdot \frac{x}{\color{blue}{B}} \]
                    2. mul-1-negN/A

                      \[\leadsto \mathsf{neg}\left(\frac{x}{B}\right) \]
                    3. lift-/.f64N/A

                      \[\leadsto \mathsf{neg}\left(\frac{x}{B}\right) \]
                    4. distribute-neg-fracN/A

                      \[\leadsto \frac{\mathsf{neg}\left(x\right)}{B} \]
                    5. lift-neg.f64N/A

                      \[\leadsto \frac{-x}{B} \]
                    6. lower-/.f6426.4

                      \[\leadsto \frac{-x}{B} \]
                  11. Applied rewrites26.4%

                    \[\leadsto \color{blue}{\frac{-x}{B}} \]
                  12. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2025175 
                  (FPCore (B x)
                    :name "VandenBroeck and Keller, Equation (24)"
                    :precision binary64
                    (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))