tan-example (used to crash)

Percentage Accurate: 79.5% → 99.7%
Time: 11.9s
Alternatives: 21
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}

Sampling outcomes in binary64 precision:

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 21 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: 79.5% 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.3× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := 1 - \tan z \cdot \tan y\\ x + \left(\frac{\tan y}{t\_0} + \left(\frac{\tan z}{t\_0} - \tan a\right)\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 z) (tan y)))))
   (+ 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(z) * tan(y));
	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(z) * tan(y))
    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(z) * Math.tan(y));
	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(z) * math.tan(y))
	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(z) * tan(y)))
	return Float64(x + Float64(Float64(tan(y) / t_0) + Float64(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(z) * tan(y));
	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[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[Tan[y], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Tan[z], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := 1 - \tan z \cdot \tan y\\
x + \left(\frac{\tan y}{t\_0} + \left(\frac{\tan z}{t\_0} - \tan a\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 79.9%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. 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) \]
  4. Applied rewrites99.7%

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

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

Alternative 2: 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 79.9%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. 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) \]
  4. Applied rewrites99.7%

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

Alternative 3: 89.5% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := \tan z + \tan y\\ \mathbf{if}\;a \leq -132000:\\ \;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\ \mathbf{elif}\;a \leq 0.098:\\ \;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.05396825396825397, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\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 (+ (tan z) (tan y))))
   (if (<= a -132000.0)
     (+ x (- (/ t_0 1.0) (tan a)))
     (if (<= a 0.098)
       (+
        x
        (-
         (/ t_0 (- 1.0 (* (tan z) (tan y))))
         (*
          (fma
           (fma
            (fma (* a a) 0.05396825396825397 0.13333333333333333)
            (* a a)
            0.3333333333333333)
           (* a a)
           1.0)
          a)))
       (+ x (- (tan (+ y z)) (tan a)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = tan(z) + tan(y);
	double tmp;
	if (a <= -132000.0) {
		tmp = x + ((t_0 / 1.0) - tan(a));
	} else if (a <= 0.098) {
		tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - (fma(fma(fma((a * a), 0.05396825396825397, 0.13333333333333333), (a * a), 0.3333333333333333), (a * a), 1.0) * a));
	} else {
		tmp = x + (tan((y + z)) - tan(a));
	}
	return tmp;
}
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(tan(z) + tan(y))
	tmp = 0.0
	if (a <= -132000.0)
		tmp = Float64(x + Float64(Float64(t_0 / 1.0) - tan(a)));
	elseif (a <= 0.098)
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(fma(fma(fma(Float64(a * a), 0.05396825396825397, 0.13333333333333333), Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a)));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	end
	return 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[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -132000.0], N[(x + N[(N[(t$95$0 / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.098], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(a * a), $MachinePrecision] * 0.05396825396825397 + 0.13333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;a \leq -132000:\\
\;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\

\mathbf{elif}\;a \leq 0.098:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.05396825396825397, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\

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


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

    1. Initial program 80.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.3

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1}} - \tan a\right) \]
    6. Step-by-step derivation
      1. tan-quot81.2

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      2. tan-quot81.2

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      3. *-commutative81.2

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      4. tan-quot81.2

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      5. tan-quot81.2

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
    7. Applied rewrites81.2%

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

    if -132000 < a < 0.098000000000000004

    1. Initial program 77.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.8

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{a \cdot \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right) \cdot \color{blue}{a}\right) \]
      2. lower-*.f64N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right) \cdot \color{blue}{a}\right) \]
    7. Applied rewrites98.1%

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.05396825396825397, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a}\right) \]

    if 0.098000000000000004 < a

    1. Initial program 82.6%

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

Alternative 4: 89.8% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := \tan z + \tan y\\ \mathbf{if}\;a \leq -0.0275:\\ \;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\ \mathbf{elif}\;a \leq 0.066:\\ \;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.13333333333333333, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\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 (+ (tan z) (tan y))))
   (if (<= a -0.0275)
     (+ x (- (/ t_0 1.0) (tan a)))
     (if (<= a 0.066)
       (+
        x
        (-
         (/ t_0 (- 1.0 (* (tan z) (tan y))))
         (*
          (fma
           (fma (* a a) 0.13333333333333333 0.3333333333333333)
           (* a a)
           1.0)
          a)))
       (+ x (- (tan (+ y z)) (tan a)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = tan(z) + tan(y);
	double tmp;
	if (a <= -0.0275) {
		tmp = x + ((t_0 / 1.0) - tan(a));
	} else if (a <= 0.066) {
		tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - (fma(fma((a * a), 0.13333333333333333, 0.3333333333333333), (a * a), 1.0) * a));
	} else {
		tmp = x + (tan((y + z)) - tan(a));
	}
	return tmp;
}
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(tan(z) + tan(y))
	tmp = 0.0
	if (a <= -0.0275)
		tmp = Float64(x + Float64(Float64(t_0 / 1.0) - tan(a)));
	elseif (a <= 0.066)
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(fma(fma(Float64(a * a), 0.13333333333333333, 0.3333333333333333), Float64(a * a), 1.0) * a)));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	end
	return 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[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0275], N[(x + N[(N[(t$95$0 / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.066], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(a * a), $MachinePrecision] * 0.13333333333333333 + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;a \leq -0.0275:\\
\;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\

\mathbf{elif}\;a \leq 0.066:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.13333333333333333, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\

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


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

    1. Initial program 78.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.3

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1}} - \tan a\right) \]
    6. Step-by-step derivation
      1. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      2. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      3. *-commutative79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      4. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      5. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
    7. Applied rewrites79.1%

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

    if -0.0275000000000000001 < a < 0.066000000000000003

    1. Initial program 78.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.8

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{a \cdot \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left({a}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right) + 1\right) \cdot a\right) \]
      4. *-commutativeN/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(\left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right) \cdot {a}^{2} + 1\right) \cdot a\right) \]
      5. lower-fma.f64N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}, {a}^{2}, 1\right) \cdot a\right) \]
      6. +-commutativeN/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\frac{2}{15} \cdot {a}^{2} + \frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
      7. *-commutativeN/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left({a}^{2} \cdot \frac{2}{15} + \frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
      8. lower-fma.f64N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left({a}^{2}, \frac{2}{15}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
      9. unpow2N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, \frac{2}{15}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
      10. lower-*.f64N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, \frac{2}{15}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
      11. unpow2N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, \frac{2}{15}, \frac{1}{3}\right), a \cdot a, 1\right) \cdot a\right) \]
      12. lower-*.f6499.7

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.13333333333333333, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right) \]
    7. Applied rewrites99.7%

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.13333333333333333, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a}\right) \]

    if 0.066000000000000003 < a

    1. Initial program 82.6%

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

