tan-example (used to crash)

Percentage Accurate: 79.3% → 99.7%
Time: 17.1s
Alternatives: 13
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 13 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.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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

Alternative 1: 99.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan y \cdot \tan z\\ x + \left(\frac{\tan y + \tan z}{1 - {t\_0}^{3}} \cdot \mathsf{fma}\left(t\_0, \mathsf{fma}\left(\tan y, \tan z, 1\right), 1\right) - \tan a\right) \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (* (tan y) (tan z))))
   (+
    x
    (-
     (*
      (/ (+ (tan y) (tan z)) (- 1.0 (pow t_0 3.0)))
      (fma t_0 (fma (tan y) (tan z) 1.0) 1.0))
     (tan a)))))
double code(double x, double y, double z, double a) {
	double t_0 = tan(y) * tan(z);
	return x + ((((tan(y) + tan(z)) / (1.0 - pow(t_0, 3.0))) * fma(t_0, fma(tan(y), tan(z), 1.0), 1.0)) - tan(a));
}
function code(x, y, z, a)
	t_0 = Float64(tan(y) * tan(z))
	return Float64(x + Float64(Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - (t_0 ^ 3.0))) * fma(t_0, fma(tan(y), tan(z), 1.0), 1.0)) - tan(a)))
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan y \cdot \tan z\\
x + \left(\frac{\tan y + \tan z}{1 - {t\_0}^{3}} \cdot \mathsf{fma}\left(t\_0, \mathsf{fma}\left(\tan y, \tan z, 1\right), 1\right) - \tan a\right)
\end{array}
\end{array}
Derivation
  1. Initial program 77.7%

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

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

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

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

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

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

Alternative 2: 88.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -1 \cdot 10^{-13}:\\ \;\;\;\;\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{elif}\;\tan a \leq 2 \cdot 10^{-34}:\\ \;\;\;\;\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= (tan a) -1e-13)
   (fma (/ (- (/ (sin (+ z y)) (cos (+ z y))) (/ (sin a) (cos a))) x) x x)
   (if (<= (tan a) 2e-34)
     (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (- x))
     (+ x (- (tan (+ y z)) (tan a))))))
double code(double x, double y, double z, double a) {
	double tmp;
	if (tan(a) <= -1e-13) {
		tmp = fma((((sin((z + y)) / cos((z + y))) - (sin(a) / cos(a))) / x), x, x);
	} else if (tan(a) <= 2e-34) {
		tmp = ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - -x;
	} else {
		tmp = x + (tan((y + z)) - tan(a));
	}
	return tmp;
}
function code(x, y, z, a)
	tmp = 0.0
	if (tan(a) <= -1e-13)
		tmp = fma(Float64(Float64(Float64(sin(Float64(z + y)) / cos(Float64(z + y))) - Float64(sin(a) / cos(a))) / x), x, x);
	elseif (tan(a) <= 2e-34)
		tmp = Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(-x));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	end
	return tmp
end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -1e-13], 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], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-34], N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - (-x)), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -1 \cdot 10^{-13}:\\
\;\;\;\;\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{elif}\;\tan a \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(-x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (tan.f64 a) < -1e-13

    1. Initial program 74.7%

      \[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. associate--l+N/A

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sin \left(y + z\right)}{x \cdot \cos \left(y + z\right)} - \frac{\sin a}{x \cdot \cos a}, x, x\right)} \]
    5. Applied rewrites74.7%

      \[\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 -1e-13 < (tan.f64 a) < 1.99999999999999986e-34

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

        \[\leadsto \tan \color{blue}{\left(z + y\right)} - \left(\tan a - x\right) \]
      9. lower--.f6479.6

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\tan a - x\right)} \]
    4. Applied rewrites79.6%

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

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

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      2. lower-neg.f6479.6

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(-x\right)} \]
    7. Applied rewrites79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999986e-34 < (tan.f64 a)

    1. Initial program 77.2%

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

Alternative 3: 99.7% accurate, 0.4× speedup?

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

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

