tan-example (used to crash)

Percentage Accurate: 78.8% → 99.6%
Time: 38.4s
Alternatives: 16
Speedup: 1.0×

Specification

?
\[\left(\left(\left(x = 0 \lor 0.5884142 \leq x \land x \leq 505.5909\right) \land \left(-1.796658 \cdot 10^{+308} \leq y \land y \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq y \land y \leq 1.751224 \cdot 10^{+308}\right)\right) \land \left(-1.776707 \cdot 10^{+308} \leq z \land z \leq -8.599796 \cdot 10^{-310} \lor 3.293145 \cdot 10^{-311} \leq z \land z \leq 1.725154 \cdot 10^{+308}\right)\right) \land \left(-1.796658 \cdot 10^{+308} \leq a \land a \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq a \land a \leq 1.751224 \cdot 10^{+308}\right)\]
\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
    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 16 alternatives:

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

Initial Program: 78.8% 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));
}
real(8) function code(x, y, z, a)
    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.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{{\tan y}^{2}}{\tan y - \tan z} + \frac{{\tan z}^{2}}{\tan z - \tan y}}{1 - \tan y \cdot \tan z} + \left(x - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  (/
   (+
    (/ (pow (tan y) 2.0) (- (tan y) (tan z)))
    (/ (pow (tan z) 2.0) (- (tan z) (tan y))))
   (- 1.0 (* (tan y) (tan z))))
  (- x (tan a))))