Alternative 5: 89.8% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := \tan z + \tan y\\ \mathbf{if}\;a \leq -0.0095:\\ \;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\ \mathbf{elif}\;a \leq 0.058:\\ \;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\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 (+ (tan z) (tan y))))
   (if (<= a -0.0095)
     (+ x (- (/ t_0 1.0) (tan a)))
     (if (<= a 0.058)
       (+
        x
        (-
         (/ t_0 (- 1.0 (* (tan z) (tan y))))
         (* (fma (* a a) 0.3333333333333333 1.0) a)))
       (+ x (- (tan (+ y z)) (tan a)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = tan(z) + tan(y);
	double tmp;
	if (a <= -0.0095) {
		tmp = x + ((t_0 / 1.0) - tan(a));
	} else if (a <= 0.058) {
		tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - (fma((a * a), 0.3333333333333333, 1.0) * a));
	} else {
		tmp = x + (tan((y + z)) - tan(a));
	}
	return tmp;
}
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(tan(z) + tan(y))
	tmp = 0.0
	if (a <= -0.0095)
		tmp = Float64(x + Float64(Float64(t_0 / 1.0) - tan(a)));
	elseif (a <= 0.058)
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(fma(Float64(a * a), 0.3333333333333333, 1.0) * a)));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	end
	return 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[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0095], N[(x + N[(N[(t$95$0 / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.058], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a * a), $MachinePrecision] * 0.3333333333333333 + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;a \leq -0.0095:\\
\;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\

\mathbf{elif}\;a \leq 0.058:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a\right)\\

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


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

    1. Initial program 78.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.3

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1}} - \tan a\right) \]
    6. Step-by-step derivation
      1. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      2. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      3. *-commutative79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      4. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      5. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
    7. Applied rewrites79.1%

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

    if -0.00949999999999999976 < a < 0.0580000000000000029

    1. Initial program 78.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.8

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{a \cdot \left(1 + \frac{1}{3} \cdot {a}^{2}\right)}\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(\frac{1}{3} \cdot {a}^{2} + 1\right) \cdot a\right) \]
      4. *-commutativeN/A

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

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left({a}^{2}, \frac{1}{3}, 1\right) \cdot a\right) \]
      6. unpow2N/A

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(a \cdot a, \frac{1}{3}, 1\right) \cdot a\right) \]
      7. lower-*.f6499.6

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a\right) \]
    7. Applied rewrites99.6%

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{\mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a}\right) \]

    if 0.0580000000000000029 < a

    1. Initial program 82.6%

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

