tan-example (used to crash)

Percentage Accurate: 79.0% → 99.7%
Time: 17.5s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 79.0% 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])\\ \\ x + \left(\frac{\tan z + \tan y}{1 - \frac{\tan y \cdot \sin z}{\cos z}} - \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 y) (sin z)) (cos z)))) (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(y) * sin(z)) / cos(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(z) + tan(y)) / (1.0d0 - ((tan(y) * sin(z)) / cos(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(z) + Math.tan(y)) / (1.0 - ((Math.tan(y) * Math.sin(z)) / Math.cos(z)))) - 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(y) * math.sin(z)) / math.cos(z)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(Float64(tan(y) * sin(z)) / cos(z)))) - 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(y) * sin(z)) / cos(z)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(N[Tan[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[Cos[z], $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 - \frac{\tan y \cdot \sin z}{\cos z}} - \tan a\right)
\end{array}
Derivation
  1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z} \cdot \tan y} - \tan a\right) \]
    13. 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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

    \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\frac{\tan y \cdot \sin z}{\cos z}}} - \tan a\right) \]
  7. 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 y + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\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) (tan z)) (fma (- (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(y) + tan(z)) / fma(-tan(z), tan(y), 1.0)) - tan(a));
}
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / fma(Float64(-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[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $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 y + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - \tan a\right)
\end{array}
Derivation
  1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z} \cdot \tan y} - \tan a\right) \]
    13. 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. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

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

      \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - \color{blue}{\tan z \cdot \tan y}} - \tan a\right) \]
    6. fp-cancel-sub-sign-invN/A

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

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

      \[\leadsto x + \left(\frac{\tan y + \tan z}{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\tan z\right), \tan y, 1\right)}} - \tan a\right) \]
    9. lower-neg.f6499.7

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

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