real(8) function code(x, y, z, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Derivation
  1. Initial program 77.7%

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

Alternative 4: 88.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.7 \cdot 10^{-13} \lor \neg \left(a \leq 1.5 \cdot 10^{-30}\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -1.7e-13) (not (<= a 1.5e-30)))
   (+ x (- (tan (+ y z)) (tan a)))
   (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (- x))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -1.7e-13) || !(a <= 1.5e-30)) {
		tmp = x + (tan((y + z)) - tan(a));
	} else {
		tmp = ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - -x;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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 <= (-1.7d-13)) .or. (.not. (a <= 1.5d-30))) then
        tmp = x + (tan((y + z)) - tan(a))
    else
        tmp = ((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -1.7e-13) || !(a <= 1.5e-30)) {
		tmp = x + (Math.tan((y + z)) - Math.tan(a));
	} else {
		tmp = ((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - -x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -1.7e-13) or not (a <= 1.5e-30):
		tmp = x + (math.tan((y + z)) - math.tan(a))
	else:
		tmp = ((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - -x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -1.7e-13) || !(a <= 1.5e-30))
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	else
		tmp = Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((a <= -1.7e-13) || ~((a <= 1.5e-30)))
		tmp = x + (tan((y + z)) - tan(a));
	else
		tmp = ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.7e-13], N[Not[LessEqual[a, 1.5e-30]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - (-x)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{-13} \lor \neg \left(a \leq 1.5 \cdot 10^{-30}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.70000000000000008e-13 or 1.49999999999999995e-30 < a

    1. Initial program 76.0%

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

    if -1.70000000000000008e-13 < a < 1.49999999999999995e-30

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

        \[\leadsto \tan \color{blue}{\left(z + y\right)} - \left(\tan a - x\right) \]
      9. lower--.f6479.6

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\tan a - x\right)} \]
    4. Applied rewrites79.6%

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

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

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      2. lower-neg.f6479.6

        \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(-x\right)} \]
    7. Applied rewrites79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}} - \left(-x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.0%

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

Alternative 5: 59.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.0001 \lor \neg \left(\tan a \leq 0.19\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= (tan a) -0.0001) (not (<= (tan a) 0.19)))
   (- x (tan a))
   (- (tan (+ z y)) (- x))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((tan(a) <= -0.0001) || !(tan(a) <= 0.19)) {
		tmp = x - tan(a);
	} else {
		tmp = tan((z + y)) - -x;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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.0001d0)) .or. (.not. (tan(a) <= 0.19d0))) then
        tmp = x - tan(a)
    else
        tmp = tan((z + y)) - -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((Math.tan(a) <= -0.0001) || !(Math.tan(a) <= 0.19)) {
		tmp = x - Math.tan(a);
	} else {
		tmp = Math.tan((z + y)) - -x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (math.tan(a) <= -0.0001) or not (math.tan(a) <= 0.19):
		tmp = x - math.tan(a)
	else:
		tmp = math.tan((z + y)) - -x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((tan(a) <= -0.0001) || !(tan(a) <= 0.19))
		tmp = Float64(x - tan(a));
	else
		tmp = Float64(tan(Float64(z + y)) - Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((tan(a) <= -0.0001) || ~((tan(a) <= 0.19)))
		tmp = x - tan(a);
	else
		tmp = tan((z + y)) - -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.0001], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.19]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.0001 \lor \neg \left(\tan a \leq 0.19\right):\\