Alternative 6: 89.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} t_0 := \tan z + \tan y\\ \mathbf{if}\;a \leq -0.0006:\\ \;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\ \mathbf{elif}\;a \leq 0.046:\\ \;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\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 (+ (tan z) (tan y))))
   (if (<= a -0.0006)
     (+ x (- (/ t_0 1.0) (tan a)))
     (if (<= a 0.046)
       (+ x (- (/ t_0 (- 1.0 (* (tan z) (tan y)))) a))
       (+ x (- (tan (+ y z)) (tan a)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double t_0 = tan(z) + tan(y);
	double tmp;
	if (a <= -0.0006) {
		tmp = x + ((t_0 / 1.0) - tan(a));
	} else if (a <= 0.046) {
		tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - a);
	} else {
		tmp = x + (tan((y + 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) :: t_0
    real(8) :: tmp
    t_0 = tan(z) + tan(y)
    if (a <= (-0.0006d0)) then
        tmp = x + ((t_0 / 1.0d0) - tan(a))
    else if (a <= 0.046d0) then
        tmp = x + ((t_0 / (1.0d0 - (tan(z) * tan(y)))) - a)
    else
        tmp = x + (tan((y + 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 t_0 = Math.tan(z) + Math.tan(y);
	double tmp;
	if (a <= -0.0006) {
		tmp = x + ((t_0 / 1.0) - Math.tan(a));
	} else if (a <= 0.046) {
		tmp = x + ((t_0 / (1.0 - (Math.tan(z) * Math.tan(y)))) - a);
	} else {
		tmp = x + (Math.tan((y + z)) - Math.tan(a));
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	t_0 = math.tan(z) + math.tan(y)
	tmp = 0
	if a <= -0.0006:
		tmp = x + ((t_0 / 1.0) - math.tan(a))
	elif a <= 0.046:
		tmp = x + ((t_0 / (1.0 - (math.tan(z) * math.tan(y)))) - a)
	else:
		tmp = x + (math.tan((y + z)) - math.tan(a))
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	t_0 = Float64(tan(z) + tan(y))
	tmp = 0.0
	if (a <= -0.0006)
		tmp = Float64(x + Float64(Float64(t_0 / 1.0) - tan(a)));
	elseif (a <= 0.046)
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) - a));
	else
		tmp = Float64(x + Float64(tan(Float64(y + 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)
	t_0 = tan(z) + tan(y);
	tmp = 0.0;
	if (a <= -0.0006)
		tmp = x + ((t_0 / 1.0) - tan(a));
	elseif (a <= 0.046)
		tmp = x + ((t_0 / (1.0 - (tan(z) * tan(y)))) - a);
	else
		tmp = x + (tan((y + 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_] := Block[{t$95$0 = N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0006], N[(x + N[(N[(t$95$0 / 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.046], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;a \leq -0.0006:\\
\;\;\;\;x + \left(\frac{t\_0}{1} - \tan a\right)\\

\mathbf{elif}\;a \leq 0.046:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan z \cdot \tan y} - a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -5.99999999999999947e-4

    1. Initial program 78.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.3

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1}} - \tan a\right) \]
    6. Step-by-step derivation
      1. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      2. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      3. *-commutative79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      4. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      5. tan-quot79.1

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
    7. Applied rewrites79.1%

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

    if -5.99999999999999947e-4 < a < 0.045999999999999999

    1. Initial program 78.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. 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.8

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \color{blue}{a}\right) \]
    6. Step-by-step derivation
      1. Applied rewrites99.4%

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

      if 0.045999999999999999 < a

      1. Initial program 82.6%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
    7. Recombined 3 regimes into one program.
    8. Add Preprocessing

    Alternative 7: 80.6% accurate, 0.5× speedup?

    \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 1.25 \cdot 10^{-7}:\\ \;\;\;\;x + \left(\frac{\tan z + \tan y}{1 - z \cdot \tan y} - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan z}{1 - \tan z \cdot \tan y} - \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 (<= z 1.25e-7)
       (+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* z (tan y)))) (tan a)))
       (+ x (- (/ (tan z) (- 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) {
    	double tmp;
    	if (z <= 1.25e-7) {
    		tmp = x + (((tan(z) + tan(y)) / (1.0 - (z * tan(y)))) - tan(a));
    	} else {
    		tmp = x + ((tan(z) / (1.0 - (tan(z) * tan(y)))) - 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 (z <= 1.25d-7) then
            tmp = x + (((tan(z) + tan(y)) / (1.0d0 - (z * tan(y)))) - tan(a))
        else
            tmp = x + ((tan(z) / (1.0d0 - (tan(z) * tan(y)))) - 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 (z <= 1.25e-7) {
    		tmp = x + (((Math.tan(z) + Math.tan(y)) / (1.0 - (z * Math.tan(y)))) - Math.tan(a));
    	} else {
    		tmp = x + ((Math.tan(z) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
    	}
    	return tmp;
    }
    
    [x, y, z, a] = sort([x, y, z, a])
    def code(x, y, z, a):
    	tmp = 0
    	if z <= 1.25e-7:
    		tmp = x + (((math.tan(z) + math.tan(y)) / (1.0 - (z * math.tan(y)))) - math.tan(a))
    	else:
    		tmp = x + ((math.tan(z) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
    	return tmp
    
    x, y, z, a = sort([x, y, z, a])
    function code(x, y, z, a)
    	tmp = 0.0
    	if (z <= 1.25e-7)
    		tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(z * tan(y)))) - tan(a)));
    	else
    		tmp = Float64(x + Float64(Float64(tan(z) / Float64(1.0 - Float64(tan(z) * tan(y)))) - 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 (z <= 1.25e-7)
    		tmp = x + (((tan(z) + tan(y)) / (1.0 - (z * tan(y)))) - tan(a));
    	else
    		tmp = x + ((tan(z) / (1.0 - (tan(z) * tan(y)))) - 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[z, 1.25e-7], N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(z * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[Tan[z], $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])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq 1.25 \cdot 10^{-7}:\\
    \;\;\;\;x + \left(\frac{\tan z + \tan y}{1 - z \cdot \tan y} - \tan a\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;x + \left(\frac{\tan z}{1 - \tan z \cdot \tan y} - \tan a\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 1.24999999999999994e-7

      1. Initial program 87.5%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
      3. 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) \]
      4. Applied rewrites99.7%

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

        \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{z} \cdot \tan y} - \tan a\right) \]
      6. Step-by-step derivation
        1. Applied rewrites81.2%

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

        if 1.24999999999999994e-7 < z

        1. Initial program 58.3%

          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
        2. Add Preprocessing
        3. 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) \]
        4. Applied rewrites99.7%

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

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

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

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

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

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

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

            \[\leadsto x + \left(\frac{\tan z}{1 - \tan z \cdot \tan y} - \tan a\right) \]
          7. lift-tan.f6461.6

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

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

      Alternative 8: 79.9% accurate, 0.7× speedup?

      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\frac{\tan z + \tan y}{1} - \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 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(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(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(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(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)) / 1.0) - 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(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] / 1.0), $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 a\right)
      \end{array}
      
      Derivation
      1. Initial program 79.9%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
      3. 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) \]
      4. Applied rewrites99.7%

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

        \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{1}} - \tan a\right) \]
      6. Step-by-step derivation
        1. tan-quot80.1

          \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
        2. tan-quot80.1

          \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
        3. *-commutative80.1

          \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
        4. tan-quot80.1

          \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
        5. tan-quot80.1

          \[\leadsto x + \left(\frac{\tan z + \tan y}{1} - \tan a\right) \]
      7. Applied rewrites80.1%

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

      Alternative 9: 69.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^{-7}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \tan \left(z + y\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-7) (+ x (- (tan y) (tan a))) (+ x (tan (+ z y)))))
      assert(x < y && y < z && z < a);
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= 2e-7) {
      		tmp = x + (tan(y) - tan(a));
      	} else {
      		tmp = x + tan((z + y));
      	}
      	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-7) then
              tmp = x + (tan(y) - tan(a))
          else
              tmp = x + tan((z + y))
          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-7) {
      		tmp = x + (Math.tan(y) - Math.tan(a));
      	} else {
      		tmp = x + Math.tan((z + y));
      	}
      	return tmp;
      }
      
      [x, y, z, a] = sort([x, y, z, a])
      def code(x, y, z, a):
      	tmp = 0
      	if (y + z) <= 2e-7:
      		tmp = x + (math.tan(y) - math.tan(a))
      	else:
      		tmp = x + math.tan((z + y))
      	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-7)
      		tmp = Float64(x + Float64(tan(y) - tan(a)));
      	else
      		tmp = Float64(x + tan(Float64(z + y)));
      	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-7)
      		tmp = x + (tan(y) - tan(a));
      	else
      		tmp = x + tan((z + y));
      	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-7], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(z + y), $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^{-7}:\\
      \;\;\;\;x + \left(\tan y - \tan a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \tan \left(z + y\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 y z) < 1.9999999999999999e-7

        1. Initial program 84.9%

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

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

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

          if 1.9999999999999999e-7 < (+.f64 y z)

          1. Initial program 71.7%

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

            \[\leadsto x + \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} \]
          4. 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-+.f6445.9

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

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

        Alternative 10: 69.6% 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^{-7}:\\ \;\;\;\;\left(\tan y + x\right) - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \tan \left(z + y\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-7) (- (+ (tan y) x) (tan a)) (+ x (tan (+ z y)))))
        assert(x < y && y < z && z < a);
        double code(double x, double y, double z, double a) {
        	double tmp;
        	if ((y + z) <= 2e-7) {
        		tmp = (tan(y) + x) - tan(a);
        	} else {
        		tmp = x + tan((z + y));
        	}
        	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-7) then
                tmp = (tan(y) + x) - tan(a)
            else
                tmp = x + tan((z + y))
            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-7) {
        		tmp = (Math.tan(y) + x) - Math.tan(a);
        	} else {
        		tmp = x + Math.tan((z + y));
        	}
        	return tmp;
        }
        
        [x, y, z, a] = sort([x, y, z, a])
        def code(x, y, z, a):
        	tmp = 0
        	if (y + z) <= 2e-7:
        		tmp = (math.tan(y) + x) - math.tan(a)
        	else:
        		tmp = x + math.tan((z + y))
        	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-7)
        		tmp = Float64(Float64(tan(y) + x) - tan(a));
        	else
        		tmp = Float64(x + tan(Float64(z + y)));
        	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-7)
        		tmp = (tan(y) + x) - tan(a);
        	else
        		tmp = x + tan((z + y));
        	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-7], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(z + y), $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^{-7}:\\
        \;\;\;\;\left(\tan y + x\right) - \tan a\\
        
        \mathbf{else}:\\
        \;\;\;\;x + \tan \left(z + y\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (+.f64 y z) < 1.9999999999999999e-7

          1. Initial program 84.9%

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

            \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
          4. 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.f6468.6

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

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

          if 1.9999999999999999e-7 < (+.f64 y z)

          1. Initial program 71.7%

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

            \[\leadsto x + \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} \]
          4. 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-+.f6445.9

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

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

        Alternative 11: 79.4% accurate, 1.0× speedup?

        \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 2.8 \cdot 10^{-8}:\\ \;\;\;\;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 (<= z 2.8e-8) (+ 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 (z <= 2.8e-8) {
        		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 (z <= 2.8d-8) 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 (z <= 2.8e-8) {
        		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 z <= 2.8e-8:
        		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 (z <= 2.8e-8)
        		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 (z <= 2.8e-8)
        		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[z, 2.8e-8], 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}\;z \leq 2.8 \cdot 10^{-8}:\\
        \;\;\;\;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 z < 2.7999999999999999e-8

          1. Initial program 87.5%

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

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

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

            if 2.7999999999999999e-8 < z

            1. Initial program 58.3%

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

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

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

            Alternative 12: 79.5% 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 79.9%

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

            Alternative 13: 60.6% accurate, 1.3× speedup?

            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.4 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot 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 (or (<= a -0.4) (not (<= a 0.045)))
               (- x (tan a))
               (+
                x
                (-
                 (tan (+ y z))
                 (*
                  (fma
                   (fma
                    (fma 0.05396825396825397 (* a a) 0.13333333333333333)
                    (* a a)
                    0.3333333333333333)
                   (* a a)
                   1.0)
                  a)))))
            assert(x < y && y < z && z < a);
            double code(double x, double y, double z, double a) {
            	double tmp;
            	if ((a <= -0.4) || !(a <= 0.045)) {
            		tmp = x - tan(a);
            	} else {
            		tmp = x + (tan((y + z)) - (fma(fma(fma(0.05396825396825397, (a * a), 0.13333333333333333), (a * a), 0.3333333333333333), (a * a), 1.0) * a));
            	}
            	return tmp;
            }
            
            x, y, z, a = sort([x, y, z, a])
            function code(x, y, z, a)
            	tmp = 0.0
            	if ((a <= -0.4) || !(a <= 0.045))
            		tmp = Float64(x - tan(a));
            	else
            		tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(fma(fma(0.05396825396825397, Float64(a * a), 0.13333333333333333), Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a)));
            	end
            	return tmp
            end
            
            NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
            code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.4], N[Not[LessEqual[a, 0.045]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(0.05396825396825397 * N[(a * a), $MachinePrecision] + 0.13333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;a \leq -0.4 \lor \neg \left(a \leq 0.045\right):\\
            \;\;\;\;x - \tan a\\
            
            \mathbf{else}:\\
            \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if a < -0.40000000000000002 or 0.044999999999999998 < a

              1. Initial program 80.3%

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

                \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
              4. 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.f6460.9

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

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

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

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

                if -0.40000000000000002 < a < 0.044999999999999998

                1. Initial program 79.4%

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

                  \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a \cdot \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right)}\right) \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right) \cdot \color{blue}{a}\right) \]
                  2. lower-*.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right)\right) \cdot \color{blue}{a}\right) \]
                  3. +-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \left({a}^{2} \cdot \left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right) + 1\right) \cdot a\right) \]
                  4. *-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \left(\left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right)\right) \cdot {a}^{2} + 1\right) \cdot a\right) \]
                  5. lower-fma.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\frac{1}{3} + {a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  6. +-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left({a}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right) + \frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
                  7. *-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}\right) \cdot {a}^{2} + \frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
                  8. lower-fma.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15} + \frac{17}{315} \cdot {a}^{2}, {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  9. +-commutativeN/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315} \cdot {a}^{2} + \frac{2}{15}, {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  10. lower-fma.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, {a}^{2}, \frac{2}{15}\right), {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  11. unpow2N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, a \cdot a, \frac{2}{15}\right), {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  12. lower-*.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, a \cdot a, \frac{2}{15}\right), {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  13. unpow2N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, a \cdot a, \frac{2}{15}\right), a \cdot a, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  14. lower-*.f64N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, a \cdot a, \frac{2}{15}\right), a \cdot a, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                  15. unpow2N/A

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, a \cdot a, \frac{2}{15}\right), a \cdot a, \frac{1}{3}\right), a \cdot a, 1\right) \cdot a\right) \]
                  16. lower-*.f6479.3

                    \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right) \]
                5. Applied rewrites79.3%

                  \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a}\right) \]
              8. Recombined 2 regimes into one program.
              9. Final simplification56.8%

                \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.4 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\ \end{array} \]
              10. Add Preprocessing

              Alternative 14: 60.5% accurate, 1.4× speedup?

              \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.145 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot 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 (or (<= a -0.145) (not (<= a 0.045)))
                 (- x (tan a))
                 (+
                  x
                  (-
                   (tan (+ y z))
                   (*
                    (fma (fma 0.13333333333333333 (* a a) 0.3333333333333333) (* a a) 1.0)
                    a)))))
              assert(x < y && y < z && z < a);
              double code(double x, double y, double z, double a) {
              	double tmp;
              	if ((a <= -0.145) || !(a <= 0.045)) {
              		tmp = x - tan(a);
              	} else {
              		tmp = x + (tan((y + z)) - (fma(fma(0.13333333333333333, (a * a), 0.3333333333333333), (a * a), 1.0) * a));
              	}
              	return tmp;
              }
              
              x, y, z, a = sort([x, y, z, a])
              function code(x, y, z, a)
              	tmp = 0.0
              	if ((a <= -0.145) || !(a <= 0.045))
              		tmp = Float64(x - tan(a));
              	else
              		tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(fma(0.13333333333333333, Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a)));
              	end
              	return tmp
              end
              
              NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
              code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.145], N[Not[LessEqual[a, 0.045]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(0.13333333333333333 * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;a \leq -0.145 \lor \neg \left(a \leq 0.045\right):\\
              \;\;\;\;x - \tan a\\
              
              \mathbf{else}:\\
              \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if a < -0.14499999999999999 or 0.044999999999999998 < a

                1. Initial program 80.3%

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

                  \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                4. 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.f6460.9

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

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

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

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

                  if -0.14499999999999999 < a < 0.044999999999999998

                  1. Initial program 79.4%

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

                    \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a \cdot \left(1 + {a}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right)\right)}\right) \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

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

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

                      \[\leadsto x + \left(\tan \left(y + z\right) - \left({a}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right) + 1\right) \cdot a\right) \]
                    4. *-commutativeN/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \left(\left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}\right) \cdot {a}^{2} + 1\right) \cdot a\right) \]
                    5. lower-fma.f64N/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\frac{1}{3} + \frac{2}{15} \cdot {a}^{2}, {a}^{2}, 1\right) \cdot a\right) \]
                    6. +-commutativeN/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\frac{2}{15} \cdot {a}^{2} + \frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
                    7. lower-fma.f64N/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, {a}^{2}, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                    8. unpow2N/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, a \cdot a, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                    9. lower-*.f64N/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, a \cdot a, \frac{1}{3}\right), {a}^{2}, 1\right) \cdot a\right) \]
                    10. unpow2N/A

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, a \cdot a, \frac{1}{3}\right), a \cdot a, 1\right) \cdot a\right) \]
                    11. lower-*.f6479.2

                      \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right) \]
                  5. Applied rewrites79.2%

                    \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a}\right) \]
                8. Recombined 2 regimes into one program.
                9. Final simplification56.7%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.145 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a\right)\\ \end{array} \]
                10. Add Preprocessing

                Alternative 15: 60.5% accurate, 1.5× speedup?

                \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.116 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot 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 (or (<= a -0.116) (not (<= a 0.045)))
                   (- x (tan a))
                   (+ x (- (tan (+ y z)) (* (fma 0.3333333333333333 (* a a) 1.0) a)))))
                assert(x < y && y < z && z < a);
                double code(double x, double y, double z, double a) {
                	double tmp;
                	if ((a <= -0.116) || !(a <= 0.045)) {
                		tmp = x - tan(a);
                	} else {
                		tmp = x + (tan((y + z)) - (fma(0.3333333333333333, (a * a), 1.0) * a));
                	}
                	return tmp;
                }
                
                x, y, z, a = sort([x, y, z, a])
                function code(x, y, z, a)
                	tmp = 0.0
                	if ((a <= -0.116) || !(a <= 0.045))
                		tmp = Float64(x - tan(a));
                	else
                		tmp = Float64(x + Float64(tan(Float64(y + z)) - Float64(fma(0.3333333333333333, Float64(a * a), 1.0) * a)));
                	end
                	return tmp
                end
                
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.116], N[Not[LessEqual[a, 0.045]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;a \leq -0.116 \lor \neg \left(a \leq 0.045\right):\\
                \;\;\;\;x - \tan a\\
                
                \mathbf{else}:\\
                \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if a < -0.116000000000000006 or 0.044999999999999998 < a

                  1. Initial program 80.3%

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

                    \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                  4. 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.f6460.9

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

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

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

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

                    if -0.116000000000000006 < a < 0.044999999999999998

                    1. Initial program 79.4%

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

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

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

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

                        \[\leadsto x + \left(\tan \left(y + z\right) - \left(\frac{1}{3} \cdot {a}^{2} + 1\right) \cdot a\right) \]
                      4. lower-fma.f64N/A

                        \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\frac{1}{3}, {a}^{2}, 1\right) \cdot a\right) \]
                      5. unpow2N/A

                        \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\frac{1}{3}, a \cdot a, 1\right) \cdot a\right) \]
                      6. lower-*.f6479.1

                        \[\leadsto x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right) \]
                    5. Applied rewrites79.1%

                      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a}\right) \]
                  8. Recombined 2 regimes into one program.
                  9. Final simplification56.7%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.116 \lor \neg \left(a \leq 0.045\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right)\\ \end{array} \]
                  10. Add Preprocessing

                  Alternative 16: 60.4% accurate, 1.7× speedup?

                  \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;\left(x - a\right) + \tan \left(z + y\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 (or (<= a -0.102) (not (<= a 0.031)))
                     (- x (tan a))
                     (+ (- x a) (tan (+ z y)))))
                  assert(x < y && y < z && z < a);
                  double code(double x, double y, double z, double a) {
                  	double tmp;
                  	if ((a <= -0.102) || !(a <= 0.031)) {
                  		tmp = x - tan(a);
                  	} else {
                  		tmp = (x - a) + tan((z + y));
                  	}
                  	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 ((a <= (-0.102d0)) .or. (.not. (a <= 0.031d0))) then
                          tmp = x - tan(a)
                      else
                          tmp = (x - a) + tan((z + y))
                      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 ((a <= -0.102) || !(a <= 0.031)) {
                  		tmp = x - Math.tan(a);
                  	} else {
                  		tmp = (x - a) + Math.tan((z + y));
                  	}
                  	return tmp;
                  }
                  
                  [x, y, z, a] = sort([x, y, z, a])
                  def code(x, y, z, a):
                  	tmp = 0
                  	if (a <= -0.102) or not (a <= 0.031):
                  		tmp = x - math.tan(a)
                  	else:
                  		tmp = (x - a) + math.tan((z + y))
                  	return tmp
                  
                  x, y, z, a = sort([x, y, z, a])
                  function code(x, y, z, a)
                  	tmp = 0.0
                  	if ((a <= -0.102) || !(a <= 0.031))
                  		tmp = Float64(x - tan(a));
                  	else
                  		tmp = Float64(Float64(x - a) + tan(Float64(z + y)));
                  	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 ((a <= -0.102) || ~((a <= 0.031)))
                  		tmp = x - tan(a);
                  	else
                  		tmp = (x - a) + tan((z + y));
                  	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[Or[LessEqual[a, -0.102], N[Not[LessEqual[a, 0.031]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[(x - a), $MachinePrecision] + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\
                  \;\;\;\;x - \tan a\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(x - a\right) + \tan \left(z + y\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if a < -0.101999999999999993 or 0.031 < a

                    1. Initial program 80.3%

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

                      \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                    4. 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.f6460.9

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

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

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

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

                      if -0.101999999999999993 < a < 0.031

                      1. Initial program 79.4%

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

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

                          \[\leadsto x + \left(-1 \cdot a + \tan \left(y + z\right)\right) \]
                        2. associate-+r+N/A

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

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

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

                          \[\leadsto \left(x + \left(\mathsf{neg}\left(a\right)\right)\right) + \tan \left(y + \color{blue}{z}\right) \]
                        6. lower-neg.f64N/A

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

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

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

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

                        \[\leadsto \color{blue}{\left(x + \left(-a\right)\right) + \tan \left(z + y\right)} \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification56.6%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;\left(x - a\right) + \tan \left(z + y\right)\\ \end{array} \]
                    10. Add Preprocessing

                    Alternative 17: 60.4% accurate, 1.7× speedup?

                    \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - 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 (or (<= a -0.102) (not (<= a 0.031)))
                       (- x (tan a))
                       (+ x (- (tan (+ y z)) a))))
                    assert(x < y && y < z && z < a);
                    double code(double x, double y, double z, double a) {
                    	double tmp;
                    	if ((a <= -0.102) || !(a <= 0.031)) {
                    		tmp = x - tan(a);
                    	} else {
                    		tmp = x + (tan((y + z)) - 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 ((a <= (-0.102d0)) .or. (.not. (a <= 0.031d0))) then
                            tmp = x - tan(a)
                        else
                            tmp = x + (tan((y + z)) - 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 ((a <= -0.102) || !(a <= 0.031)) {
                    		tmp = x - Math.tan(a);
                    	} else {
                    		tmp = x + (Math.tan((y + z)) - a);
                    	}
                    	return tmp;
                    }
                    
                    [x, y, z, a] = sort([x, y, z, a])
                    def code(x, y, z, a):
                    	tmp = 0
                    	if (a <= -0.102) or not (a <= 0.031):
                    		tmp = x - math.tan(a)
                    	else:
                    		tmp = x + (math.tan((y + z)) - a)
                    	return tmp
                    
                    x, y, z, a = sort([x, y, z, a])
                    function code(x, y, z, a)
                    	tmp = 0.0
                    	if ((a <= -0.102) || !(a <= 0.031))
                    		tmp = Float64(x - tan(a));
                    	else
                    		tmp = Float64(x + Float64(tan(Float64(y + z)) - 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 ((a <= -0.102) || ~((a <= 0.031)))
                    		tmp = x - tan(a);
                    	else
                    		tmp = x + (tan((y + z)) - 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[Or[LessEqual[a, -0.102], N[Not[LessEqual[a, 0.031]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\
                    \;\;\;\;x - \tan a\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if a < -0.101999999999999993 or 0.031 < a

                      1. Initial program 80.3%

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

                        \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                      4. 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.f6460.9

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

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

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

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

                        if -0.101999999999999993 < a < 0.031

                        1. Initial program 79.4%

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

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

                            \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
                        5. Recombined 2 regimes into one program.
                        6. Final simplification56.6%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.102 \lor \neg \left(a \leq 0.031\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 18: 60.0% accurate, 1.8× speedup?

                        \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.065 \lor \neg \left(a \leq 3.75 \cdot 10^{-6}\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \tan \left(z + y\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 (or (<= a -0.065) (not (<= a 3.75e-6)))
                           (- x (tan a))
                           (+ x (tan (+ z y)))))
                        assert(x < y && y < z && z < a);
                        double code(double x, double y, double z, double a) {
                        	double tmp;
                        	if ((a <= -0.065) || !(a <= 3.75e-6)) {
                        		tmp = x - tan(a);
                        	} else {
                        		tmp = x + tan((z + y));
                        	}
                        	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 ((a <= (-0.065d0)) .or. (.not. (a <= 3.75d-6))) then
                                tmp = x - tan(a)
                            else
                                tmp = x + tan((z + y))
                            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 ((a <= -0.065) || !(a <= 3.75e-6)) {
                        		tmp = x - Math.tan(a);
                        	} else {
                        		tmp = x + Math.tan((z + y));
                        	}
                        	return tmp;
                        }
                        
                        [x, y, z, a] = sort([x, y, z, a])
                        def code(x, y, z, a):
                        	tmp = 0
                        	if (a <= -0.065) or not (a <= 3.75e-6):
                        		tmp = x - math.tan(a)
                        	else:
                        		tmp = x + math.tan((z + y))
                        	return tmp
                        
                        x, y, z, a = sort([x, y, z, a])
                        function code(x, y, z, a)
                        	tmp = 0.0
                        	if ((a <= -0.065) || !(a <= 3.75e-6))
                        		tmp = Float64(x - tan(a));
                        	else
                        		tmp = Float64(x + tan(Float64(z + y)));
                        	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 ((a <= -0.065) || ~((a <= 3.75e-6)))
                        		tmp = x - tan(a);
                        	else
                        		tmp = x + tan((z + y));
                        	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[Or[LessEqual[a, -0.065], N[Not[LessEqual[a, 3.75e-6]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                        
                        \begin{array}{l}
                        [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;a \leq -0.065 \lor \neg \left(a \leq 3.75 \cdot 10^{-6}\right):\\
                        \;\;\;\;x - \tan a\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;x + \tan \left(z + y\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if a < -0.065000000000000002 or 3.7500000000000001e-6 < a

                          1. Initial program 80.3%

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

                            \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                          4. 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.f6460.9

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

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

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

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

                            if -0.065000000000000002 < a < 3.7500000000000001e-6

                            1. Initial program 79.4%

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

                              \[\leadsto x + \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} \]
                            4. 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.7

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

                              \[\leadsto x + \color{blue}{\tan \left(z + y\right)} \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification56.5%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.065 \lor \neg \left(a \leq 3.75 \cdot 10^{-6}\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \tan \left(z + y\right)\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 19: 50.6% 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 -5000000:\\ \;\;\;\;x + \tan y\\ \mathbf{else}:\\ \;\;\;\;x - \tan a\\ \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) -5000000.0) (+ x (tan y)) (- 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) <= -5000000.0) {
                          		tmp = x + tan(y);
                          	} else {
                          		tmp = 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) <= (-5000000.0d0)) then
                                  tmp = x + tan(y)
                              else
                                  tmp = 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) <= -5000000.0) {
                          		tmp = x + Math.tan(y);
                          	} else {
                          		tmp = 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) <= -5000000.0:
                          		tmp = x + math.tan(y)
                          	else:
                          		tmp = 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) <= -5000000.0)
                          		tmp = Float64(x + tan(y));
                          	else
                          		tmp = 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) <= -5000000.0)
                          		tmp = x + tan(y);
                          	else
                          		tmp = 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], -5000000.0], N[(x + N[Tan[y], $MachinePrecision]), $MachinePrecision], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
                          
                          \begin{array}{l}
                          [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;y + z \leq -5000000:\\
                          \;\;\;\;x + \tan y\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;x - \tan a\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (+.f64 y z) < -5e6

                            1. Initial program 75.0%

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

                              \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                            4. 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.f6448.7

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

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

                              \[\leadsto x + \color{blue}{\frac{\sin y}{\cos y}} \]
                            7. 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.f6430.5

                                \[\leadsto x + \tan y \]
                            8. Applied rewrites30.5%

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

                            if -5e6 < (+.f64 y z)

                            1. Initial program 82.9%

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

                              \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                            4. 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.f6467.4

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

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

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

                                \[\leadsto x - \tan \color{blue}{a} \]
                            8. Recombined 2 regimes into one program.
                            9. Add Preprocessing

                            Alternative 20: 41.4% accurate, 2.0× speedup?

                            \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \tan y \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)))
                            assert(x < y && y < z && z < a);
                            double code(double x, double y, double z, double a) {
                            	return x + tan(y);
                            }
                            
                            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)
                            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);
                            }
                            
                            [x, y, z, a] = sort([x, y, z, a])
                            def code(x, y, z, a):
                            	return x + math.tan(y)
                            
                            x, y, z, a = sort([x, y, z, a])
                            function code(x, y, z, a)
                            	return Float64(x + tan(y))
                            end
                            
                            x, y, z, a = num2cell(sort([x, y, z, a])){:}
                            function tmp = code(x, y, z, a)
                            	tmp = x + tan(y);
                            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[Tan[y], $MachinePrecision]), $MachinePrecision]
                            
                            \begin{array}{l}
                            [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                            \\
                            x + \tan y
                            \end{array}
                            
                            Derivation
                            1. Initial program 79.9%

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

                              \[\leadsto \color{blue}{\left(x + \frac{\sin y}{\cos y}\right) - \frac{\sin a}{\cos a}} \]
                            4. 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.f6460.4

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

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

                              \[\leadsto x + \color{blue}{\frac{\sin y}{\cos y}} \]
                            7. 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.f6438.8

                                \[\leadsto x + \tan y \]
                            8. Applied rewrites38.8%

                              \[\leadsto x + \color{blue}{\tan y} \]
                            9. Add Preprocessing

                            Alternative 21: 31.8% 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 79.9%

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

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

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

                              Reproduce

                              ?
                              herbie shell --seed 2025061 
                              (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))))