Alternative 3: 89.0% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.0005 \lor \neg \left(a \leq 0.038\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} - \frac{\sin a}{\cos a}}{x}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\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.0005) (not (<= a 0.038)))
   (fma (/ (- (/ (sin (+ z y)) (cos (+ z y))) (/ (sin a) (cos a))) x) x x)
   (+ x (- (/ (+ (tan z) (tan y)) (fma (- (tan z)) (tan y) 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.0005) || !(a <= 0.038)) {
		tmp = fma((((sin((z + y)) / cos((z + y))) - (sin(a) / cos(a))) / x), x, x);
	} else {
		tmp = x + (((tan(z) + tan(y)) / fma(-tan(z), tan(y), 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.0005) || !(a <= 0.038))
		tmp = fma(Float64(Float64(Float64(sin(Float64(z + y)) / cos(Float64(z + y))) - Float64(sin(a) / cos(a))) / x), x, x);
	else
		tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / fma(Float64(-tan(z)), tan(y), 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.0005], N[Not[LessEqual[a, 0.038]], $MachinePrecision]], N[(N[(N[(N[(N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision], N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $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.0005 \lor \neg \left(a \leq 0.038\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} - \frac{\sin a}{\cos a}}{x}, x, x\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -5.0000000000000001e-4 or 0.0379999999999999991 < a

    1. Initial program 76.5%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} - \frac{\sin a}{\cos a}}{x}, x, x\right)} \]

      if -5.0000000000000001e-4 < a < 0.0379999999999999991

      1. Initial program 77.8%

        \[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 rewrites77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z \cdot \tan y}} - a\right) \]
          16. fp-cancel-sub-sign-invN/A

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

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

            \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\tan z\right), \tan y, 1\right)}} - a\right) \]
          19. lower-neg.f6499.5

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.0005 \lor \neg \left(a \leq 0.038\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} - \frac{\sin a}{\cos a}}{x}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - a\right)\\ \end{array} \]
      7. Add Preprocessing

      Alternative 4: 89.0% accurate, 0.5× speedup?

      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -0.0005 \lor \neg \left(a \leq 0.038\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\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.0005) (not (<= a 0.038)))
         (+ x (- (tan (+ y z)) (tan a)))
         (+ x (- (/ (+ (tan z) (tan y)) (fma (- (tan z)) (tan y) 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.0005) || !(a <= 0.038)) {
      		tmp = x + (tan((y + z)) - tan(a));
      	} else {
      		tmp = x + (((tan(z) + tan(y)) / fma(-tan(z), tan(y), 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.0005) || !(a <= 0.038))
      		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
      	else
      		tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / fma(Float64(-tan(z)), tan(y), 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.0005], N[Not[LessEqual[a, 0.038]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $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.0005 \lor \neg \left(a \leq 0.038\right):\\
      \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if a < -5.0000000000000001e-4 or 0.0379999999999999991 < a

        1. Initial program 76.5%

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

        if -5.0000000000000001e-4 < a < 0.0379999999999999991

        1. Initial program 77.8%

          \[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 rewrites77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto x + \left(\frac{\tan z + \tan y}{1 - \color{blue}{\tan z \cdot \tan y}} - a\right) \]
            16. fp-cancel-sub-sign-invN/A

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

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

              \[\leadsto x + \left(\frac{\tan z + \tan y}{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\tan z\right), \tan y, 1\right)}} - a\right) \]
            19. lower-neg.f6499.5

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

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

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

        Alternative 5: 69.3% accurate, 0.5× speedup?

        \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.005 \lor \neg \left(\tan a \leq 5 \cdot 10^{-6}\right):\\ \;\;\;\;\left(\tan z + x\right) - \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 (<= (tan a) -0.005) (not (<= (tan a) 5e-6)))
           (- (+ (tan z) 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 ((tan(a) <= -0.005) || !(tan(a) <= 5e-6)) {
        		tmp = (tan(z) + 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 ((tan(a) <= (-0.005d0)) .or. (.not. (tan(a) <= 5d-6))) then
                tmp = (tan(z) + 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 ((Math.tan(a) <= -0.005) || !(Math.tan(a) <= 5e-6)) {
        		tmp = (Math.tan(z) + 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 (math.tan(a) <= -0.005) or not (math.tan(a) <= 5e-6):
        		tmp = (math.tan(z) + 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 ((tan(a) <= -0.005) || !(tan(a) <= 5e-6))
        		tmp = Float64(Float64(tan(z) + 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 ((tan(a) <= -0.005) || ~((tan(a) <= 5e-6)))
        		tmp = (tan(z) + 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[N[Tan[a], $MachinePrecision], -0.005], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 5e-6]], $MachinePrecision]], N[(N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision] - 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}\;\tan a \leq -0.005 \lor \neg \left(\tan a \leq 5 \cdot 10^{-6}\right):\\
        \;\;\;\;\left(\tan z + x\right) - \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 (tan.f64 a) < -0.0050000000000000001 or 5.00000000000000041e-6 < (tan.f64 a)

          1. Initial program 76.2%

            \[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 rewrites22.7%

              \[\leadsto \color{blue}{x} \]
            2. Taylor expanded in y around 0

              \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
            3. Step-by-step derivation
              1. Applied rewrites56.4%

                \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
              2. Step-by-step derivation
                1. Applied rewrites56.4%

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

                if -0.0050000000000000001 < (tan.f64 a) < 5.00000000000000041e-6

                1. Initial program 78.2%

                  \[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.2%

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

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

                Alternative 6: 78.7% accurate, 1.0× speedup?

                \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5.9 \cdot 10^{-11}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                (FPCore (x y z a)
                 :precision binary64
                 (if (<= y -5.9e-11) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
                assert(x < y && y < z && z < a);
                double code(double x, double y, double z, double a) {
                	double tmp;
                	if (y <= -5.9e-11) {
                		tmp = x + (tan(y) - tan(a));
                	} else {
                		tmp = x + (tan(z) - tan(a));
                	}
                	return tmp;
                }
                
                NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x, y, z, a)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z
                    real(8), intent (in) :: a
                    real(8) :: tmp
                    if (y <= (-5.9d-11)) then
                        tmp = x + (tan(y) - tan(a))
                    else
                        tmp = x + (tan(z) - tan(a))
                    end if
                    code = tmp
                end function
                
                assert x < y && y < z && z < a;
                public static double code(double x, double y, double z, double a) {
                	double tmp;
                	if (y <= -5.9e-11) {
                		tmp = x + (Math.tan(y) - Math.tan(a));
                	} else {
                		tmp = x + (Math.tan(z) - Math.tan(a));
                	}
                	return tmp;
                }
                
                [x, y, z, a] = sort([x, y, z, a])
                def code(x, y, z, a):
                	tmp = 0
                	if y <= -5.9e-11:
                		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 (y <= -5.9e-11)
                		tmp = Float64(x + Float64(tan(y) - tan(a)));
                	else
                		tmp = Float64(x + Float64(tan(z) - tan(a)));
                	end
                	return tmp
                end
                
                x, y, z, a = num2cell(sort([x, y, z, a])){:}
                function tmp_2 = code(x, y, z, a)
                	tmp = 0.0;
                	if (y <= -5.9e-11)
                		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[y, -5.9e-11], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq -5.9 \cdot 10^{-11}:\\
                \;\;\;\;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 y < -5.9000000000000003e-11

                  1. Initial program 66.2%

                    \[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 rewrites66.6%

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

                    if -5.9000000000000003e-11 < y

                    1. Initial program 81.6%

                      \[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 rewrites71.2%

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

                    Alternative 7: 78.6% accurate, 1.0× speedup?

                    \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5.9 \cdot 10^{-11}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\tan z + x\right) - \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 -5.9e-11) (+ x (- (tan y) (tan a))) (- (+ (tan z) x) (tan a))))
                    assert(x < y && y < z && z < a);
                    double code(double x, double y, double z, double a) {
                    	double tmp;
                    	if (y <= -5.9e-11) {
                    		tmp = x + (tan(y) - tan(a));
                    	} else {
                    		tmp = (tan(z) + x) - tan(a);
                    	}
                    	return tmp;
                    }
                    
                    NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(x, y, z, a)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8), intent (in) :: a
                        real(8) :: tmp
                        if (y <= (-5.9d-11)) then
                            tmp = x + (tan(y) - tan(a))
                        else
                            tmp = (tan(z) + x) - tan(a)
                        end if
                        code = tmp
                    end function
                    
                    assert x < y && y < z && z < a;
                    public static double code(double x, double y, double z, double a) {
                    	double tmp;
                    	if (y <= -5.9e-11) {
                    		tmp = x + (Math.tan(y) - Math.tan(a));
                    	} else {
                    		tmp = (Math.tan(z) + x) - Math.tan(a);
                    	}
                    	return tmp;
                    }
                    
                    [x, y, z, a] = sort([x, y, z, a])
                    def code(x, y, z, a):
                    	tmp = 0
                    	if y <= -5.9e-11:
                    		tmp = x + (math.tan(y) - math.tan(a))
                    	else:
                    		tmp = (math.tan(z) + x) - math.tan(a)
                    	return tmp
                    
                    x, y, z, a = sort([x, y, z, a])
                    function code(x, y, z, a)
                    	tmp = 0.0
                    	if (y <= -5.9e-11)
                    		tmp = Float64(x + Float64(tan(y) - tan(a)));
                    	else
                    		tmp = Float64(Float64(tan(z) + 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 <= -5.9e-11)
                    		tmp = x + (tan(y) - tan(a));
                    	else
                    		tmp = (tan(z) + x) - tan(a);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
                    code[x_, y_, z_, a_] := If[LessEqual[y, -5.9e-11], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[z], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq -5.9 \cdot 10^{-11}:\\
                    \;\;\;\;x + \left(\tan y - \tan a\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(\tan z + x\right) - \tan a\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < -5.9000000000000003e-11

                      1. Initial program 66.2%

                        \[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 rewrites66.6%

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

                        if -5.9000000000000003e-11 < y

                        1. Initial program 81.6%

                          \[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 rewrites33.5%

                            \[\leadsto \color{blue}{x} \]
                          2. Taylor expanded in y around 0

                            \[\leadsto \color{blue}{\left(x + \frac{\sin z}{\cos z}\right) - \frac{\sin a}{\cos a}} \]
                          3. Step-by-step derivation
                            1. Applied rewrites71.1%

                              \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                            2. Step-by-step derivation
                              1. Applied rewrites71.2%

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

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

                            Alternative 8: 79.0% 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 77.2%

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

                            Alternative 9: 43.5% accurate, 1.7× speedup?

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

                              1. Initial program 77.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 rewrites38.8%

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

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

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

                                  if -5.00000000000000018e-11 < (+.f64 y z) < 0.0050000000000000001

                                  1. Initial program 99.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 rewrites59.6%

                                      \[\leadsto \color{blue}{x} \]

                                    if 0.0050000000000000001 < (+.f64 y z)

                                    1. Initial program 64.7%

                                      \[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 rewrites39.5%

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

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

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

                                      Alternative 10: 50.7% accurate, 1.7× speedup?

                                      \[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -4.7 \lor \neg \left(a \leq 0.036\right):\\ \;\;\;\;x\\ \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 -4.7) (not (<= a 0.036))) x (+ 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 <= -4.7) || !(a <= 0.036)) {
                                      		tmp = x;
                                      	} 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 <= (-4.7d0)) .or. (.not. (a <= 0.036d0))) then
                                              tmp = x
                                          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 <= -4.7) || !(a <= 0.036)) {
                                      		tmp = x;
                                      	} 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 <= -4.7) or not (a <= 0.036):
                                      		tmp = x
                                      	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 <= -4.7) || !(a <= 0.036))
                                      		tmp = x;
                                      	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 <= -4.7) || ~((a <= 0.036)))
                                      		tmp = x;
                                      	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, -4.7], N[Not[LessEqual[a, 0.036]], $MachinePrecision]], x, 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 -4.7 \lor \neg \left(a \leq 0.036\right):\\
                                      \;\;\;\;x\\
                                      
                                      \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 < -4.70000000000000018 or 0.0359999999999999973 < a

                                        1. Initial program 76.5%

                                          \[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 rewrites22.6%

                                            \[\leadsto \color{blue}{x} \]

                                          if -4.70000000000000018 < a < 0.0359999999999999973

                                          1. Initial program 77.8%

                                            \[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 rewrites77.8%

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

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

                                          Alternative 11: 41.2% accurate, 1.8× speedup?

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

                                            1. Initial program 76.5%

                                              \[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 rewrites22.6%

                                                \[\leadsto \color{blue}{x} \]

                                              if -2.39999999999999991 < a < 1.6000000000000001

                                              1. Initial program 77.8%

                                                \[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 rewrites77.8%

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

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

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

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

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

                                                  \[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 rewrites30.7%

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

                                                  Reproduce

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