double code(double x, double y, double z, double a) {
	return (((pow(tan(y), 2.0) / (tan(y) - tan(z))) + (pow(tan(z), 2.0) / (tan(z) - tan(y)))) / (1.0 - (tan(y) * tan(z)))) + (x - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = ((((tan(y) ** 2.0d0) / (tan(y) - tan(z))) + ((tan(z) ** 2.0d0) / (tan(z) - tan(y)))) / (1.0d0 - (tan(y) * tan(z)))) + (x - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return (((Math.pow(Math.tan(y), 2.0) / (Math.tan(y) - Math.tan(z))) + (Math.pow(Math.tan(z), 2.0) / (Math.tan(z) - Math.tan(y)))) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - Math.tan(a));
}
def code(x, y, z, a):
	return (((math.pow(math.tan(y), 2.0) / (math.tan(y) - math.tan(z))) + (math.pow(math.tan(z), 2.0) / (math.tan(z) - math.tan(y)))) / (1.0 - (math.tan(y) * math.tan(z)))) + (x - math.tan(a))
function code(x, y, z, a)
	return Float64(Float64(Float64(Float64((tan(y) ^ 2.0) / Float64(tan(y) - tan(z))) + Float64((tan(z) ^ 2.0) / Float64(tan(z) - tan(y)))) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = ((((tan(y) ^ 2.0) / (tan(y) - tan(z))) + ((tan(z) ^ 2.0) / (tan(z) - tan(y)))) / (1.0 - (tan(y) * tan(z)))) + (x - tan(a));
end
code[x_, y_, z_, a_] := N[(N[(N[(N[(N[Power[N[Tan[y], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Tan[y], $MachinePrecision] - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Tan[z], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Tan[z], $MachinePrecision] - N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

      \[\leadsto \color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x} \]
    2. associate-+l-81.1%

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\left(\tan a - x\right)\right)} \]
  5. Step-by-step derivation
    1. fmm-undef99.6%

      \[\leadsto \color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - \left(\tan a - x\right)} \]
    2. add-cube-cbrt97.9%

      \[\leadsto \left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - \color{blue}{\left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right) \cdot \sqrt[3]{\tan a - x}} \]
    3. prod-diff97.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right)} \]
    4. pow297.9%

      \[\leadsto \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot \color{blue}{{\left(\sqrt[3]{\tan a - x}\right)}^{2}}\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right) \]
  6. Applied egg-rr97.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot {\left(\sqrt[3]{\tan a - x}\right)}^{2}\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, {\left(\sqrt[3]{\tan a - x}\right)}^{2}, \sqrt[3]{\tan a - x} \cdot {\left(\sqrt[3]{\tan a - x}\right)}^{2}\right)} \]
  7. Step-by-step derivation
    1. Simplified99.7%

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

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

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

        \[\leadsto \left(\frac{\frac{\color{blue}{{\tan y}^{2}}}{\tan y - \tan z} - \frac{\tan z \cdot \tan z}{\tan y - \tan z}}{1 - \tan y \cdot \tan z} + \left(x - \tan a\right)\right) + \left(\left(x - \tan a\right) + \left(\tan a - x\right)\right) \]
      4. pow299.7%

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

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

      \[\leadsto \left(\frac{\frac{{\tan y}^{2}}{\tan y - \tan z} - \frac{{\tan z}^{2}}{\tan y - \tan z}}{1 - \tan y \cdot \tan z} + \left(x - \tan a\right)\right) + \color{blue}{0} \]
    5. Final simplification99.7%

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

    Alternative 2: 88.2% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\ \;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{-1}{\tan y \cdot \tan z + -1} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\ \end{array} \end{array} \]
    (FPCore (x y z a)
     :precision binary64
     (if (<= (tan a) -0.01)
       (+ x (- (tan (+ y z)) (tan a)))
       (if (<= (tan a) 5e-51)
         (+ x (- (* (+ (tan y) (tan z)) (/ -1.0 (+ (* (tan y) (tan z)) -1.0))) a))
         (+ (/ (sin (+ y z)) (cos (+ y z))) (- x (tan a))))))
    double code(double x, double y, double z, double a) {
    	double tmp;
    	if (tan(a) <= -0.01) {
    		tmp = x + (tan((y + z)) - tan(a));
    	} else if (tan(a) <= 5e-51) {
    		tmp = x + (((tan(y) + tan(z)) * (-1.0 / ((tan(y) * tan(z)) + -1.0))) - a);
    	} else {
    		tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a));
    	}
    	return tmp;
    }
    
    real(8) function code(x, y, z, a)
        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.01d0)) then
            tmp = x + (tan((y + z)) - tan(a))
        else if (tan(a) <= 5d-51) then
            tmp = x + (((tan(y) + tan(z)) * ((-1.0d0) / ((tan(y) * tan(z)) + (-1.0d0)))) - a)
        else
            tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a))
        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.01) {
    		tmp = x + (Math.tan((y + z)) - Math.tan(a));
    	} else if (Math.tan(a) <= 5e-51) {
    		tmp = x + (((Math.tan(y) + Math.tan(z)) * (-1.0 / ((Math.tan(y) * Math.tan(z)) + -1.0))) - a);
    	} else {
    		tmp = (Math.sin((y + z)) / Math.cos((y + z))) + (x - Math.tan(a));
    	}
    	return tmp;
    }
    
    def code(x, y, z, a):
    	tmp = 0
    	if math.tan(a) <= -0.01:
    		tmp = x + (math.tan((y + z)) - math.tan(a))
    	elif math.tan(a) <= 5e-51:
    		tmp = x + (((math.tan(y) + math.tan(z)) * (-1.0 / ((math.tan(y) * math.tan(z)) + -1.0))) - a)
    	else:
    		tmp = (math.sin((y + z)) / math.cos((y + z))) + (x - math.tan(a))
    	return tmp
    
    function code(x, y, z, a)
    	tmp = 0.0
    	if (tan(a) <= -0.01)
    		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
    	elseif (tan(a) <= 5e-51)
    		tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(-1.0 / Float64(Float64(tan(y) * tan(z)) + -1.0))) - a));
    	else
    		tmp = Float64(Float64(sin(Float64(y + z)) / cos(Float64(y + z))) + Float64(x - tan(a)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, a)
    	tmp = 0.0;
    	if (tan(a) <= -0.01)
    		tmp = x + (tan((y + z)) - tan(a));
    	elseif (tan(a) <= 5e-51)
    		tmp = x + (((tan(y) + tan(z)) * (-1.0 / ((tan(y) * tan(z)) + -1.0))) - a);
    	else
    		tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 5e-51], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\tan a \leq -0.01:\\
    \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
    
    \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\
    \;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{-1}{\tan y \cdot \tan z + -1} - a\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (tan.f64 a) < -0.0100000000000000002

      1. Initial program 83.6%

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

      if -0.0100000000000000002 < (tan.f64 a) < 5.00000000000000004e-51

      1. Initial program 81.4%

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

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

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

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

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

      if 5.00000000000000004e-51 < (tan.f64 a)

      1. Initial program 77.9%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. +-commutative77.9%

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x} \]
        2. sub-neg77.9%

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + \left(-\tan a\right)\right)} + x \]
        3. associate-+l+78.0%

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

          \[\leadsto \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} + \left(\left(-\tan a\right) + x\right) \]
        5. div-inv77.9%

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \left(-\tan a\right) + x\right)} \]
        7. neg-mul-177.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-1 \cdot \tan a} + x\right) \]
        8. fma-define77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\mathsf{fma}\left(-1, \tan a, x\right)}\right) \]
      4. Applied egg-rr77.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \mathsf{fma}\left(-1, \tan a, x\right)\right)} \]
      5. Step-by-step derivation
        1. fma-undefine77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-1 \cdot \tan a + x}\right) \]
        2. neg-mul-177.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\left(-\tan a\right)} + x\right) \]
        3. neg-sub077.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\left(0 - \tan a\right)} + x\right) \]
        4. associate-+l-77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{0 - \left(\tan a - x\right)}\right) \]
        5. neg-sub077.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-\left(\tan a - x\right)}\right) \]
        6. fmm-undef77.9%

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

          \[\leadsto \color{blue}{\frac{\sin \left(y + z\right) \cdot 1}{\cos \left(y + z\right)}} - \left(\tan a - x\right) \]
        8. *-rgt-identity78.0%

          \[\leadsto \frac{\color{blue}{\sin \left(y + z\right)}}{\cos \left(y + z\right)} - \left(\tan a - x\right) \]
      6. Simplified78.0%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\ \;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{-1}{\tan y \cdot \tan z + -1} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 3: 88.2% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\ \;\;\;\;x - \left(a + \frac{\tan y + \tan z}{\tan y \cdot \tan z + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\ \end{array} \end{array} \]
    (FPCore (x y z a)
     :precision binary64
     (if (<= (tan a) -0.01)
       (+ x (- (tan (+ y z)) (tan a)))
       (if (<= (tan a) 5e-51)
         (- x (+ a (/ (+ (tan y) (tan z)) (+ (* (tan y) (tan z)) -1.0))))
         (+ (/ (sin (+ y z)) (cos (+ y z))) (- x (tan a))))))
    double code(double x, double y, double z, double a) {
    	double tmp;
    	if (tan(a) <= -0.01) {
    		tmp = x + (tan((y + z)) - tan(a));
    	} else if (tan(a) <= 5e-51) {
    		tmp = x - (a + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + -1.0)));
    	} else {
    		tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a));
    	}
    	return tmp;
    }
    
    real(8) function code(x, y, z, a)
        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.01d0)) then
            tmp = x + (tan((y + z)) - tan(a))
        else if (tan(a) <= 5d-51) then
            tmp = x - (a + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + (-1.0d0))))
        else
            tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a))
        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.01) {
    		tmp = x + (Math.tan((y + z)) - Math.tan(a));
    	} else if (Math.tan(a) <= 5e-51) {
    		tmp = x - (a + ((Math.tan(y) + Math.tan(z)) / ((Math.tan(y) * Math.tan(z)) + -1.0)));
    	} else {
    		tmp = (Math.sin((y + z)) / Math.cos((y + z))) + (x - Math.tan(a));
    	}
    	return tmp;
    }
    
    def code(x, y, z, a):
    	tmp = 0
    	if math.tan(a) <= -0.01:
    		tmp = x + (math.tan((y + z)) - math.tan(a))
    	elif math.tan(a) <= 5e-51:
    		tmp = x - (a + ((math.tan(y) + math.tan(z)) / ((math.tan(y) * math.tan(z)) + -1.0)))
    	else:
    		tmp = (math.sin((y + z)) / math.cos((y + z))) + (x - math.tan(a))
    	return tmp
    
    function code(x, y, z, a)
    	tmp = 0.0
    	if (tan(a) <= -0.01)
    		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
    	elseif (tan(a) <= 5e-51)
    		tmp = Float64(x - Float64(a + Float64(Float64(tan(y) + tan(z)) / Float64(Float64(tan(y) * tan(z)) + -1.0))));
    	else
    		tmp = Float64(Float64(sin(Float64(y + z)) / cos(Float64(y + z))) + Float64(x - tan(a)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, a)
    	tmp = 0.0;
    	if (tan(a) <= -0.01)
    		tmp = x + (tan((y + z)) - tan(a));
    	elseif (tan(a) <= 5e-51)
    		tmp = x - (a + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + -1.0)));
    	else
    		tmp = (sin((y + z)) / cos((y + z))) + (x - tan(a));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 5e-51], N[(x - N[(a + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\tan a \leq -0.01:\\
    \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
    
    \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\
    \;\;\;\;x - \left(a + \frac{\tan y + \tan z}{\tan y \cdot \tan z + -1}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (tan.f64 a) < -0.0100000000000000002

      1. Initial program 83.6%

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

      if -0.0100000000000000002 < (tan.f64 a) < 5.00000000000000004e-51

      1. Initial program 81.4%

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

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

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

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

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

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -a\right)} \]
      6. Step-by-step derivation
        1. fmm-undef99.8%

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

          \[\leadsto x + \left(\color{blue}{\frac{\left(\tan y + \tan z\right) \cdot 1}{1 - \tan y \cdot \tan z}} - a\right) \]
        3. *-rgt-identity99.8%

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

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

      if 5.00000000000000004e-51 < (tan.f64 a)

      1. Initial program 77.9%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. +-commutative77.9%

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x} \]
        2. sub-neg77.9%

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + \left(-\tan a\right)\right)} + x \]
        3. associate-+l+78.0%

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

          \[\leadsto \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)}} + \left(\left(-\tan a\right) + x\right) \]
        5. div-inv77.9%

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \left(-\tan a\right) + x\right)} \]
        7. neg-mul-177.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-1 \cdot \tan a} + x\right) \]
        8. fma-define77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\mathsf{fma}\left(-1, \tan a, x\right)}\right) \]
      4. Applied egg-rr77.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \mathsf{fma}\left(-1, \tan a, x\right)\right)} \]
      5. Step-by-step derivation
        1. fma-undefine77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-1 \cdot \tan a + x}\right) \]
        2. neg-mul-177.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\left(-\tan a\right)} + x\right) \]
        3. neg-sub077.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{\left(0 - \tan a\right)} + x\right) \]
        4. associate-+l-77.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{0 - \left(\tan a - x\right)}\right) \]
        5. neg-sub077.9%

          \[\leadsto \mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, \color{blue}{-\left(\tan a - x\right)}\right) \]
        6. fmm-undef77.9%

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

          \[\leadsto \color{blue}{\frac{\sin \left(y + z\right) \cdot 1}{\cos \left(y + z\right)}} - \left(\tan a - x\right) \]
        8. *-rgt-identity78.0%

          \[\leadsto \frac{\color{blue}{\sin \left(y + z\right)}}{\cos \left(y + z\right)} - \left(\tan a - x\right) \]
      6. Simplified78.0%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\ \;\;\;\;x - \left(a + \frac{\tan y + \tan z}{\tan y \cdot \tan z + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 99.6% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - \tan a\right) \end{array} \]
    (FPCore (x y z a)
     :precision binary64
     (+ (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (- x (tan a))))
    double code(double x, double y, double z, double a) {
    	return ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - tan(a));
    }
    
    real(8) function code(x, y, z, a)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        real(8), intent (in) :: a
        code = ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) + (x - tan(a))
    end function
    
    public static double code(double x, double y, double z, double a) {
    	return ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - Math.tan(a));
    }
    
    def code(x, y, z, a):
    	return ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) + (x - math.tan(a))
    
    function code(x, y, z, a)
    	return Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - tan(a)))
    end
    
    function tmp = code(x, y, z, a)
    	tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - tan(a));
    end
    
    code[x_, y_, z_, a_] := N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - \tan a\right)
    \end{array}
    
    Derivation
    1. Initial program 81.1%

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

        \[\leadsto \color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x} \]
      2. associate-+l-81.1%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\left(\tan a - x\right)\right)} \]
    5. Step-by-step derivation
      1. fmm-undef99.6%

        \[\leadsto \color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - \left(\tan a - x\right)} \]
      2. add-cube-cbrt97.9%

        \[\leadsto \left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - \color{blue}{\left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right) \cdot \sqrt[3]{\tan a - x}} \]
      3. prod-diff97.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right)} \]
      4. pow297.9%

        \[\leadsto \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot \color{blue}{{\left(\sqrt[3]{\tan a - x}\right)}^{2}}\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}, \sqrt[3]{\tan a - x} \cdot \left(\sqrt[3]{\tan a - x} \cdot \sqrt[3]{\tan a - x}\right)\right) \]
    6. Applied egg-rr97.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\sqrt[3]{\tan a - x} \cdot {\left(\sqrt[3]{\tan a - x}\right)}^{2}\right) + \mathsf{fma}\left(-\sqrt[3]{\tan a - x}, {\left(\sqrt[3]{\tan a - x}\right)}^{2}, \sqrt[3]{\tan a - x} \cdot {\left(\sqrt[3]{\tan a - x}\right)}^{2}\right)} \]
    7. Step-by-step derivation
      1. Simplified99.7%

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

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

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

      Alternative 5: 99.7% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ x - \left(\tan a + \frac{\tan y + \tan z}{\tan y \cdot \tan z + -1}\right) \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (- x (+ (tan a) (/ (+ (tan y) (tan z)) (+ (* (tan y) (tan z)) -1.0)))))
      double code(double x, double y, double z, double a) {
      	return x - (tan(a) + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + -1.0)));
      }
      
      real(8) function code(x, y, z, a)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          code = x - (tan(a) + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + (-1.0d0))))
      end function
      
      public static double code(double x, double y, double z, double a) {
      	return x - (Math.tan(a) + ((Math.tan(y) + Math.tan(z)) / ((Math.tan(y) * Math.tan(z)) + -1.0)));
      }
      
      def code(x, y, z, a):
      	return x - (math.tan(a) + ((math.tan(y) + math.tan(z)) / ((math.tan(y) * math.tan(z)) + -1.0)))
      
      function code(x, y, z, a)
      	return Float64(x - Float64(tan(a) + Float64(Float64(tan(y) + tan(z)) / Float64(Float64(tan(y) * tan(z)) + -1.0))))
      end
      
      function tmp = code(x, y, z, a)
      	tmp = x - (tan(a) + ((tan(y) + tan(z)) / ((tan(y) * tan(z)) + -1.0)));
      end
      
      code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      x - \left(\tan a + \frac{\tan y + \tan z}{\tan y \cdot \tan z + -1}\right)
      \end{array}
      
      Derivation
      1. Initial program 81.1%

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

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x} \]
        2. sub-neg81.1%

          \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + \left(-\tan a\right)\right)} + x \]
        3. associate-+l+81.1%

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, \left(-\tan a\right) + x\right)} \]
        7. neg-mul-199.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, \mathsf{fma}\left(-1, \tan a, x\right)\right)} \]
      5. Step-by-step derivation
        1. fma-undefine99.6%

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

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

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

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

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

          \[\leadsto \left(\color{blue}{\frac{\left(\tan y + \tan z\right) \cdot 1}{1 - \tan y \cdot \tan z}} - \tan a\right) + x \]
        7. *-rgt-identity99.6%

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

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

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

      Alternative 6: 69.1% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01 \lor \neg \left(\tan a \leq 10^{-12}\right):\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (or (<= (tan a) -0.01) (not (<= (tan a) 1e-12)))
         (+ x (- (tan y) (tan a)))
         (+ x (- (tan (+ y z)) a))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((tan(a) <= -0.01) || !(tan(a) <= 1e-12)) {
      		tmp = x + (tan(y) - tan(a));
      	} else {
      		tmp = x + (tan((y + z)) - a);
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          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.01d0)) .or. (.not. (tan(a) <= 1d-12))) then
              tmp = x + (tan(y) - tan(a))
          else
              tmp = x + (tan((y + z)) - a)
          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.01) || !(Math.tan(a) <= 1e-12)) {
      		tmp = x + (Math.tan(y) - Math.tan(a));
      	} else {
      		tmp = x + (Math.tan((y + z)) - a);
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if (math.tan(a) <= -0.01) or not (math.tan(a) <= 1e-12):
      		tmp = x + (math.tan(y) - math.tan(a))
      	else:
      		tmp = x + (math.tan((y + z)) - a)
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if ((tan(a) <= -0.01) || !(tan(a) <= 1e-12))
      		tmp = Float64(x + Float64(tan(y) - tan(a)));
      	else
      		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if ((tan(a) <= -0.01) || ~((tan(a) <= 1e-12)))
      		tmp = x + (tan(y) - tan(a));
      	else
      		tmp = x + (tan((y + z)) - a);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 1e-12]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\tan a \leq -0.01 \lor \neg \left(\tan a \leq 10^{-12}\right):\\
      \;\;\;\;x + \left(\tan y - \tan a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (tan.f64 a) < -0.0100000000000000002 or 9.9999999999999998e-13 < (tan.f64 a)

        1. Initial program 80.4%

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

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

        if -0.0100000000000000002 < (tan.f64 a) < 9.9999999999999998e-13

        1. Initial program 81.9%

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

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

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

      Alternative 7: 49.5% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;e^{\log x}\\ \mathbf{elif}\;\tan a \leq 10^{-12}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (tan a) -0.01)
         (exp (log x))
         (if (<= (tan a) 1e-12) (+ x (- (tan (+ y z)) a)) (expm1 (log1p x)))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (tan(a) <= -0.01) {
      		tmp = exp(log(x));
      	} else if (tan(a) <= 1e-12) {
      		tmp = x + (tan((y + z)) - a);
      	} else {
      		tmp = expm1(log1p(x));
      	}
      	return tmp;
      }
      
      public static double code(double x, double y, double z, double a) {
      	double tmp;
      	if (Math.tan(a) <= -0.01) {
      		tmp = Math.exp(Math.log(x));
      	} else if (Math.tan(a) <= 1e-12) {
      		tmp = x + (Math.tan((y + z)) - a);
      	} else {
      		tmp = Math.expm1(Math.log1p(x));
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if math.tan(a) <= -0.01:
      		tmp = math.exp(math.log(x))
      	elif math.tan(a) <= 1e-12:
      		tmp = x + (math.tan((y + z)) - a)
      	else:
      		tmp = math.expm1(math.log1p(x))
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (tan(a) <= -0.01)
      		tmp = exp(log(x));
      	elseif (tan(a) <= 1e-12)
      		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
      	else
      		tmp = expm1(log1p(x));
      	end
      	return tmp
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-12], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\tan a \leq -0.01:\\
      \;\;\;\;e^{\log x}\\
      
      \mathbf{elif}\;\tan a \leq 10^{-12}:\\
      \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (tan.f64 a) < -0.0100000000000000002

        1. Initial program 83.6%

          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. add-cbrt-cube83.1%

            \[\leadsto \color{blue}{\sqrt[3]{\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}} \]
          2. pow1/379.7%

            \[\leadsto \color{blue}{{\left(\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right)}^{0.3333333333333333}} \]
          3. pow379.8%

            \[\leadsto {\color{blue}{\left({\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}^{3}\right)}}^{0.3333333333333333} \]
          4. +-commutative79.8%

            \[\leadsto {\left({\color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}^{3}\right)}^{0.3333333333333333} \]
          5. associate-+l-79.8%

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

          \[\leadsto \color{blue}{{\left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}^{0.3333333333333333}} \]
        5. Step-by-step derivation
          1. add-exp-log79.9%

            \[\leadsto {\color{blue}{\left(e^{\log \left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}\right)}}^{0.3333333333333333} \]
          2. log-pow79.6%

            \[\leadsto {\left(e^{\color{blue}{3 \cdot \log \left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}}\right)}^{0.3333333333333333} \]
          3. associate--r-79.6%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}\right)}^{0.3333333333333333} \]
          4. pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{{\tan \left(y + z\right)}^{1}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          5. metadata-eval79.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left({\tan \left(y + z\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          6. sqrt-pow165.5%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{\sqrt{{\tan \left(y + z\right)}^{2}}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          7. +-commutative65.5%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(x + \left(\sqrt{{\tan \left(y + z\right)}^{2}} - \tan a\right)\right)}}\right)}^{0.3333333333333333} \]
          8. sqrt-pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{{\tan \left(y + z\right)}^{\left(\frac{2}{2}\right)}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          9. metadata-eval79.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left({\tan \left(y + z\right)}^{\color{blue}{1}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          10. pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
        6. Applied egg-rr79.6%

          \[\leadsto {\color{blue}{\left(e^{3 \cdot \log \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}\right)}}^{0.3333333333333333} \]
        7. Taylor expanded in x around inf 23.2%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
        8. Step-by-step derivation
          1. mul-1-neg23.2%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
          2. log-rec23.2%

            \[\leadsto {\left(e^{3 \cdot \left(-\color{blue}{\left(-\log x\right)}\right)}\right)}^{0.3333333333333333} \]
          3. remove-double-neg23.2%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        9. Simplified23.2%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        10. Step-by-step derivation
          1. *-commutative23.2%

            \[\leadsto {\left(e^{\color{blue}{\log x \cdot 3}}\right)}^{0.3333333333333333} \]
          2. pow-to-exp23.2%

            \[\leadsto {\color{blue}{\left({x}^{3}\right)}}^{0.3333333333333333} \]
          3. pow323.2%

            \[\leadsto {\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}}^{0.3333333333333333} \]
          4. pow1/323.2%

            \[\leadsto \color{blue}{\sqrt[3]{\left(x \cdot x\right) \cdot x}} \]
          5. add-cbrt-cube23.2%

            \[\leadsto \color{blue}{x} \]
          6. add-exp-log23.2%

            \[\leadsto \color{blue}{e^{\log x}} \]
        11. Applied egg-rr23.2%

          \[\leadsto \color{blue}{e^{\log x}} \]

        if -0.0100000000000000002 < (tan.f64 a) < 9.9999999999999998e-13

        1. Initial program 81.9%

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

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

        if 9.9999999999999998e-13 < (tan.f64 a)

        1. Initial program 76.9%

          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. add-cbrt-cube76.7%

            \[\leadsto \color{blue}{\sqrt[3]{\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}} \]
          2. pow1/358.9%

            \[\leadsto \color{blue}{{\left(\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right)}^{0.3333333333333333}} \]
          3. pow358.9%

            \[\leadsto {\color{blue}{\left({\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}^{3}\right)}}^{0.3333333333333333} \]
          4. +-commutative58.9%

            \[\leadsto {\left({\color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}^{3}\right)}^{0.3333333333333333} \]
          5. associate-+l-58.9%

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

          \[\leadsto \color{blue}{{\left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}^{0.3333333333333333}} \]
        5. Step-by-step derivation
          1. add-exp-log59.1%

            \[\leadsto {\color{blue}{\left(e^{\log \left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}\right)}}^{0.3333333333333333} \]
          2. log-pow58.9%

            \[\leadsto {\left(e^{\color{blue}{3 \cdot \log \left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}}\right)}^{0.3333333333333333} \]
          3. associate--r-58.8%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}\right)}^{0.3333333333333333} \]
          4. pow158.8%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{{\tan \left(y + z\right)}^{1}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          5. metadata-eval58.8%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left({\tan \left(y + z\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          6. sqrt-pow141.7%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{\sqrt{{\tan \left(y + z\right)}^{2}}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          7. +-commutative41.7%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(x + \left(\sqrt{{\tan \left(y + z\right)}^{2}} - \tan a\right)\right)}}\right)}^{0.3333333333333333} \]
          8. sqrt-pow158.8%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{{\tan \left(y + z\right)}^{\left(\frac{2}{2}\right)}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          9. metadata-eval58.8%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left({\tan \left(y + z\right)}^{\color{blue}{1}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          10. pow158.8%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
        6. Applied egg-rr58.8%

          \[\leadsto {\color{blue}{\left(e^{3 \cdot \log \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}\right)}}^{0.3333333333333333} \]
        7. Taylor expanded in x around inf 18.4%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
        8. Step-by-step derivation
          1. mul-1-neg18.4%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
          2. log-rec18.4%

            \[\leadsto {\left(e^{3 \cdot \left(-\color{blue}{\left(-\log x\right)}\right)}\right)}^{0.3333333333333333} \]
          3. remove-double-neg18.4%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        9. Simplified18.4%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        10. Step-by-step derivation
          1. *-commutative18.4%

            \[\leadsto {\left(e^{\color{blue}{\log x \cdot 3}}\right)}^{0.3333333333333333} \]
          2. pow-to-exp18.4%

            \[\leadsto {\color{blue}{\left({x}^{3}\right)}}^{0.3333333333333333} \]
          3. pow318.4%

            \[\leadsto {\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}}^{0.3333333333333333} \]
          4. pow1/318.4%

            \[\leadsto \color{blue}{\sqrt[3]{\left(x \cdot x\right) \cdot x}} \]
          5. expm1-log1p-u18.4%

            \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt[3]{\left(x \cdot x\right) \cdot x}\right)\right)} \]
          6. add-cbrt-cube18.4%

            \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{x}\right)\right) \]
          7. expm1-undefine18.4%

            \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x\right)} - 1} \]
        11. Applied egg-rr18.4%

          \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x\right)} - 1} \]
        12. Step-by-step derivation
          1. expm1-define18.4%

            \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \]
        13. Simplified18.4%

          \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \]
      3. Recombined 3 regimes into one program.
      4. Add Preprocessing

      Alternative 8: 78.7% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \log \left(e^{\tan \left(y + z\right) + \left(x - \tan a\right)}\right) \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (log (exp (+ (tan (+ y z)) (- x (tan a))))))
      double code(double x, double y, double z, double a) {
      	return log(exp((tan((y + z)) + (x - tan(a)))));
      }
      
      real(8) function code(x, y, z, a)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          code = log(exp((tan((y + z)) + (x - tan(a)))))
      end function
      
      public static double code(double x, double y, double z, double a) {
      	return Math.log(Math.exp((Math.tan((y + z)) + (x - Math.tan(a)))));
      }
      
      def code(x, y, z, a):
      	return math.log(math.exp((math.tan((y + z)) + (x - math.tan(a)))))
      
      function code(x, y, z, a)
      	return log(exp(Float64(tan(Float64(y + z)) + Float64(x - tan(a)))))
      end
      
      function tmp = code(x, y, z, a)
      	tmp = log(exp((tan((y + z)) + (x - tan(a)))));
      end
      
      code[x_, y_, z_, a_] := N[Log[N[Exp[N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \log \left(e^{\tan \left(y + z\right) + \left(x - \tan a\right)}\right)
      \end{array}
      
      Derivation
      1. Initial program 81.1%

        \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. add-log-exp81.1%

          \[\leadsto \color{blue}{\log \left(e^{x + \left(\tan \left(y + z\right) - \tan a\right)}\right)} \]
        2. +-commutative81.1%

          \[\leadsto \log \left(e^{\color{blue}{\left(\tan \left(y + z\right) - \tan a\right) + x}}\right) \]
        3. associate-+l-81.1%

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

        \[\leadsto \color{blue}{\log \left(e^{\tan \left(y + z\right) - \left(\tan a - x\right)}\right)} \]
      5. Final simplification81.1%

        \[\leadsto \log \left(e^{\tan \left(y + z\right) + \left(x - \tan a\right)}\right) \]
      6. Add Preprocessing

      Alternative 9: 49.5% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;e^{\log x}\\ \mathbf{elif}\;\tan a \leq 10^{-12}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (tan a) -0.01)
         (exp (log x))
         (if (<= (tan a) 1e-12) (+ x (- (tan (+ y z)) a)) x)))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (tan(a) <= -0.01) {
      		tmp = exp(log(x));
      	} else if (tan(a) <= 1e-12) {
      		tmp = x + (tan((y + z)) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          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.01d0)) then
              tmp = exp(log(x))
          else if (tan(a) <= 1d-12) then
              tmp = x + (tan((y + z)) - a)
          else
              tmp = 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.01) {
      		tmp = Math.exp(Math.log(x));
      	} else if (Math.tan(a) <= 1e-12) {
      		tmp = x + (Math.tan((y + z)) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if math.tan(a) <= -0.01:
      		tmp = math.exp(math.log(x))
      	elif math.tan(a) <= 1e-12:
      		tmp = x + (math.tan((y + z)) - a)
      	else:
      		tmp = x
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (tan(a) <= -0.01)
      		tmp = exp(log(x));
      	elseif (tan(a) <= 1e-12)
      		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
      	else
      		tmp = x;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if (tan(a) <= -0.01)
      		tmp = exp(log(x));
      	elseif (tan(a) <= 1e-12)
      		tmp = x + (tan((y + z)) - a);
      	else
      		tmp = x;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-12], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\tan a \leq -0.01:\\
      \;\;\;\;e^{\log x}\\
      
      \mathbf{elif}\;\tan a \leq 10^{-12}:\\
      \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (tan.f64 a) < -0.0100000000000000002

        1. Initial program 83.6%

          \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. add-cbrt-cube83.1%

            \[\leadsto \color{blue}{\sqrt[3]{\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}} \]
          2. pow1/379.7%

            \[\leadsto \color{blue}{{\left(\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right)}^{0.3333333333333333}} \]
          3. pow379.8%

            \[\leadsto {\color{blue}{\left({\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}^{3}\right)}}^{0.3333333333333333} \]
          4. +-commutative79.8%

            \[\leadsto {\left({\color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}^{3}\right)}^{0.3333333333333333} \]
          5. associate-+l-79.8%

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

          \[\leadsto \color{blue}{{\left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}^{0.3333333333333333}} \]
        5. Step-by-step derivation
          1. add-exp-log79.9%

            \[\leadsto {\color{blue}{\left(e^{\log \left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}\right)}}^{0.3333333333333333} \]
          2. log-pow79.6%

            \[\leadsto {\left(e^{\color{blue}{3 \cdot \log \left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}}\right)}^{0.3333333333333333} \]
          3. associate--r-79.6%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(\left(\tan \left(y + z\right) - \tan a\right) + x\right)}}\right)}^{0.3333333333333333} \]
          4. pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{{\tan \left(y + z\right)}^{1}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          5. metadata-eval79.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left({\tan \left(y + z\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          6. sqrt-pow165.5%

            \[\leadsto {\left(e^{3 \cdot \log \left(\left(\color{blue}{\sqrt{{\tan \left(y + z\right)}^{2}}} - \tan a\right) + x\right)}\right)}^{0.3333333333333333} \]
          7. +-commutative65.5%

            \[\leadsto {\left(e^{3 \cdot \log \color{blue}{\left(x + \left(\sqrt{{\tan \left(y + z\right)}^{2}} - \tan a\right)\right)}}\right)}^{0.3333333333333333} \]
          8. sqrt-pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{{\tan \left(y + z\right)}^{\left(\frac{2}{2}\right)}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          9. metadata-eval79.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left({\tan \left(y + z\right)}^{\color{blue}{1}} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
          10. pow179.6%

            \[\leadsto {\left(e^{3 \cdot \log \left(x + \left(\color{blue}{\tan \left(y + z\right)} - \tan a\right)\right)}\right)}^{0.3333333333333333} \]
        6. Applied egg-rr79.6%

          \[\leadsto {\color{blue}{\left(e^{3 \cdot \log \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}\right)}}^{0.3333333333333333} \]
        7. Taylor expanded in x around inf 23.2%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
        8. Step-by-step derivation
          1. mul-1-neg23.2%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}}\right)}^{0.3333333333333333} \]
          2. log-rec23.2%

            \[\leadsto {\left(e^{3 \cdot \left(-\color{blue}{\left(-\log x\right)}\right)}\right)}^{0.3333333333333333} \]
          3. remove-double-neg23.2%

            \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        9. Simplified23.2%

          \[\leadsto {\left(e^{3 \cdot \color{blue}{\log x}}\right)}^{0.3333333333333333} \]
        10. Step-by-step derivation
          1. *-commutative23.2%

            \[\leadsto {\left(e^{\color{blue}{\log x \cdot 3}}\right)}^{0.3333333333333333} \]
          2. pow-to-exp23.2%

            \[\leadsto {\color{blue}{\left({x}^{3}\right)}}^{0.3333333333333333} \]
          3. pow323.2%

            \[\leadsto {\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}}^{0.3333333333333333} \]
          4. pow1/323.2%

            \[\leadsto \color{blue}{\sqrt[3]{\left(x \cdot x\right) \cdot x}} \]
          5. add-cbrt-cube23.2%

            \[\leadsto \color{blue}{x} \]
          6. add-exp-log23.2%

            \[\leadsto \color{blue}{e^{\log x}} \]
        11. Applied egg-rr23.2%

          \[\leadsto \color{blue}{e^{\log x}} \]

        if -0.0100000000000000002 < (tan.f64 a) < 9.9999999999999998e-13

        1. Initial program 81.9%

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

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

        if 9.9999999999999998e-13 < (tan.f64 a)

        1. Initial program 76.9%

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

          \[\leadsto \color{blue}{x} \]
      3. Recombined 3 regimes into one program.
      4. Add Preprocessing

      Alternative 10: 49.5% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.01:\\ \;\;\;\;x\\ \mathbf{elif}\;\tan a \leq 10^{-12}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (tan a) -0.01) x (if (<= (tan a) 1e-12) (+ x (- (tan (+ y z)) a)) x)))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (tan(a) <= -0.01) {
      		tmp = x;
      	} else if (tan(a) <= 1e-12) {
      		tmp = x + (tan((y + z)) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          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.01d0)) then
              tmp = x
          else if (tan(a) <= 1d-12) then
              tmp = x + (tan((y + z)) - a)
          else
              tmp = 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.01) {
      		tmp = x;
      	} else if (Math.tan(a) <= 1e-12) {
      		tmp = x + (Math.tan((y + z)) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if math.tan(a) <= -0.01:
      		tmp = x
      	elif math.tan(a) <= 1e-12:
      		tmp = x + (math.tan((y + z)) - a)
      	else:
      		tmp = x
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (tan(a) <= -0.01)
      		tmp = x;
      	elseif (tan(a) <= 1e-12)
      		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
      	else
      		tmp = x;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if (tan(a) <= -0.01)
      		tmp = x;
      	elseif (tan(a) <= 1e-12)
      		tmp = x + (tan((y + z)) - a);
      	else
      		tmp = x;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.01], x, If[LessEqual[N[Tan[a], $MachinePrecision], 1e-12], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\tan a \leq -0.01:\\
      \;\;\;\;x\\
      
      \mathbf{elif}\;\tan a \leq 10^{-12}:\\
      \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (tan.f64 a) < -0.0100000000000000002 or 9.9999999999999998e-13 < (tan.f64 a)

        1. Initial program 80.4%

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

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

        if -0.0100000000000000002 < (tan.f64 a) < 9.9999999999999998e-13

        1. Initial program 81.9%

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

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

      Alternative 11: 39.7% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -1 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\ \;\;\;\;x + \left(\tan y - a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (tan a) -1e-5) x (if (<= (tan a) 5e-51) (+ x (- (tan y) a)) x)))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (tan(a) <= -1e-5) {
      		tmp = x;
      	} else if (tan(a) <= 5e-51) {
      		tmp = x + (tan(y) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          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) <= (-1d-5)) then
              tmp = x
          else if (tan(a) <= 5d-51) then
              tmp = x + (tan(y) - a)
          else
              tmp = 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) <= -1e-5) {
      		tmp = x;
      	} else if (Math.tan(a) <= 5e-51) {
      		tmp = x + (Math.tan(y) - a);
      	} else {
      		tmp = x;
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if math.tan(a) <= -1e-5:
      		tmp = x
      	elif math.tan(a) <= 5e-51:
      		tmp = x + (math.tan(y) - a)
      	else:
      		tmp = x
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (tan(a) <= -1e-5)
      		tmp = x;
      	elseif (tan(a) <= 5e-51)
      		tmp = Float64(x + Float64(tan(y) - a));
      	else
      		tmp = x;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if (tan(a) <= -1e-5)
      		tmp = x;
      	elseif (tan(a) <= 5e-51)
      		tmp = x + (tan(y) - a);
      	else
      		tmp = x;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -1e-5], x, If[LessEqual[N[Tan[a], $MachinePrecision], 5e-51], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\tan a \leq -1 \cdot 10^{-5}:\\
      \;\;\;\;x\\
      
      \mathbf{elif}\;\tan a \leq 5 \cdot 10^{-51}:\\
      \;\;\;\;x + \left(\tan y - a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (tan.f64 a) < -1.00000000000000008e-5 or 5.00000000000000004e-51 < (tan.f64 a)

        1. Initial program 80.9%

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

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

        if -1.00000000000000008e-5 < (tan.f64 a) < 5.00000000000000004e-51

        1. Initial program 81.2%

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

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

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

      Alternative 12: 69.4% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 1.55 \cdot 10^{-7}:\\ \;\;\;\;\left(\tan y + x\right) - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= z 1.55e-7) (- (+ (tan y) x) (tan a)) (+ x (- (tan z) (tan a)))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (z <= 1.55e-7) {
      		tmp = (tan(y) + x) - tan(a);
      	} else {
      		tmp = x + (tan(z) - tan(a));
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          real(8) :: tmp
          if (z <= 1.55d-7) then
              tmp = (tan(y) + x) - tan(a)
          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 (z <= 1.55e-7) {
      		tmp = (Math.tan(y) + x) - Math.tan(a);
      	} else {
      		tmp = x + (Math.tan(z) - Math.tan(a));
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if z <= 1.55e-7:
      		tmp = (math.tan(y) + x) - math.tan(a)
      	else:
      		tmp = x + (math.tan(z) - math.tan(a))
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (z <= 1.55e-7)
      		tmp = Float64(Float64(tan(y) + x) - tan(a));
      	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 (z <= 1.55e-7)
      		tmp = (tan(y) + x) - tan(a);
      	else
      		tmp = x + (tan(z) - tan(a));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[z, 1.55e-7], N[(N[(N[Tan[y], $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq 1.55 \cdot 10^{-7}:\\
      \;\;\;\;\left(\tan y + x\right) - \tan a\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\tan z - \tan a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < 1.55e-7

        1. Initial program 87.9%

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

          \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
        4. Taylor expanded in y around inf 74.9%

          \[\leadsto x + \left(\tan \color{blue}{y} - \frac{\sin a}{\cos a}\right) \]
        5. Step-by-step derivation
          1. tan-quot74.9%

            \[\leadsto x + \left(\tan y - \color{blue}{\tan a}\right) \]
          2. associate-+r-74.9%

            \[\leadsto \color{blue}{\left(x + \tan y\right) - \tan a} \]
        6. Applied egg-rr74.9%

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

        if 1.55e-7 < z

        1. Initial program 60.0%

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

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

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

      Alternative 13: 69.4% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 1.8 \cdot 10^{-7}:\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= z 1.8e-7) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if (z <= 1.8e-7) {
      		tmp = x + (tan(y) - tan(a));
      	} else {
      		tmp = x + (tan(z) - tan(a));
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          real(8) :: tmp
          if (z <= 1.8d-7) then
              tmp = x + (tan(y) - tan(a))
          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 (z <= 1.8e-7) {
      		tmp = x + (Math.tan(y) - Math.tan(a));
      	} else {
      		tmp = x + (Math.tan(z) - Math.tan(a));
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if z <= 1.8e-7:
      		tmp = x + (math.tan(y) - math.tan(a))
      	else:
      		tmp = x + (math.tan(z) - math.tan(a))
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (z <= 1.8e-7)
      		tmp = Float64(x + Float64(tan(y) - tan(a)));
      	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 (z <= 1.8e-7)
      		tmp = x + (tan(y) - tan(a));
      	else
      		tmp = x + (tan(z) - tan(a));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[z, 1.8e-7], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq 1.8 \cdot 10^{-7}:\\
      \;\;\;\;x + \left(\tan y - \tan a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x + \left(\tan z - \tan a\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < 1.79999999999999997e-7

        1. Initial program 87.9%

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

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

        if 1.79999999999999997e-7 < z

        1. Initial program 60.0%

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

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

      Alternative 14: 78.8% 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));
      }
      
      real(8) function code(x, y, z, a)
          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 81.1%

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

      Alternative 15: 33.1% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y + z \leq -5000000000000:\\ \;\;\;\;x + \left(\tan y - a\right)\\ \mathbf{elif}\;y + z \leq 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \left(a - \tan z\right)\\ \end{array} \end{array} \]
      (FPCore (x y z a)
       :precision binary64
       (if (<= (+ y z) -5000000000000.0)
         (+ x (- (tan y) a))
         (if (<= (+ y z) 1e-16) x (- x (- a (tan z))))))
      double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -5000000000000.0) {
      		tmp = x + (tan(y) - a);
      	} else if ((y + z) <= 1e-16) {
      		tmp = x;
      	} else {
      		tmp = x - (a - tan(z));
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, a)
          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) <= (-5000000000000.0d0)) then
              tmp = x + (tan(y) - a)
          else if ((y + z) <= 1d-16) then
              tmp = x
          else
              tmp = x - (a - tan(z))
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double a) {
      	double tmp;
      	if ((y + z) <= -5000000000000.0) {
      		tmp = x + (Math.tan(y) - a);
      	} else if ((y + z) <= 1e-16) {
      		tmp = x;
      	} else {
      		tmp = x - (a - Math.tan(z));
      	}
      	return tmp;
      }
      
      def code(x, y, z, a):
      	tmp = 0
      	if (y + z) <= -5000000000000.0:
      		tmp = x + (math.tan(y) - a)
      	elif (y + z) <= 1e-16:
      		tmp = x
      	else:
      		tmp = x - (a - math.tan(z))
      	return tmp
      
      function code(x, y, z, a)
      	tmp = 0.0
      	if (Float64(y + z) <= -5000000000000.0)
      		tmp = Float64(x + Float64(tan(y) - a));
      	elseif (Float64(y + z) <= 1e-16)
      		tmp = x;
      	else
      		tmp = Float64(x - Float64(a - tan(z)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, a)
      	tmp = 0.0;
      	if ((y + z) <= -5000000000000.0)
      		tmp = x + (tan(y) - a);
      	elseif ((y + z) <= 1e-16)
      		tmp = x;
      	else
      		tmp = x - (a - tan(z));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5000000000000.0], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 1e-16], x, N[(x - N[(a - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y + z \leq -5000000000000:\\
      \;\;\;\;x + \left(\tan y - a\right)\\
      
      \mathbf{elif}\;y + z \leq 10^{-16}:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;x - \left(a - \tan z\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (+.f64 y z) < -5e12

        1. Initial program 72.4%

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

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

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

        if -5e12 < (+.f64 y z) < 9.9999999999999998e-17

        1. Initial program 99.9%

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

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

        if 9.9999999999999998e-17 < (+.f64 y z)

        1. Initial program 76.8%

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

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

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

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

      Alternative 16: 31.2% accurate, 207.0× speedup?

      \[\begin{array}{l} \\ x \end{array} \]
      (FPCore (x y z a) :precision binary64 x)
      double code(double x, double y, double z, double a) {
      	return x;
      }
      
      real(8) function code(x, y, z, a)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: a
          code = x
      end function
      
      public static double code(double x, double y, double z, double a) {
      	return x;
      }
      
      def code(x, y, z, a):
      	return x
      
      function code(x, y, z, a)
      	return x
      end
      
      function tmp = code(x, y, z, a)
      	tmp = x;
      end
      
      code[x_, y_, z_, a_] := x
      
      \begin{array}{l}
      
      \\
      x
      \end{array}
      
      Derivation
      1. Initial program 81.1%

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

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

      Reproduce

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