tan-example (used to crash)

Percentage Accurate: 78.9% → 99.7%
Time: 8.4s
Alternatives: 16
Speedup: 1.0×

Specification

?
\[\left(\left(\left(x = 0 \lor 0.5884142 \leq x \land x \leq 505.5909\right) \land \left(-1.796658 \cdot 10^{+308} \leq y \land y \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq y \land y \leq 1.751224 \cdot 10^{+308}\right)\right) \land \left(-1.776707 \cdot 10^{+308} \leq z \land z \leq -8.599796 \cdot 10^{-310} \lor 3.293145 \cdot 10^{-311} \leq z \land z \leq 1.725154 \cdot 10^{+308}\right)\right) \land \left(-1.796658 \cdot 10^{+308} \leq a \land a \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq a \land a \leq 1.751224 \cdot 10^{+308}\right)\]
\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}

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 16 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: 78.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}

Alternative 1: 99.7% accurate, 0.2× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\left(\frac{\tan y}{1 - \frac{\sin y}{\cos y} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (-
   (+
    (/ (tan y) (- 1.0 (* (/ (sin y) (cos y)) (tan z))))
    (/ (tan z) (- 1.0 (* (tan y) (tan z)))))
   (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + (((tan(y) / (1.0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0 - (tan(y) * tan(z))))) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (((tan(y) / (1.0d0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0d0 - (tan(y) * tan(z))))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x + (((Math.tan(y) / (1.0 - ((Math.sin(y) / Math.cos(y)) * Math.tan(z)))) + (Math.tan(z) / (1.0 - (Math.tan(y) * Math.tan(z))))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + (((math.tan(y) / (1.0 - ((math.sin(y) / math.cos(y)) * math.tan(z)))) + (math.tan(z) / (1.0 - (math.tan(y) * math.tan(z))))) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) / Float64(1.0 - Float64(Float64(sin(y) / cos(y)) * tan(z)))) + Float64(tan(z) / Float64(1.0 - Float64(tan(y) * tan(z))))) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) / (1.0 - ((sin(y) / cos(y)) * tan(z)))) + (tan(z) / (1.0 - (tan(y) * tan(z))))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\left(\frac{\tan y}{1 - \frac{\sin y}{\cos y} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right)
\end{array}
Derivation
  1. Initial program 78.9%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
    2. lift-tan.f64N/A

      \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
    3. tan-sumN/A

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    4. quot-tanN/A

      \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
    5. quot-tanN/A

      \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
    6. div-addN/A

      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
    7. lower-+.f64N/A

      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
  3. Applied rewrites99.7%

    \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
  4. Step-by-step derivation
    1. lift-tan.f64N/A

      \[\leadsto x + \left(\left(\frac{\tan y}{1 - \color{blue}{\tan y} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \]
    2. tan-quotN/A

      \[\leadsto x + \left(\left(\frac{\tan y}{1 - \color{blue}{\frac{\sin y}{\cos y}} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \]
    3. lower-/.f64N/A

      \[\leadsto x + \left(\left(\frac{\tan y}{1 - \color{blue}{\frac{\sin y}{\cos y}} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \]
    4. lower-sin.f64N/A

      \[\leadsto x + \left(\left(\frac{\tan y}{1 - \frac{\color{blue}{\sin y}}{\cos y} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \]
    5. lower-cos.f6499.7

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

    \[\leadsto x + \left(\left(\frac{\tan y}{1 - \color{blue}{\frac{\sin y}{\cos y}} \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right) - \tan a\right) \]
  6. Add Preprocessing

Alternative 2: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := 1 - \tan y \cdot \tan z\\ x + \left(\left(\frac{\tan y}{t\_0} + \frac{\tan z}{t\_0}\right) - \tan a\right) \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (- 1.0 (* (tan y) (tan z)))))
   (+ x (- (+ (/ (tan y) t_0) (/ (tan z) t_0)) (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = 1.0 - (tan(y) * tan(z));
	return x + (((tan(y) / t_0) + (tan(z) / t_0)) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: t_0
    t_0 = 1.0d0 - (tan(y) * tan(z))
    code = x + (((tan(y) / t_0) + (tan(z) / t_0)) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double t_0 = 1.0 - (Math.tan(y) * Math.tan(z));
	return x + (((Math.tan(y) / t_0) + (Math.tan(z) / t_0)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	t_0 = 1.0 - (math.tan(y) * math.tan(z))
	return x + (((math.tan(y) / t_0) + (math.tan(z) / t_0)) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(1.0 - Float64(tan(y) * tan(z)))
	return Float64(x + Float64(Float64(Float64(tan(y) / t_0) + Float64(tan(z) / t_0)) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	t_0 = 1.0 - (tan(y) * tan(z));
	tmp = x + (((tan(y) / t_0) + (tan(z) / t_0)) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[Tan[z], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := 1 - \tan y \cdot \tan z\\
x + \left(\left(\frac{\tan y}{t\_0} + \frac{\tan z}{t\_0}\right) - \tan a\right)
\end{array}
\end{array}
Derivation
  1. Initial program 78.9%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
    2. lift-tan.f64N/A

      \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
    3. tan-sumN/A

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    4. quot-tanN/A

      \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
    5. quot-tanN/A

      \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
    6. div-addN/A

      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
    7. lower-+.f64N/A

      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
  3. Applied rewrites99.7%

    \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
  4. Add Preprocessing

Alternative 3: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x + (((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + (((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Derivation
  1. Initial program 78.9%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
    2. lift-tan.f64N/A

      \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
    3. +-commutativeN/A

      \[\leadsto x + \left(\tan \color{blue}{\left(z + y\right)} - \tan a\right) \]
    4. tan-sumN/A

      \[\leadsto x + \left(\color{blue}{\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}} - \tan a\right) \]
    5. lower-/.f64N/A

      \[\leadsto x + \left(\color{blue}{\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}} - \tan a\right) \]
    6. quot-tanN/A

      \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin z}{\cos z}} + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    7. quot-tanN/A

      \[\leadsto x + \left(\frac{\frac{\sin z}{\cos z} + \color{blue}{\frac{\sin y}{\cos y}}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    8. lower-+.f64N/A

      \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin z}{\cos z} + \frac{\sin y}{\cos y}}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    9. quot-tanN/A

      \[\leadsto x + \left(\frac{\color{blue}{\tan z} + \frac{\sin y}{\cos y}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    10. lower-tan.f64N/A

      \[\leadsto x + \left(\frac{\color{blue}{\tan z} + \frac{\sin y}{\cos y}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    11. quot-tanN/A

      \[\leadsto x + \left(\frac{\tan z + \color{blue}{\tan y}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    12. lower-tan.f64N/A

      \[\leadsto x + \left(\frac{\tan z + \color{blue}{\tan y}}{1 - \tan z \cdot \tan y} - \tan a\right) \]
    13. lower--.f64N/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1 - \tan z \cdot \tan y}} - \tan a\right) \]
    14. quot-tanN/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\frac{\sin z}{\cos z}} \cdot \tan y} - \tan a\right) \]
    15. quot-tanN/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \frac{\sin z}{\cos z} \cdot \color{blue}{\frac{\sin y}{\cos y}}} - \tan a\right) \]
    16. lower-*.f64N/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\frac{\sin z}{\cos z} \cdot \frac{\sin y}{\cos y}}} - \tan a\right) \]
    17. quot-tanN/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z} \cdot \frac{\sin y}{\cos y}} - \tan a\right) \]
    18. lower-tan.f64N/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z} \cdot \frac{\sin y}{\cos y}} - \tan a\right) \]
    19. quot-tanN/A

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \color{blue}{\tan y}} - \tan a\right) \]
    20. lower-tan.f6499.7

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \color{blue}{\tan y}} - \tan a\right) \]
  3. Applied rewrites99.7%

    \[\leadsto x + \left(\color{blue}{\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}} - \tan a\right) \]
  4. Add Preprocessing

Alternative 4: 59.1% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := x - \tan a\\ \mathbf{if}\;\tan a \leq -2 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\tan a \leq 0.18:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (- x (tan a))))
   (if (<= (tan a) -2e-5)
     t_0
     (if (<= (tan a) 0.18) (+ x (- (tan (+ y z)) a)) t_0))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = x - tan(a);
	double tmp;
	if (tan(a) <= -2e-5) {
		tmp = t_0;
	} else if (tan(a) <= 0.18) {
		tmp = x + (tan((y + z)) - a);
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x - tan(a)
    if (tan(a) <= (-2d-5)) then
        tmp = t_0
    else if (tan(a) <= 0.18d0) then
        tmp = x + (tan((y + z)) - a)
    else
        tmp = t_0
    end if
    code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double t_0 = x - Math.tan(a);
	double tmp;
	if (Math.tan(a) <= -2e-5) {
		tmp = t_0;
	} else if (Math.tan(a) <= 0.18) {
		tmp = x + (Math.tan((y + z)) - a);
	} else {
		tmp = t_0;
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	t_0 = x - math.tan(a)
	tmp = 0
	if math.tan(a) <= -2e-5:
		tmp = t_0
	elif math.tan(a) <= 0.18:
		tmp = x + (math.tan((y + z)) - a)
	else:
		tmp = t_0
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(x - tan(a))
	tmp = 0.0
	if (tan(a) <= -2e-5)
		tmp = t_0;
	elseif (tan(a) <= 0.18)
		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
	else
		tmp = t_0;
	end
	return tmp
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
	t_0 = x - tan(a);
	tmp = 0.0;
	if (tan(a) <= -2e-5)
		tmp = t_0;
	elseif (tan(a) <= 0.18)
		tmp = x + (tan((y + z)) - a);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -2e-5], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.18], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;\tan a \leq -2 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\tan a \leq 0.18:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (tan.f64 a) < -2.00000000000000016e-5 or 0.17999999999999999 < (tan.f64 a)

    1. Initial program 78.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
      3. lower-+.f64N/A

        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
      4. quot-tanN/A

        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
      5. lower-tan.f64N/A

        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
      6. tan-quotN/A

        \[\leadsto \left(\tan z + x\right) - \tan a \]
      7. lift-tan.f6459.4

        \[\leadsto \left(\tan z + x\right) - \tan a \]
    4. Applied rewrites59.4%

      \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
    5. Taylor expanded in x around inf

      \[\leadsto x - \tan \color{blue}{a} \]
    6. Step-by-step derivation
      1. Applied rewrites41.8%

        \[\leadsto x - \tan \color{blue}{a} \]

      if -2.00000000000000016e-5 < (tan.f64 a) < 0.17999999999999999

      1. Initial program 79.2%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Taylor expanded in a around 0

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
      3. Step-by-step derivation
        1. Applied rewrites74.9%

          \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 5: 78.8% accurate, 1.0× speedup?

      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -4 \cdot 10^{-49}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
      (FPCore (x y z a)
       :precision binary64
       (if (<= (+ y z) -4e-49) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
      assert(x < y && y < z && z < a);
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -4e-49) {
      		tmp = x + (tan(y) - tan(a));
      	} else {
      		tmp = x + (tan(z) - tan(a));
      	}
      	return tmp;
      }
      
      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
      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(x, y, z, a)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          real(8) :: tmp
          if ((y + z) <= (-4d-49)) then
              tmp = x + (tan(y) - tan(a))
          else
              tmp = x + (tan(z) - tan(a))
          end if
          code = tmp
      end function
      
      assert x < y && y < z && z < a;
      public static double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -4e-49) {
      		tmp = x + (Math.tan(y) - Math.tan(a));
      	} else {
      		tmp = x + (Math.tan(z) - Math.tan(a));
      	}
      	return tmp;
      }
      
      [x, y, z, a] = sort([x, y, z, a])
      def code(x, y, z, a):
      	tmp = 0
      	if (y + z) <= -4e-49:
      		tmp = x + (math.tan(y) - math.tan(a))
      	else:
      		tmp = x + (math.tan(z) - math.tan(a))
      	return tmp
      
      x, y, z, a = sort([x, y, z, a])
      function code(x, y, z, a)
      	tmp = 0.0
      	if (Float64(y + z) <= -4e-49)
      		tmp = Float64(x + Float64(tan(y) - tan(a)));
      	else
      		tmp = Float64(x + Float64(tan(z) - tan(a)));
      	end
      	return tmp
      end
      
      x, y, z, a = num2cell(sort([x, y, z, a])){:}
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if ((y + z) <= -4e-49)
      		tmp = x + (tan(y) - tan(a));
      	else
      		tmp = x + (tan(z) - tan(a));
      	end
      	tmp_2 = tmp;
      end
      
      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
      code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -4e-49], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
      \\
      \begin{array}{l}
      \mathbf{if}\;y + z \leq -4 \cdot 10^{-49}:\\
      \;\;\;\;x + \left(\tan y - \tan a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\tan z - \tan a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 y z) < -3.99999999999999975e-49

        1. Initial program 74.1%

          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
        2. Taylor expanded in y around inf

          \[\leadsto x + \left(\tan \color{blue}{y} - \tan a\right) \]
        3. Step-by-step derivation
          1. Applied rewrites74.0%

            \[\leadsto x + \left(\tan \color{blue}{y} - \tan a\right) \]

          if -3.99999999999999975e-49 < (+.f64 y z)

          1. Initial program 82.3%

            \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
          2. Taylor expanded in y around 0

            \[\leadsto x + \left(\tan \color{blue}{z} - \tan a\right) \]
          3. Step-by-step derivation
            1. Applied rewrites82.2%

              \[\leadsto x + \left(\tan \color{blue}{z} - \tan a\right) \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 6: 78.8% accurate, 1.0× speedup?

          \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -4 \cdot 10^{-49}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\tan z + \left(x - \tan a\right)\\ \end{array} \end{array} \]
          NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
          (FPCore (x y z a)
           :precision binary64
           (if (<= (+ y z) -4e-49) (+ x (- (tan y) (tan a))) (+ (tan z) (- x (tan a)))))
          assert(x < y && y < z && z < a);
          double code(double x, double y, double z, double a) {
          	double tmp;
          	if ((y + z) <= -4e-49) {
          		tmp = x + (tan(y) - tan(a));
          	} else {
          		tmp = tan(z) + (x - tan(a));
          	}
          	return tmp;
          }
          
          NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
          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(x, y, z, a)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8), intent (in) :: a
              real(8) :: tmp
              if ((y + z) <= (-4d-49)) then
                  tmp = x + (tan(y) - tan(a))
              else
                  tmp = tan(z) + (x - tan(a))
              end if
              code = tmp
          end function
          
          assert x < y && y < z && z < a;
          public static double code(double x, double y, double z, double a) {
          	double tmp;
          	if ((y + z) <= -4e-49) {
          		tmp = x + (Math.tan(y) - Math.tan(a));
          	} else {
          		tmp = Math.tan(z) + (x - Math.tan(a));
          	}
          	return tmp;
          }
          
          [x, y, z, a] = sort([x, y, z, a])
          def code(x, y, z, a):
          	tmp = 0
          	if (y + z) <= -4e-49:
          		tmp = x + (math.tan(y) - math.tan(a))
          	else:
          		tmp = math.tan(z) + (x - math.tan(a))
          	return tmp
          
          x, y, z, a = sort([x, y, z, a])
          function code(x, y, z, a)
          	tmp = 0.0
          	if (Float64(y + z) <= -4e-49)
          		tmp = Float64(x + Float64(tan(y) - tan(a)));
          	else
          		tmp = Float64(tan(z) + Float64(x - tan(a)));
          	end
          	return tmp
          end
          
          x, y, z, a = num2cell(sort([x, y, z, a])){:}
          function tmp_2 = code(x, y, z, a)
          	tmp = 0.0;
          	if ((y + z) <= -4e-49)
          		tmp = x + (tan(y) - tan(a));
          	else
          		tmp = tan(z) + (x - tan(a));
          	end
          	tmp_2 = tmp;
          end
          
          NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
          code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -4e-49], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;y + z \leq -4 \cdot 10^{-49}:\\
          \;\;\;\;x + \left(\tan y - \tan a\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\tan z + \left(x - \tan a\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (+.f64 y z) < -3.99999999999999975e-49

            1. Initial program 74.1%

              \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
            2. Taylor expanded in y around inf

              \[\leadsto x + \left(\tan \color{blue}{y} - \tan a\right) \]
            3. Step-by-step derivation
              1. Applied rewrites74.0%

                \[\leadsto x + \left(\tan \color{blue}{y} - \tan a\right) \]

              if -3.99999999999999975e-49 < (+.f64 y z)

              1. Initial program 82.3%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
              3. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. quot-tanN/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lower-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                7. lift-tan.f6482.2

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
              4. Applied rewrites82.2%

                \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
              5. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \color{blue}{\tan a} \]
                2. lift-+.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan \color{blue}{a} \]
                3. lift-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                4. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                5. lift-tan.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                6. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                7. associate--l+N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                8. lower-+.f64N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                9. tan-quotN/A

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

                  \[\leadsto \tan z + \left(\color{blue}{x} - \frac{\sin a}{\cos a}\right) \]
                11. lower--.f64N/A

                  \[\leadsto \tan z + \left(x - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
                12. tan-quotN/A

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
                13. lift-tan.f6482.2

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
              6. Applied rewrites82.2%

                \[\leadsto \tan z + \color{blue}{\left(x - \tan a\right)} \]
            4. Recombined 2 regimes into one program.
            5. Add Preprocessing

            Alternative 7: 78.7% accurate, 1.0× speedup?

            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-13}:\\ \;\;\;\;\left(\tan y + x\right) - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan z + \left(x - \tan a\right)\\ \end{array} \end{array} \]
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            (FPCore (x y z a)
             :precision binary64
             (if (<= (+ y z) -2e-13) (- (+ (tan y) x) (tan a)) (+ (tan z) (- x (tan a)))))
            assert(x < y && y < z && z < a);
            double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -2e-13) {
            		tmp = (tan(y) + x) - tan(a);
            	} else {
            		tmp = tan(z) + (x - tan(a));
            	}
            	return tmp;
            }
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            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(x, y, z, a)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: a
                real(8) :: tmp
                if ((y + z) <= (-2d-13)) then
                    tmp = (tan(y) + x) - tan(a)
                else
                    tmp = tan(z) + (x - tan(a))
                end if
                code = tmp
            end function
            
            assert x < y && y < z && z < a;
            public static double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -2e-13) {
            		tmp = (Math.tan(y) + x) - Math.tan(a);
            	} else {
            		tmp = Math.tan(z) + (x - Math.tan(a));
            	}
            	return tmp;
            }
            
            [x, y, z, a] = sort([x, y, z, a])
            def code(x, y, z, a):
            	tmp = 0
            	if (y + z) <= -2e-13:
            		tmp = (math.tan(y) + x) - math.tan(a)
            	else:
            		tmp = math.tan(z) + (x - math.tan(a))
            	return tmp
            
            x, y, z, a = sort([x, y, z, a])
            function code(x, y, z, a)
            	tmp = 0.0
            	if (Float64(y + z) <= -2e-13)
            		tmp = Float64(Float64(tan(y) + x) - tan(a));
            	else
            		tmp = Float64(tan(z) + Float64(x - tan(a)));
            	end
            	return tmp
            end
            
            x, y, z, a = num2cell(sort([x, y, z, a])){:}
            function tmp_2 = code(x, y, z, a)
            	tmp = 0.0;
            	if ((y + z) <= -2e-13)
            		tmp = (tan(y) + x) - tan(a);
            	else
            		tmp = tan(z) + (x - tan(a));
            	end
            	tmp_2 = tmp;
            end
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2e-13], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;y + z \leq -2 \cdot 10^{-13}:\\
            \;\;\;\;\left(\tan y + x\right) - \tan a\\
            
            \mathbf{else}:\\
            \;\;\;\;\tan z + \left(x - \tan a\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (+.f64 y z) < -2.0000000000000001e-13

              1. Initial program 72.4%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Taylor expanded in z around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
              3. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. quot-tanN/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lower-tan.f64N/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
                7. lift-tan.f6472.3

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
              4. Applied rewrites72.3%

                \[\leadsto \color{blue}{\left(\tan y + x\right) - \tan a} \]

              if -2.0000000000000001e-13 < (+.f64 y z)

              1. Initial program 83.0%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
              3. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. quot-tanN/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lower-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                7. lift-tan.f6482.9

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
              4. Applied rewrites82.9%

                \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
              5. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \color{blue}{\tan a} \]
                2. lift-+.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan \color{blue}{a} \]
                3. lift-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                4. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                5. lift-tan.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                6. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                7. associate--l+N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                8. lower-+.f64N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                9. tan-quotN/A

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

                  \[\leadsto \tan z + \left(\color{blue}{x} - \frac{\sin a}{\cos a}\right) \]
                11. lower--.f64N/A

                  \[\leadsto \tan z + \left(x - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
                12. tan-quotN/A

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
                13. lift-tan.f6482.9

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
              6. Applied rewrites82.9%

                \[\leadsto \tan z + \color{blue}{\left(x - \tan a\right)} \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 8: 68.7% accurate, 1.0× speedup?

            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -0.00015:\\ \;\;\;\;x + \tan \left(z + y\right)\\ \mathbf{else}:\\ \;\;\;\;\tan z + \left(x - \tan a\right)\\ \end{array} \end{array} \]
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            (FPCore (x y z a)
             :precision binary64
             (if (<= (+ y z) -0.00015) (+ x (tan (+ z y))) (+ (tan z) (- x (tan a)))))
            assert(x < y && y < z && z < a);
            double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -0.00015) {
            		tmp = x + tan((z + y));
            	} else {
            		tmp = tan(z) + (x - tan(a));
            	}
            	return tmp;
            }
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            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(x, y, z, a)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: a
                real(8) :: tmp
                if ((y + z) <= (-0.00015d0)) then
                    tmp = x + tan((z + y))
                else
                    tmp = tan(z) + (x - tan(a))
                end if
                code = tmp
            end function
            
            assert x < y && y < z && z < a;
            public static double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -0.00015) {
            		tmp = x + Math.tan((z + y));
            	} else {
            		tmp = Math.tan(z) + (x - Math.tan(a));
            	}
            	return tmp;
            }
            
            [x, y, z, a] = sort([x, y, z, a])
            def code(x, y, z, a):
            	tmp = 0
            	if (y + z) <= -0.00015:
            		tmp = x + math.tan((z + y))
            	else:
            		tmp = math.tan(z) + (x - math.tan(a))
            	return tmp
            
            x, y, z, a = sort([x, y, z, a])
            function code(x, y, z, a)
            	tmp = 0.0
            	if (Float64(y + z) <= -0.00015)
            		tmp = Float64(x + tan(Float64(z + y)));
            	else
            		tmp = Float64(tan(z) + Float64(x - tan(a)));
            	end
            	return tmp
            end
            
            x, y, z, a = num2cell(sort([x, y, z, a])){:}
            function tmp_2 = code(x, y, z, a)
            	tmp = 0.0;
            	if ((y + z) <= -0.00015)
            		tmp = x + tan((z + y));
            	else
            		tmp = tan(z) + (x - tan(a));
            	end
            	tmp_2 = tmp;
            end
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.00015], N[(x + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;y + z \leq -0.00015:\\
            \;\;\;\;x + \tan \left(z + y\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\tan z + \left(x - \tan a\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (+.f64 y z) < -1.49999999999999987e-4

              1. Initial program 71.8%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Taylor expanded in a around 0

                \[\leadsto x + \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} \]
              3. Step-by-step derivation
                1. tan-quotN/A

                  \[\leadsto x + \tan \left(y + z\right) \]
                2. lift-tan.f64N/A

                  \[\leadsto x + \tan \left(y + z\right) \]
                3. +-commutativeN/A

                  \[\leadsto x + \tan \left(z + y\right) \]
                4. lower-+.f6446.3

                  \[\leadsto x + \tan \left(z + y\right) \]
              4. Applied rewrites46.3%

                \[\leadsto x + \color{blue}{\tan \left(z + y\right)} \]

              if -1.49999999999999987e-4 < (+.f64 y z)

              1. Initial program 83.3%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
              3. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. quot-tanN/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lower-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                7. lift-tan.f6482.7

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
              4. Applied rewrites82.7%

                \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
              5. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \color{blue}{\tan a} \]
                2. lift-+.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan \color{blue}{a} \]
                3. lift-tan.f64N/A

                  \[\leadsto \left(\tan z + x\right) - \tan a \]
                4. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                5. lift-tan.f64N/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \tan a \]
                6. tan-quotN/A

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                7. associate--l+N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                8. lower-+.f64N/A

                  \[\leadsto \frac{\sin z}{\cos z} + \color{blue}{\left(x - \frac{\sin a}{\cos a}\right)} \]
                9. tan-quotN/A

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

                  \[\leadsto \tan z + \left(\color{blue}{x} - \frac{\sin a}{\cos a}\right) \]
                11. lower--.f64N/A

                  \[\leadsto \tan z + \left(x - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
                12. tan-quotN/A

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
                13. lift-tan.f6482.7

                  \[\leadsto \tan z + \left(x - \tan a\right) \]
              6. Applied rewrites82.7%

                \[\leadsto \tan z + \color{blue}{\left(x - \tan a\right)} \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 9: 78.9% accurate, 1.0× speedup?

            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            (FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
            assert(x < y && y < z && z < a);
            double code(double x, double y, double z, double a) {
            	return x + (tan((y + z)) - tan(a));
            }
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            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(x, y, z, a)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: a
                code = x + (tan((y + z)) - tan(a))
            end function
            
            assert x < y && y < z && z < a;
            public static double code(double x, double y, double z, double a) {
            	return x + (Math.tan((y + z)) - Math.tan(a));
            }
            
            [x, y, z, a] = sort([x, y, z, a])
            def code(x, y, z, a):
            	return x + (math.tan((y + z)) - math.tan(a))
            
            x, y, z, a = sort([x, y, z, a])
            function code(x, y, z, a)
            	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
            end
            
            x, y, z, a = num2cell(sort([x, y, z, a])){:}
            function tmp = code(x, y, z, a)
            	tmp = x + (tan((y + z)) - tan(a));
            end
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
            \\
            x + \left(\tan \left(y + z\right) - \tan a\right)
            \end{array}
            
            Derivation
            1. Initial program 78.9%

              \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
            2. Add Preprocessing

            Alternative 10: 59.1% accurate, 1.7× speedup?

            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -100000000:\\ \;\;\;\;x + \tan y\\ \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\ \;\;\;\;\left(y + x\right) - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan z + x\\ \end{array} \end{array} \]
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            (FPCore (x y z a)
             :precision binary64
             (if (<= (+ y z) -100000000.0)
               (+ x (tan y))
               (if (<= (+ y z) 4e-10) (- (+ y x) (tan a)) (+ (tan z) x))))
            assert(x < y && y < z && z < a);
            double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -100000000.0) {
            		tmp = x + tan(y);
            	} else if ((y + z) <= 4e-10) {
            		tmp = (y + x) - tan(a);
            	} else {
            		tmp = tan(z) + x;
            	}
            	return tmp;
            }
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            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(x, y, z, a)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: a
                real(8) :: tmp
                if ((y + z) <= (-100000000.0d0)) then
                    tmp = x + tan(y)
                else if ((y + z) <= 4d-10) then
                    tmp = (y + x) - tan(a)
                else
                    tmp = tan(z) + x
                end if
                code = tmp
            end function
            
            assert x < y && y < z && z < a;
            public static double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((y + z) <= -100000000.0) {
            		tmp = x + Math.tan(y);
            	} else if ((y + z) <= 4e-10) {
            		tmp = (y + x) - Math.tan(a);
            	} else {
            		tmp = Math.tan(z) + x;
            	}
            	return tmp;
            }
            
            [x, y, z, a] = sort([x, y, z, a])
            def code(x, y, z, a):
            	tmp = 0
            	if (y + z) <= -100000000.0:
            		tmp = x + math.tan(y)
            	elif (y + z) <= 4e-10:
            		tmp = (y + x) - math.tan(a)
            	else:
            		tmp = math.tan(z) + x
            	return tmp
            
            x, y, z, a = sort([x, y, z, a])
            function code(x, y, z, a)
            	tmp = 0.0
            	if (Float64(y + z) <= -100000000.0)
            		tmp = Float64(x + tan(y));
            	elseif (Float64(y + z) <= 4e-10)
            		tmp = Float64(Float64(y + x) - tan(a));
            	else
            		tmp = Float64(tan(z) + x);
            	end
            	return tmp
            end
            
            x, y, z, a = num2cell(sort([x, y, z, a])){:}
            function tmp_2 = code(x, y, z, a)
            	tmp = 0.0;
            	if ((y + z) <= -100000000.0)
            		tmp = x + tan(y);
            	elseif ((y + z) <= 4e-10)
            		tmp = (y + x) - tan(a);
            	else
            		tmp = tan(z) + x;
            	end
            	tmp_2 = tmp;
            end
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -100000000.0], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 4e-10], N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]]
            
            \begin{array}{l}
            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;y + z \leq -100000000:\\
            \;\;\;\;x + \tan y\\
            
            \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\
            \;\;\;\;\left(y + x\right) - \tan a\\
            
            \mathbf{else}:\\
            \;\;\;\;\tan z + x\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (+.f64 y z) < -1e8

              1. Initial program 71.3%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
                2. lift-tan.f64N/A

                  \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
                3. tan-sumN/A

                  \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
                4. quot-tanN/A

                  \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                5. quot-tanN/A

                  \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                6. div-addN/A

                  \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                7. lower-+.f64N/A

                  \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
              3. Applied rewrites99.6%

                \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
              4. Taylor expanded in z around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
              5. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. tan-quotN/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lift-tan.f64N/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
                7. lift-tan.f6471.1

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
              6. Applied rewrites71.1%

                \[\leadsto \color{blue}{\left(\tan y + x\right) - \tan a} \]
              7. Taylor expanded in a around 0

                \[\leadsto x + \color{blue}{\frac{\sin y}{\cos y}} \]
              8. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto x + \frac{\sin y}{\color{blue}{\cos y}} \]
                2. tan-quotN/A

                  \[\leadsto x + \tan y \]
                3. lift-tan.f6446.1

                  \[\leadsto x + \tan y \]
              9. Applied rewrites46.1%

                \[\leadsto x + \color{blue}{\tan y} \]

              if -1e8 < (+.f64 y z) < 4.00000000000000015e-10

              1. Initial program 99.9%

                \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
                2. lift-tan.f64N/A

                  \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
                3. tan-sumN/A

                  \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
                4. quot-tanN/A

                  \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                5. quot-tanN/A

                  \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                6. div-addN/A

                  \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                7. lower-+.f64N/A

                  \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
              3. Applied rewrites99.9%

                \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
              4. Taylor expanded in z around 0

                \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
              5. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                3. lower-+.f64N/A

                  \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                4. tan-quotN/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                5. lift-tan.f64N/A

                  \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                6. tan-quotN/A

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
                7. lift-tan.f6499.5

                  \[\leadsto \left(\tan y + x\right) - \tan a \]
              6. Applied rewrites99.5%

                \[\leadsto \color{blue}{\left(\tan y + x\right) - \tan a} \]
              7. Taylor expanded in y around 0

                \[\leadsto \left(y + x\right) - \tan a \]
              8. Step-by-step derivation
                1. Applied rewrites97.1%

                  \[\leadsto \left(y + x\right) - \tan a \]

                if 4.00000000000000015e-10 < (+.f64 y z)

                1. Initial program 72.6%

                  \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                2. Taylor expanded in y around 0

                  \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                3. Step-by-step derivation
                  1. lower--.f64N/A

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

                    \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  3. lower-+.f64N/A

                    \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  4. quot-tanN/A

                    \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  5. lower-tan.f64N/A

                    \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  6. tan-quotN/A

                    \[\leadsto \left(\tan z + x\right) - \tan a \]
                  7. lift-tan.f6472.4

                    \[\leadsto \left(\tan z + x\right) - \tan a \]
                4. Applied rewrites72.4%

                  \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                5. Taylor expanded in a around 0

                  \[\leadsto x + \color{blue}{\frac{\sin z}{\cos z}} \]
                6. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \frac{\sin z}{\cos z} + x \]
                  2. tan-quotN/A

                    \[\leadsto \tan z + x \]
                  3. lift-tan.f64N/A

                    \[\leadsto \tan z + x \]
                  4. lift-+.f6447.1

                    \[\leadsto \tan z + x \]
                7. Applied rewrites47.1%

                  \[\leadsto \tan z + \color{blue}{x} \]
              9. Recombined 3 regimes into one program.
              10. Add Preprocessing

              Alternative 11: 59.2% accurate, 1.7× speedup?

              \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -0.00015:\\ \;\;\;\;x + \tan y\\ \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\ \;\;\;\;\left(z + x\right) - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan z + x\\ \end{array} \end{array} \]
              NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
              (FPCore (x y z a)
               :precision binary64
               (if (<= (+ y z) -0.00015)
                 (+ x (tan y))
                 (if (<= (+ y z) 4e-10) (- (+ z x) (tan a)) (+ (tan z) x))))
              assert(x < y && y < z && z < a);
              double code(double x, double y, double z, double a) {
              	double tmp;
              	if ((y + z) <= -0.00015) {
              		tmp = x + tan(y);
              	} else if ((y + z) <= 4e-10) {
              		tmp = (z + x) - tan(a);
              	} else {
              		tmp = tan(z) + x;
              	}
              	return tmp;
              }
              
              NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
              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(x, y, z, a)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8), intent (in) :: a
                  real(8) :: tmp
                  if ((y + z) <= (-0.00015d0)) then
                      tmp = x + tan(y)
                  else if ((y + z) <= 4d-10) then
                      tmp = (z + x) - tan(a)
                  else
                      tmp = tan(z) + x
                  end if
                  code = tmp
              end function
              
              assert x < y && y < z && z < a;
              public static double code(double x, double y, double z, double a) {
              	double tmp;
              	if ((y + z) <= -0.00015) {
              		tmp = x + Math.tan(y);
              	} else if ((y + z) <= 4e-10) {
              		tmp = (z + x) - Math.tan(a);
              	} else {
              		tmp = Math.tan(z) + x;
              	}
              	return tmp;
              }
              
              [x, y, z, a] = sort([x, y, z, a])
              def code(x, y, z, a):
              	tmp = 0
              	if (y + z) <= -0.00015:
              		tmp = x + math.tan(y)
              	elif (y + z) <= 4e-10:
              		tmp = (z + x) - math.tan(a)
              	else:
              		tmp = math.tan(z) + x
              	return tmp
              
              x, y, z, a = sort([x, y, z, a])
              function code(x, y, z, a)
              	tmp = 0.0
              	if (Float64(y + z) <= -0.00015)
              		tmp = Float64(x + tan(y));
              	elseif (Float64(y + z) <= 4e-10)
              		tmp = Float64(Float64(z + x) - tan(a));
              	else
              		tmp = Float64(tan(z) + x);
              	end
              	return tmp
              end
              
              x, y, z, a = num2cell(sort([x, y, z, a])){:}
              function tmp_2 = code(x, y, z, a)
              	tmp = 0.0;
              	if ((y + z) <= -0.00015)
              		tmp = x + tan(y);
              	elseif ((y + z) <= 4e-10)
              		tmp = (z + x) - tan(a);
              	else
              		tmp = tan(z) + x;
              	end
              	tmp_2 = tmp;
              end
              
              NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
              code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.00015], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 4e-10], N[(N[(z + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]]
              
              \begin{array}{l}
              [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;y + z \leq -0.00015:\\
              \;\;\;\;x + \tan y\\
              
              \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\
              \;\;\;\;\left(z + x\right) - \tan a\\
              
              \mathbf{else}:\\
              \;\;\;\;\tan z + x\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if (+.f64 y z) < -1.49999999999999987e-4

                1. Initial program 71.8%

                  \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                2. Step-by-step derivation
                  1. lift-+.f64N/A

                    \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
                  2. lift-tan.f64N/A

                    \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
                  3. tan-sumN/A

                    \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
                  4. quot-tanN/A

                    \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                  5. quot-tanN/A

                    \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                  6. div-addN/A

                    \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                  7. lower-+.f64N/A

                    \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                3. Applied rewrites99.6%

                  \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                4. Taylor expanded in z around 0

                  \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                5. Step-by-step derivation
                  1. lower--.f64N/A

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

                    \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  3. lower-+.f64N/A

                    \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  4. tan-quotN/A

                    \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  5. lift-tan.f64N/A

                    \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  6. tan-quotN/A

                    \[\leadsto \left(\tan y + x\right) - \tan a \]
                  7. lift-tan.f6471.7

                    \[\leadsto \left(\tan y + x\right) - \tan a \]
                6. Applied rewrites71.7%

                  \[\leadsto \color{blue}{\left(\tan y + x\right) - \tan a} \]
                7. Taylor expanded in a around 0

                  \[\leadsto x + \color{blue}{\frac{\sin y}{\cos y}} \]
                8. Step-by-step derivation
                  1. lower-+.f64N/A

                    \[\leadsto x + \frac{\sin y}{\color{blue}{\cos y}} \]
                  2. tan-quotN/A

                    \[\leadsto x + \tan y \]
                  3. lift-tan.f6446.2

                    \[\leadsto x + \tan y \]
                9. Applied rewrites46.2%

                  \[\leadsto x + \color{blue}{\tan y} \]

                if -1.49999999999999987e-4 < (+.f64 y z) < 4.00000000000000015e-10

                1. Initial program 99.9%

                  \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                2. Taylor expanded in y around 0

                  \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                3. Step-by-step derivation
                  1. lower--.f64N/A

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

                    \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  3. lower-+.f64N/A

                    \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                  4. quot-tanN/A

                    \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  5. lower-tan.f64N/A

                    \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                  6. tan-quotN/A

                    \[\leadsto \left(\tan z + x\right) - \tan a \]
                  7. lift-tan.f6498.7

                    \[\leadsto \left(\tan z + x\right) - \tan a \]
                4. Applied rewrites98.7%

                  \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                5. Taylor expanded in z around 0

                  \[\leadsto \left(z + x\right) - \tan a \]
                6. Step-by-step derivation
                  1. Applied rewrites98.7%

                    \[\leadsto \left(z + x\right) - \tan a \]

                  if 4.00000000000000015e-10 < (+.f64 y z)

                  1. Initial program 72.6%

                    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                  2. Taylor expanded in y around 0

                    \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                  3. Step-by-step derivation
                    1. lower--.f64N/A

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

                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    3. lower-+.f64N/A

                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    4. quot-tanN/A

                      \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    5. lower-tan.f64N/A

                      \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    6. tan-quotN/A

                      \[\leadsto \left(\tan z + x\right) - \tan a \]
                    7. lift-tan.f6472.4

                      \[\leadsto \left(\tan z + x\right) - \tan a \]
                  4. Applied rewrites72.4%

                    \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                  5. Taylor expanded in a around 0

                    \[\leadsto x + \color{blue}{\frac{\sin z}{\cos z}} \]
                  6. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \frac{\sin z}{\cos z} + x \]
                    2. tan-quotN/A

                      \[\leadsto \tan z + x \]
                    3. lift-tan.f64N/A

                      \[\leadsto \tan z + x \]
                    4. lift-+.f6447.1

                      \[\leadsto \tan z + x \]
                  7. Applied rewrites47.1%

                    \[\leadsto \tan z + \color{blue}{x} \]
                7. Recombined 3 regimes into one program.
                8. Add Preprocessing

                Alternative 12: 59.1% accurate, 1.7× speedup?

                \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -0.00015:\\ \;\;\;\;x + \tan y\\ \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan z + x\\ \end{array} \end{array} \]
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                (FPCore (x y z a)
                 :precision binary64
                 (if (<= (+ y z) -0.00015)
                   (+ x (tan y))
                   (if (<= (+ y z) 4e-10) (- x (tan a)) (+ (tan z) x))))
                assert(x < y && y < z && z < a);
                double code(double x, double y, double z, double a) {
                	double tmp;
                	if ((y + z) <= -0.00015) {
                		tmp = x + tan(y);
                	} else if ((y + z) <= 4e-10) {
                		tmp = x - tan(a);
                	} else {
                		tmp = tan(z) + x;
                	}
                	return tmp;
                }
                
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                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(x, y, z, a)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z
                    real(8), intent (in) :: a
                    real(8) :: tmp
                    if ((y + z) <= (-0.00015d0)) then
                        tmp = x + tan(y)
                    else if ((y + z) <= 4d-10) then
                        tmp = x - tan(a)
                    else
                        tmp = tan(z) + x
                    end if
                    code = tmp
                end function
                
                assert x < y && y < z && z < a;
                public static double code(double x, double y, double z, double a) {
                	double tmp;
                	if ((y + z) <= -0.00015) {
                		tmp = x + Math.tan(y);
                	} else if ((y + z) <= 4e-10) {
                		tmp = x - Math.tan(a);
                	} else {
                		tmp = Math.tan(z) + x;
                	}
                	return tmp;
                }
                
                [x, y, z, a] = sort([x, y, z, a])
                def code(x, y, z, a):
                	tmp = 0
                	if (y + z) <= -0.00015:
                		tmp = x + math.tan(y)
                	elif (y + z) <= 4e-10:
                		tmp = x - math.tan(a)
                	else:
                		tmp = math.tan(z) + x
                	return tmp
                
                x, y, z, a = sort([x, y, z, a])
                function code(x, y, z, a)
                	tmp = 0.0
                	if (Float64(y + z) <= -0.00015)
                		tmp = Float64(x + tan(y));
                	elseif (Float64(y + z) <= 4e-10)
                		tmp = Float64(x - tan(a));
                	else
                		tmp = Float64(tan(z) + x);
                	end
                	return tmp
                end
                
                x, y, z, a = num2cell(sort([x, y, z, a])){:}
                function tmp_2 = code(x, y, z, a)
                	tmp = 0.0;
                	if ((y + z) <= -0.00015)
                		tmp = x + tan(y);
                	elseif ((y + z) <= 4e-10)
                		tmp = x - tan(a);
                	else
                		tmp = tan(z) + x;
                	end
                	tmp_2 = tmp;
                end
                
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.00015], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 4e-10], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]]
                
                \begin{array}{l}
                [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;y + z \leq -0.00015:\\
                \;\;\;\;x + \tan y\\
                
                \mathbf{elif}\;y + z \leq 4 \cdot 10^{-10}:\\
                \;\;\;\;x - \tan a\\
                
                \mathbf{else}:\\
                \;\;\;\;\tan z + x\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if (+.f64 y z) < -1.49999999999999987e-4

                  1. Initial program 71.8%

                    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                  2. Step-by-step derivation
                    1. lift-+.f64N/A

                      \[\leadsto x + \left(\tan \color{blue}{\left(y + z\right)} - \tan a\right) \]
                    2. lift-tan.f64N/A

                      \[\leadsto x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right) \]
                    3. tan-sumN/A

                      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
                    4. quot-tanN/A

                      \[\leadsto x + \left(\frac{\color{blue}{\frac{\sin y}{\cos y}} + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                    5. quot-tanN/A

                      \[\leadsto x + \left(\frac{\frac{\sin y}{\cos y} + \color{blue}{\frac{\sin z}{\cos z}}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
                    6. div-addN/A

                      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                    7. lower-+.f64N/A

                      \[\leadsto x + \left(\color{blue}{\left(\frac{\frac{\sin y}{\cos y}}{1 - \tan y \cdot \tan z} + \frac{\frac{\sin z}{\cos z}}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                  3. Applied rewrites99.6%

                    \[\leadsto x + \left(\color{blue}{\left(\frac{\tan y}{1 - \tan y \cdot \tan z} + \frac{\tan z}{1 - \tan y \cdot \tan z}\right)} - \tan a\right) \]
                  4. Taylor expanded in z around 0

                    \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                  5. Step-by-step derivation
                    1. lower--.f64N/A

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

                      \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    3. lower-+.f64N/A

                      \[\leadsto \left(\frac{\sin y}{\cos y} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    4. tan-quotN/A

                      \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    5. lift-tan.f64N/A

                      \[\leadsto \left(\tan y + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    6. tan-quotN/A

                      \[\leadsto \left(\tan y + x\right) - \tan a \]
                    7. lift-tan.f6471.7

                      \[\leadsto \left(\tan y + x\right) - \tan a \]
                  6. Applied rewrites71.7%

                    \[\leadsto \color{blue}{\left(\tan y + x\right) - \tan a} \]
                  7. Taylor expanded in a around 0

                    \[\leadsto x + \color{blue}{\frac{\sin y}{\cos y}} \]
                  8. Step-by-step derivation
                    1. lower-+.f64N/A

                      \[\leadsto x + \frac{\sin y}{\color{blue}{\cos y}} \]
                    2. tan-quotN/A

                      \[\leadsto x + \tan y \]
                    3. lift-tan.f6446.2

                      \[\leadsto x + \tan y \]
                  9. Applied rewrites46.2%

                    \[\leadsto x + \color{blue}{\tan y} \]

                  if -1.49999999999999987e-4 < (+.f64 y z) < 4.00000000000000015e-10

                  1. Initial program 99.9%

                    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                  2. Taylor expanded in y around 0

                    \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                  3. Step-by-step derivation
                    1. lower--.f64N/A

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

                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    3. lower-+.f64N/A

                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                    4. quot-tanN/A

                      \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    5. lower-tan.f64N/A

                      \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                    6. tan-quotN/A

                      \[\leadsto \left(\tan z + x\right) - \tan a \]
                    7. lift-tan.f6498.7

                      \[\leadsto \left(\tan z + x\right) - \tan a \]
                  4. Applied rewrites98.7%

                    \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                  5. Taylor expanded in x around inf

                    \[\leadsto x - \tan \color{blue}{a} \]
                  6. Step-by-step derivation
                    1. Applied rewrites98.4%

                      \[\leadsto x - \tan \color{blue}{a} \]

                    if 4.00000000000000015e-10 < (+.f64 y z)

                    1. Initial program 72.6%

                      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                    2. Taylor expanded in y around 0

                      \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                    3. Step-by-step derivation
                      1. lower--.f64N/A

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

                        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                      3. lower-+.f64N/A

                        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                      4. quot-tanN/A

                        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                      5. lower-tan.f64N/A

                        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                      6. tan-quotN/A

                        \[\leadsto \left(\tan z + x\right) - \tan a \]
                      7. lift-tan.f6472.4

                        \[\leadsto \left(\tan z + x\right) - \tan a \]
                    4. Applied rewrites72.4%

                      \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                    5. Taylor expanded in a around 0

                      \[\leadsto x + \color{blue}{\frac{\sin z}{\cos z}} \]
                    6. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \frac{\sin z}{\cos z} + x \]
                      2. tan-quotN/A

                        \[\leadsto \tan z + x \]
                      3. lift-tan.f64N/A

                        \[\leadsto \tan z + x \]
                      4. lift-+.f6447.1

                        \[\leadsto \tan z + x \]
                    7. Applied rewrites47.1%

                      \[\leadsto \tan z + \color{blue}{x} \]
                  7. Recombined 3 regimes into one program.
                  8. Add Preprocessing

                  Alternative 13: 59.8% accurate, 1.8× speedup?

                  \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := x - \tan a\\ \mathbf{if}\;a \leq -2 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;a \leq 1.15 \cdot 10^{-11}:\\ \;\;\;\;x + \tan \left(z + y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                  (FPCore (x y z a)
                   :precision binary64
                   (let* ((t_0 (- x (tan a))))
                     (if (<= a -2e-5) t_0 (if (<= a 1.15e-11) (+ x (tan (+ z y))) t_0))))
                  assert(x < y && y < z && z < a);
                  double code(double x, double y, double z, double a) {
                  	double t_0 = x - tan(a);
                  	double tmp;
                  	if (a <= -2e-5) {
                  		tmp = t_0;
                  	} else if (a <= 1.15e-11) {
                  		tmp = x + tan((z + y));
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                  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(x, y, z, a)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8), intent (in) :: z
                      real(8), intent (in) :: a
                      real(8) :: t_0
                      real(8) :: tmp
                      t_0 = x - tan(a)
                      if (a <= (-2d-5)) then
                          tmp = t_0
                      else if (a <= 1.15d-11) then
                          tmp = x + tan((z + y))
                      else
                          tmp = t_0
                      end if
                      code = tmp
                  end function
                  
                  assert x < y && y < z && z < a;
                  public static double code(double x, double y, double z, double a) {
                  	double t_0 = x - Math.tan(a);
                  	double tmp;
                  	if (a <= -2e-5) {
                  		tmp = t_0;
                  	} else if (a <= 1.15e-11) {
                  		tmp = x + Math.tan((z + y));
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  [x, y, z, a] = sort([x, y, z, a])
                  def code(x, y, z, a):
                  	t_0 = x - math.tan(a)
                  	tmp = 0
                  	if a <= -2e-5:
                  		tmp = t_0
                  	elif a <= 1.15e-11:
                  		tmp = x + math.tan((z + y))
                  	else:
                  		tmp = t_0
                  	return tmp
                  
                  x, y, z, a = sort([x, y, z, a])
                  function code(x, y, z, a)
                  	t_0 = Float64(x - tan(a))
                  	tmp = 0.0
                  	if (a <= -2e-5)
                  		tmp = t_0;
                  	elseif (a <= 1.15e-11)
                  		tmp = Float64(x + tan(Float64(z + y)));
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  x, y, z, a = num2cell(sort([x, y, z, a])){:}
                  function tmp_2 = code(x, y, z, a)
                  	t_0 = x - tan(a);
                  	tmp = 0.0;
                  	if (a <= -2e-5)
                  		tmp = t_0;
                  	elseif (a <= 1.15e-11)
                  		tmp = x + tan((z + y));
                  	else
                  		tmp = t_0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                  code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2e-5], t$95$0, If[LessEqual[a, 1.15e-11], N[(x + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                  \\
                  \begin{array}{l}
                  t_0 := x - \tan a\\
                  \mathbf{if}\;a \leq -2 \cdot 10^{-5}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;a \leq 1.15 \cdot 10^{-11}:\\
                  \;\;\;\;x + \tan \left(z + y\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if a < -2.00000000000000016e-5 or 1.15000000000000007e-11 < a

                    1. Initial program 78.5%

                      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                    2. Taylor expanded in y around 0

                      \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                    3. Step-by-step derivation
                      1. lower--.f64N/A

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

                        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                      3. lower-+.f64N/A

                        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                      4. quot-tanN/A

                        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                      5. lower-tan.f64N/A

                        \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                      6. tan-quotN/A

                        \[\leadsto \left(\tan z + x\right) - \tan a \]
                      7. lift-tan.f6459.4

                        \[\leadsto \left(\tan z + x\right) - \tan a \]
                    4. Applied rewrites59.4%

                      \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                    5. Taylor expanded in x around inf

                      \[\leadsto x - \tan \color{blue}{a} \]
                    6. Step-by-step derivation
                      1. Applied rewrites41.8%

                        \[\leadsto x - \tan \color{blue}{a} \]

                      if -2.00000000000000016e-5 < a < 1.15000000000000007e-11

                      1. Initial program 79.2%

                        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                      2. Taylor expanded in a around 0

                        \[\leadsto x + \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} \]
                      3. Step-by-step derivation
                        1. tan-quotN/A

                          \[\leadsto x + \tan \left(y + z\right) \]
                        2. lift-tan.f64N/A

                          \[\leadsto x + \tan \left(y + z\right) \]
                        3. +-commutativeN/A

                          \[\leadsto x + \tan \left(z + y\right) \]
                        4. lower-+.f6478.9

                          \[\leadsto x + \tan \left(z + y\right) \]
                      4. Applied rewrites78.9%

                        \[\leadsto x + \color{blue}{\tan \left(z + y\right)} \]
                    7. Recombined 2 regimes into one program.
                    8. Add Preprocessing

                    Alternative 14: 50.5% accurate, 1.9× speedup?

                    \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq 4 \cdot 10^{-10}:\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan z + x\\ \end{array} \end{array} \]
                    NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                    (FPCore (x y z a)
                     :precision binary64
                     (if (<= (+ y z) 4e-10) (- x (tan a)) (+ (tan z) x)))
                    assert(x < y && y < z && z < a);
                    double code(double x, double y, double z, double a) {
                    	double tmp;
                    	if ((y + z) <= 4e-10) {
                    		tmp = x - tan(a);
                    	} else {
                    		tmp = tan(z) + x;
                    	}
                    	return tmp;
                    }
                    
                    NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                    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(x, y, z, a)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8), intent (in) :: a
                        real(8) :: tmp
                        if ((y + z) <= 4d-10) then
                            tmp = x - tan(a)
                        else
                            tmp = tan(z) + x
                        end if
                        code = tmp
                    end function
                    
                    assert x < y && y < z && z < a;
                    public static double code(double x, double y, double z, double a) {
                    	double tmp;
                    	if ((y + z) <= 4e-10) {
                    		tmp = x - Math.tan(a);
                    	} else {
                    		tmp = Math.tan(z) + x;
                    	}
                    	return tmp;
                    }
                    
                    [x, y, z, a] = sort([x, y, z, a])
                    def code(x, y, z, a):
                    	tmp = 0
                    	if (y + z) <= 4e-10:
                    		tmp = x - math.tan(a)
                    	else:
                    		tmp = math.tan(z) + x
                    	return tmp
                    
                    x, y, z, a = sort([x, y, z, a])
                    function code(x, y, z, a)
                    	tmp = 0.0
                    	if (Float64(y + z) <= 4e-10)
                    		tmp = Float64(x - tan(a));
                    	else
                    		tmp = Float64(tan(z) + x);
                    	end
                    	return tmp
                    end
                    
                    x, y, z, a = num2cell(sort([x, y, z, a])){:}
                    function tmp_2 = code(x, y, z, a)
                    	tmp = 0.0;
                    	if ((y + z) <= 4e-10)
                    		tmp = x - tan(a);
                    	else
                    		tmp = tan(z) + x;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                    code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 4e-10], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]]
                    
                    \begin{array}{l}
                    [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y + z \leq 4 \cdot 10^{-10}:\\
                    \;\;\;\;x - \tan a\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\tan z + x\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (+.f64 y z) < 4.00000000000000015e-10

                      1. Initial program 82.6%

                        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                      2. Taylor expanded in y around 0

                        \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                      3. Step-by-step derivation
                        1. lower--.f64N/A

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

                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                        3. lower-+.f64N/A

                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                        4. quot-tanN/A

                          \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                        5. lower-tan.f64N/A

                          \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                        6. tan-quotN/A

                          \[\leadsto \left(\tan z + x\right) - \tan a \]
                        7. lift-tan.f6452.3

                          \[\leadsto \left(\tan z + x\right) - \tan a \]
                      4. Applied rewrites52.3%

                        \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                      5. Taylor expanded in x around inf

                        \[\leadsto x - \tan \color{blue}{a} \]
                      6. Step-by-step derivation
                        1. Applied rewrites52.6%

                          \[\leadsto x - \tan \color{blue}{a} \]

                        if 4.00000000000000015e-10 < (+.f64 y z)

                        1. Initial program 72.6%

                          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                        2. Taylor expanded in y around 0

                          \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                        3. Step-by-step derivation
                          1. lower--.f64N/A

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

                            \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                          3. lower-+.f64N/A

                            \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                          4. quot-tanN/A

                            \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                          5. lower-tan.f64N/A

                            \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                          6. tan-quotN/A

                            \[\leadsto \left(\tan z + x\right) - \tan a \]
                          7. lift-tan.f6472.4

                            \[\leadsto \left(\tan z + x\right) - \tan a \]
                        4. Applied rewrites72.4%

                          \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                        5. Taylor expanded in a around 0

                          \[\leadsto x + \color{blue}{\frac{\sin z}{\cos z}} \]
                        6. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \frac{\sin z}{\cos z} + x \]
                          2. tan-quotN/A

                            \[\leadsto \tan z + x \]
                          3. lift-tan.f64N/A

                            \[\leadsto \tan z + x \]
                          4. lift-+.f6447.1

                            \[\leadsto \tan z + x \]
                        7. Applied rewrites47.1%

                          \[\leadsto \tan z + \color{blue}{x} \]
                      7. Recombined 2 regimes into one program.
                      8. Add Preprocessing

                      Alternative 15: 40.7% accurate, 2.0× speedup?

                      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \tan z + x \end{array} \]
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      (FPCore (x y z a) :precision binary64 (+ (tan z) x))
                      assert(x < y && y < z && z < a);
                      double code(double x, double y, double z, double a) {
                      	return tan(z) + x;
                      }
                      
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      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(x, y, z, a)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          real(8), intent (in) :: a
                          code = tan(z) + x
                      end function
                      
                      assert x < y && y < z && z < a;
                      public static double code(double x, double y, double z, double a) {
                      	return Math.tan(z) + x;
                      }
                      
                      [x, y, z, a] = sort([x, y, z, a])
                      def code(x, y, z, a):
                      	return math.tan(z) + x
                      
                      x, y, z, a = sort([x, y, z, a])
                      function code(x, y, z, a)
                      	return Float64(tan(z) + x)
                      end
                      
                      x, y, z, a = num2cell(sort([x, y, z, a])){:}
                      function tmp = code(x, y, z, a)
                      	tmp = tan(z) + x;
                      end
                      
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      code[x_, y_, z_, a_] := N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision]
                      
                      \begin{array}{l}
                      [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                      \\
                      \tan z + x
                      \end{array}
                      
                      Derivation
                      1. Initial program 78.9%

                        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                      2. Taylor expanded in y around 0

                        \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                      3. Step-by-step derivation
                        1. lower--.f64N/A

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

                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                        3. lower-+.f64N/A

                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                        4. quot-tanN/A

                          \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                        5. lower-tan.f64N/A

                          \[\leadsto \left(\tan z + x\right) - \frac{\sin \color{blue}{a}}{\cos a} \]
                        6. tan-quotN/A

                          \[\leadsto \left(\tan z + x\right) - \tan a \]
                        7. lift-tan.f6459.9

                          \[\leadsto \left(\tan z + x\right) - \tan a \]
                      4. Applied rewrites59.9%

                        \[\leadsto \color{blue}{\left(\tan z + x\right) - \tan a} \]
                      5. Taylor expanded in a around 0

                        \[\leadsto x + \color{blue}{\frac{\sin z}{\cos z}} \]
                      6. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \frac{\sin z}{\cos z} + x \]
                        2. tan-quotN/A

                          \[\leadsto \tan z + x \]
                        3. lift-tan.f64N/A

                          \[\leadsto \tan z + x \]
                        4. lift-+.f6440.7

                          \[\leadsto \tan z + x \]
                      7. Applied rewrites40.7%

                        \[\leadsto \tan z + \color{blue}{x} \]
                      8. Add Preprocessing

                      Alternative 16: 31.7% accurate, 210.0× speedup?

                      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x \end{array} \]
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      (FPCore (x y z a) :precision binary64 x)
                      assert(x < y && y < z && z < a);
                      double code(double x, double y, double z, double a) {
                      	return x;
                      }
                      
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      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(x, y, z, a)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          real(8), intent (in) :: a
                          code = x
                      end function
                      
                      assert x < y && y < z && z < a;
                      public static double code(double x, double y, double z, double a) {
                      	return x;
                      }
                      
                      [x, y, z, a] = sort([x, y, z, a])
                      def code(x, y, z, a):
                      	return x
                      
                      x, y, z, a = sort([x, y, z, a])
                      function code(x, y, z, a)
                      	return x
                      end
                      
                      x, y, z, a = num2cell(sort([x, y, z, a])){:}
                      function tmp = code(x, y, z, a)
                      	tmp = x;
                      end
                      
                      NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                      code[x_, y_, z_, a_] := x
                      
                      \begin{array}{l}
                      [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                      \\
                      x
                      \end{array}
                      
                      Derivation
                      1. Initial program 78.9%

                        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
                      2. Taylor expanded in x around inf

                        \[\leadsto \color{blue}{x} \]
                      3. Step-by-step derivation
                        1. Applied rewrites31.7%

                          \[\leadsto \color{blue}{x} \]
                        2. Add Preprocessing

                        Reproduce

                        ?
                        herbie shell --seed 2025103 
                        (FPCore (x y z a)
                          :name "tan-example (used to crash)"
                          :precision binary64
                          :pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
                          (+ x (- (tan (+ y z)) (tan a))))