\;\;\;\;x - \tan a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (tan.f64 a) < -1.00000000000000005e-4 or 0.19 < (tan.f64 a)

    1. Initial program 75.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
      9. lower-cos.f6458.4

        \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
    5. Applied rewrites58.4%

      \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
    6. Taylor expanded in z around 0

      \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
    7. Step-by-step derivation
      1. Applied rewrites43.0%

        \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
      2. Step-by-step derivation
        1. Applied rewrites43.0%

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

        if -1.00000000000000005e-4 < (tan.f64 a) < 0.19

        1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
          2. lower-neg.f6476.3

            \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(-x\right)} \]
        7. Applied rewrites76.3%

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

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

      Alternative 6: 60.1% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y + z \leq -5 \cdot 10^{-9}:\\ \;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (+ y z) -5e-9) (- (tan (+ z y)) (- x)) (+ x (- (tan z) (tan a)))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -5e-9) {
      		tmp = tan((z + y)) - -x;
      	} else {
      		tmp = x + (tan(z) - tan(a));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(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-9)) then
              tmp = tan((z + y)) - -x
          else
              tmp = x + (tan(z) - tan(a))
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -5e-9) {
      		tmp = Math.tan((z + y)) - -x;
      	} else {
      		tmp = x + (Math.tan(z) - Math.tan(a));
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if (y + z) <= -5e-9:
      		tmp = math.tan((z + y)) - -x
      	else:
      		tmp = x + (math.tan(z) - math.tan(a))
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (Float64(y + z) <= -5e-9)
      		tmp = Float64(tan(Float64(z + y)) - Float64(-x));
      	else
      		tmp = Float64(x + Float64(tan(z) - tan(a)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if ((y + z) <= -5e-9)
      		tmp = tan((z + y)) - -x;
      	else
      		tmp = x + (tan(z) - tan(a));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-9], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y + z \leq -5 \cdot 10^{-9}:\\
      \;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\tan z - \tan a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 y z) < -5.0000000000000001e-9

        1. Initial program 66.3%

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

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

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

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

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

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

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

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

            \[\leadsto \tan \color{blue}{\left(z + y\right)} - \left(\tan a - x\right) \]
          9. lower--.f6466.3

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

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

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

            \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
          2. lower-neg.f6444.4

            \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(-x\right)} \]
        7. Applied rewrites44.4%

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

        if -5.0000000000000001e-9 < (+.f64 y z)

        1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 7: 79.3% 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}
        
        Derivation
        1. Initial program 77.7%

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

        Alternative 8: 60.3% accurate, 1.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.19:\\ \;\;\;\;x - \tan a\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-14}:\\ \;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a - x\right)\\ \mathbf{else}:\\ \;\;\;\;x - \tan \left(\left(\mathsf{PI}\left(\right) + a\right) + \mathsf{PI}\left(\right)\right)\\ \end{array} \end{array} \]
        (FPCore (x y z a)
         :precision binary64
         (if (<= a -0.19)
           (- x (tan a))
           (if (<= a 2.35e-14)
             (- (tan (+ z y)) (- (* (fma (* a a) 0.3333333333333333 1.0) a) x))
             (- x (tan (+ (+ (PI) a) (PI)))))))
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;a \leq -0.19:\\
        \;\;\;\;x - \tan a\\
        
        \mathbf{elif}\;a \leq 2.35 \cdot 10^{-14}:\\
        \;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a - x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;x - \tan \left(\left(\mathsf{PI}\left(\right) + a\right) + \mathsf{PI}\left(\right)\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if a < -0.19

          1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
            9. lower-cos.f6457.2

              \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
          5. Applied rewrites57.2%

            \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
          6. Taylor expanded in z around 0

            \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
          7. Step-by-step derivation
            1. Applied rewrites42.3%

              \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
            2. Step-by-step derivation
              1. Applied rewrites42.3%

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

              if -0.19 < a < 2.3500000000000001e-14

              1. Initial program 80.6%

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

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

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

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

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

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

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

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

                  \[\leadsto \tan \color{blue}{\left(z + y\right)} - \left(\tan a - x\right) \]
                9. lower--.f6480.6

                  \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\tan a - x\right)} \]
              4. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

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

              if 2.3500000000000001e-14 < a

              1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
              5. Applied rewrites57.8%

                \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
              6. Taylor expanded in z around 0

                \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
              7. Step-by-step derivation
                1. Applied rewrites40.2%

                  \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                2. Step-by-step derivation
                  1. Applied rewrites40.4%

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

                Alternative 9: 60.2% accurate, 1.7× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.001:\\ \;\;\;\;x - \tan a\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-14}:\\ \;\;\;\;\tan \left(z + y\right) - \left(a - x\right)\\ \mathbf{else}:\\ \;\;\;\;x - \tan \left(\left(\mathsf{PI}\left(\right) + a\right) + \mathsf{PI}\left(\right)\right)\\ \end{array} \end{array} \]
                (FPCore (x y z a)
                 :precision binary64
                 (if (<= a -0.001)
                   (- x (tan a))
                   (if (<= a 2.35e-14)
                     (- (tan (+ z y)) (- a x))
                     (- x (tan (+ (+ (PI) a) (PI)))))))
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;a \leq -0.001:\\
                \;\;\;\;x - \tan a\\
                
                \mathbf{elif}\;a \leq 2.35 \cdot 10^{-14}:\\
                \;\;\;\;\tan \left(z + y\right) - \left(a - x\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;x - \tan \left(\left(\mathsf{PI}\left(\right) + a\right) + \mathsf{PI}\left(\right)\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if a < -1e-3

                  1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                  5. Applied rewrites57.8%

                    \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                  6. Taylor expanded in z around 0

                    \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                  7. Step-by-step derivation
                    1. Applied rewrites43.2%

                      \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                    2. Step-by-step derivation
                      1. Applied rewrites43.1%

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

                      if -1e-3 < a < 2.3500000000000001e-14

                      1. Initial program 80.4%

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

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

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

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

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

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

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

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

                          \[\leadsto \tan \color{blue}{\left(z + y\right)} - \left(\tan a - x\right) \]
                        9. lower--.f6480.4

                          \[\leadsto \tan \left(z + y\right) - \color{blue}{\left(\tan a - x\right)} \]
                      4. Applied rewrites80.4%

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

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

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

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

                      if 2.3500000000000001e-14 < a

                      1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                      5. Applied rewrites57.8%

                        \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                      6. Taylor expanded in z around 0

                        \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                      7. Step-by-step derivation
                        1. Applied rewrites40.2%

                          \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                        2. Step-by-step derivation
                          1. Applied rewrites40.4%

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

                        Alternative 10: 42.1% accurate, 2.0× speedup?

                        \[\begin{array}{l} \\ x - \tan a \end{array} \]
                        (FPCore (x y z a) :precision binary64 (- x (tan a)))
                        double code(double x, double y, double z, double a) {
                        	return x - 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(a)
                        end function
                        
                        public static double code(double x, double y, double z, double a) {
                        	return x - Math.tan(a);
                        }
                        
                        def code(x, y, z, a):
                        	return x - math.tan(a)
                        
                        function code(x, y, z, a)
                        	return Float64(x - tan(a))
                        end
                        
                        function tmp = code(x, y, z, a)
                        	tmp = x - tan(a);
                        end
                        
                        code[x_, y_, z_, a_] := N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]
                        
                        \begin{array}{l}
                        
                        \\
                        x - \tan a
                        \end{array}
                        
                        Derivation
                        1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                          9. lower-cos.f6462.0

                            \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                        5. Applied rewrites62.0%

                          \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                        6. Taylor expanded in z around 0

                          \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                        7. Step-by-step derivation
                          1. Applied rewrites44.5%

                            \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                          2. Step-by-step derivation
                            1. Applied rewrites44.5%

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

                            Alternative 11: 22.4% accurate, 10.5× speedup?

                            \[\begin{array}{l} \\ \left(1 - \frac{a}{x}\right) \cdot x \end{array} \]
                            (FPCore (x y z a) :precision binary64 (* (- 1.0 (/ a x)) x))
                            double code(double x, double y, double z, double a) {
                            	return (1.0 - (a / x)) * x;
                            }
                            
                            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 = (1.0d0 - (a / x)) * x
                            end function
                            
                            public static double code(double x, double y, double z, double a) {
                            	return (1.0 - (a / x)) * x;
                            }
                            
                            def code(x, y, z, a):
                            	return (1.0 - (a / x)) * x
                            
                            function code(x, y, z, a)
                            	return Float64(Float64(1.0 - Float64(a / x)) * x)
                            end
                            
                            function tmp = code(x, y, z, a)
                            	tmp = (1.0 - (a / x)) * x;
                            end
                            
                            code[x_, y_, z_, a_] := N[(N[(1.0 - N[(a / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            \left(1 - \frac{a}{x}\right) \cdot x
                            \end{array}
                            
                            Derivation
                            1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                              9. lower-cos.f6462.0

                                \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                            5. Applied rewrites62.0%

                              \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                            6. Taylor expanded in z around 0

                              \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                            7. Step-by-step derivation
                              1. Applied rewrites44.5%

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

                                \[\leadsto x + -1 \cdot \color{blue}{a} \]
                              3. Step-by-step derivation
                                1. Applied rewrites24.8%

                                  \[\leadsto x - a \]
                                2. Taylor expanded in x around inf

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

                                    \[\leadsto \left(1 - \frac{a}{x}\right) \cdot x \]
                                  2. Add Preprocessing

                                  Alternative 12: 22.4% accurate, 52.5× speedup?

                                  \[\begin{array}{l} \\ x - a \end{array} \]
                                  (FPCore (x y z a) :precision binary64 (- x a))
                                  double code(double x, double y, double z, double a) {
                                  	return x - 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 - a
                                  end function
                                  
                                  public static double code(double x, double y, double z, double a) {
                                  	return x - a;
                                  }
                                  
                                  def code(x, y, z, a):
                                  	return x - a
                                  
                                  function code(x, y, z, a)
                                  	return Float64(x - a)
                                  end
                                  
                                  function tmp = code(x, y, z, a)
                                  	tmp = x - a;
                                  end
                                  
                                  code[x_, y_, z_, a_] := N[(x - a), $MachinePrecision]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  x - a
                                  \end{array}
                                  
                                  Derivation
                                  1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                                    9. lower-cos.f6462.0

                                      \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                                  5. Applied rewrites62.0%

                                    \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                                  6. Taylor expanded in z around 0

                                    \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites44.5%

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

                                      \[\leadsto x + -1 \cdot \color{blue}{a} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites24.8%

                                        \[\leadsto x - a \]
                                      2. Add Preprocessing

                                      Alternative 13: 3.5% accurate, 70.0× speedup?

                                      \[\begin{array}{l} \\ -a \end{array} \]
                                      (FPCore (x y z a) :precision binary64 (- a))
                                      double code(double x, double y, double z, double a) {
                                      	return -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 = -a
                                      end function
                                      
                                      public static double code(double x, double y, double z, double a) {
                                      	return -a;
                                      }
                                      
                                      def code(x, y, z, a):
                                      	return -a
                                      
                                      function code(x, y, z, a)
                                      	return Float64(-a)
                                      end
                                      
                                      function tmp = code(x, y, z, a)
                                      	tmp = -a;
                                      end
                                      
                                      code[x_, y_, z_, a_] := (-a)
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      -a
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\color{blue}{\sin a}}{\cos a} \]
                                        9. lower-cos.f6462.0

                                          \[\leadsto \left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\color{blue}{\cos a}} \]
                                      5. Applied rewrites62.0%

                                        \[\leadsto \color{blue}{\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}} \]
                                      6. Taylor expanded in z around 0

                                        \[\leadsto x - \color{blue}{\frac{\sin a}{\cos a}} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites44.5%

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

                                          \[\leadsto x + -1 \cdot \color{blue}{a} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites24.8%

                                            \[\leadsto x - a \]
                                          2. Taylor expanded in x around 0

                                            \[\leadsto -1 \cdot a \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites3.4%

                                              \[\leadsto -a \]
                                            2. Add Preprocessing

                                            Reproduce

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