tan-example (used to crash)

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

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

Initial Program: 79.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
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.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ x - \left(\tan a - \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (- x (- (tan a) (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
	return x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))));
}
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)) / (1.0d0 - (tan(y) * tan(z)))))
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)) / (1.0 - (Math.tan(y) * Math.tan(z)))));
}
def code(x, y, z, a):
	return x - (math.tan(a) - ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))))
function code(x, y, z, a)
	return Float64(x - Float64(tan(a) - Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z))))))
end
function tmp = code(x, y, z, a)
	tmp = x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))));
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[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Step-by-step derivation
    1. tan-sum99.7%

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

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

    \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  4. Step-by-step derivation
    1. associate-*r/99.7%

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

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

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

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

Alternative 2: 88.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\

\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;\left(x - a\right) + \left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}\\

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


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

    1. Initial program 86.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-sum99.7%

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

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

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

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

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

    if -5.00000000000000018e-11 < (tan.f64 a) < 9.99999999999999908e-22

    1. Initial program 80.5%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-80.5%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\left(x + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg80.5%

        \[\leadsto \tan \left(y + z\right) + \left(x + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg80.5%

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

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

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

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

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

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

    if 9.99999999999999908e-22 < (tan.f64 a)

    1. Initial program 83.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-quot83.5%

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

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

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

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

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

Alternative 3: 88.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\

\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\

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


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

    1. Initial program 86.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-sum99.7%

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

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

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

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

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

    if -5.00000000000000018e-11 < (tan.f64 a) < 9.99999999999999908e-22

    1. Initial program 80.5%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-80.5%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\left(x + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg80.5%

        \[\leadsto \tan \left(y + z\right) + \left(x + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg80.5%

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

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

        \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan 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}} - \tan a\right) \]
    8. Applied egg-rr99.8%

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

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

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

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

    if 9.99999999999999908e-22 < (tan.f64 a)

    1. Initial program 83.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-quot83.5%

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

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

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

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

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

Alternative 4: 88.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.001:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\

\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\

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


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

    1. Initial program 85.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-sum99.7%

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

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

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

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

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

    if -1e-3 < (tan.f64 a) < 9.99999999999999908e-22

    1. Initial program 80.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-80.8%

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

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

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

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

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

        \[\leadsto \tan \left(y + z\right) + \left(x + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg80.8%

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

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

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

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

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

        \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan 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}} - \tan a\right) \]
    10. Applied egg-rr99.8%

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

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

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

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

    if 9.99999999999999908e-22 < (tan.f64 a)

    1. Initial program 83.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-quot83.5%

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

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

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

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

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

Alternative 5: 88.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan y + \tan z\\ \mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8.5 \cdot 10^{-50}\right):\\ \;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\mathsf{fma}\left(\tan y, -\tan z, 1\right)} + \left(x - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (+ (tan y) (tan z))))
   (if (or (<= a -5.8e-11) (not (<= a 8.5e-50)))
     (+
      x
      (-
       (/ t_0 (- 1.0 (/ (tan y) (+ (* z -0.3333333333333333) (/ 1.0 z)))))
       (tan a)))
     (+ (/ t_0 (fma (tan y) (- (tan z)) 1.0)) (- x a)))))
double code(double x, double y, double z, double a) {
	double t_0 = tan(y) + tan(z);
	double tmp;
	if ((a <= -5.8e-11) || !(a <= 8.5e-50)) {
		tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a));
	} else {
		tmp = (t_0 / fma(tan(y), -tan(z), 1.0)) + (x - a);
	}
	return tmp;
}
function code(x, y, z, a)
	t_0 = Float64(tan(y) + tan(z))
	tmp = 0.0
	if ((a <= -5.8e-11) || !(a <= 8.5e-50))
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) / Float64(Float64(z * -0.3333333333333333) + Float64(1.0 / z))))) - tan(a)));
	else
		tmp = Float64(Float64(t_0 / fma(tan(y), Float64(-tan(z)), 1.0)) + Float64(x - a));
	end
	return tmp
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -5.8e-11], N[Not[LessEqual[a, 8.5e-50]], $MachinePrecision]], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] / N[(N[(z * -0.3333333333333333), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(N[Tan[y], $MachinePrecision] * (-N[Tan[z], $MachinePrecision]) + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8.5 \cdot 10^{-50}\right):\\
\;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -5.8e-11 or 8.50000000000000012e-50 < a

    1. Initial program 85.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-sum99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8e-11 < a < 8.50000000000000012e-50

    1. Initial program 79.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-79.7%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\left(x + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8.5 \cdot 10^{-50}\right):\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan y + \tan z}{\mathsf{fma}\left(\tan y, -\tan z, 1\right)} + \left(x - a\right)\\ \end{array} \]

Alternative 6: 88.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan y + \tan z\\ \mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8 \cdot 10^{-50}\right):\\ \;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - a\right) + t_0 \cdot \frac{1}{1 - \tan y \cdot \tan z}\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (+ (tan y) (tan z))))
   (if (or (<= a -5.8e-11) (not (<= a 8e-50)))
     (+
      x
      (-
       (/ t_0 (- 1.0 (/ (tan y) (+ (* z -0.3333333333333333) (/ 1.0 z)))))
       (tan a)))
     (+ (- x a) (* t_0 (/ 1.0 (- 1.0 (* (tan y) (tan z)))))))))
double code(double x, double y, double z, double a) {
	double t_0 = tan(y) + tan(z);
	double tmp;
	if ((a <= -5.8e-11) || !(a <= 8e-50)) {
		tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a));
	} else {
		tmp = (x - a) + (t_0 * (1.0 / (1.0 - (tan(y) * 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) :: t_0
    real(8) :: tmp
    t_0 = tan(y) + tan(z)
    if ((a <= (-5.8d-11)) .or. (.not. (a <= 8d-50))) then
        tmp = x + ((t_0 / (1.0d0 - (tan(y) / ((z * (-0.3333333333333333d0)) + (1.0d0 / z))))) - tan(a))
    else
        tmp = (x - a) + (t_0 * (1.0d0 / (1.0d0 - (tan(y) * tan(z)))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double t_0 = Math.tan(y) + Math.tan(z);
	double tmp;
	if ((a <= -5.8e-11) || !(a <= 8e-50)) {
		tmp = x + ((t_0 / (1.0 - (Math.tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - Math.tan(a));
	} else {
		tmp = (x - a) + (t_0 * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z)))));
	}
	return tmp;
}
def code(x, y, z, a):
	t_0 = math.tan(y) + math.tan(z)
	tmp = 0
	if (a <= -5.8e-11) or not (a <= 8e-50):
		tmp = x + ((t_0 / (1.0 - (math.tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - math.tan(a))
	else:
		tmp = (x - a) + (t_0 * (1.0 / (1.0 - (math.tan(y) * math.tan(z)))))
	return tmp
function code(x, y, z, a)
	t_0 = Float64(tan(y) + tan(z))
	tmp = 0.0
	if ((a <= -5.8e-11) || !(a <= 8e-50))
		tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) / Float64(Float64(z * -0.3333333333333333) + Float64(1.0 / z))))) - tan(a)));
	else
		tmp = Float64(Float64(x - a) + Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	t_0 = tan(y) + tan(z);
	tmp = 0.0;
	if ((a <= -5.8e-11) || ~((a <= 8e-50)))
		tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a));
	else
		tmp = (x - a) + (t_0 * (1.0 / (1.0 - (tan(y) * tan(z)))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -5.8e-11], N[Not[LessEqual[a, 8e-50]], $MachinePrecision]], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] / N[(N[(z * -0.3333333333333333), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - a), $MachinePrecision] + N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8 \cdot 10^{-50}\right):\\
\;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -5.8e-11 or 8.00000000000000006e-50 < a

    1. Initial program 85.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. tan-sum99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8e-11 < a < 8.00000000000000006e-50

    1. Initial program 79.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-79.7%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\left(x + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg79.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8 \cdot 10^{-50}\right):\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - a\right) + \left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}\\ \end{array} \]

Alternative 7: 79.0% accurate, 1.0× speedup?

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

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

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Final simplification82.6%

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

Alternative 8: 50.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.5:\\ \;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= a -1.5)
   (exp (- (log (/ 1.0 x))))
   (if (<= a 1.55) (- x (- a (tan (+ y z)))) x)))
double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.5) {
		tmp = exp(-log((1.0 / x)));
	} else if (a <= 1.55) {
		tmp = x - (a - tan((y + z)));
	} 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 (a <= (-1.5d0)) then
        tmp = exp(-log((1.0d0 / x)))
    else if (a <= 1.55d0) then
        tmp = x - (a - tan((y + z)))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.5) {
		tmp = Math.exp(-Math.log((1.0 / x)));
	} else if (a <= 1.55) {
		tmp = x - (a - Math.tan((y + z)));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if a <= -1.5:
		tmp = math.exp(-math.log((1.0 / x)))
	elif a <= 1.55:
		tmp = x - (a - math.tan((y + z)))
	else:
		tmp = x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (a <= -1.5)
		tmp = exp(Float64(-log(Float64(1.0 / x))));
	elseif (a <= 1.55)
		tmp = Float64(x - Float64(a - tan(Float64(y + z))));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (a <= -1.5)
		tmp = exp(-log((1.0 / x)));
	elseif (a <= 1.55)
		tmp = x - (a - tan((y + z)));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.5], N[Exp[(-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[a, 1.55], N[(x - N[(a - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5:\\
\;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\

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

\mathbf{else}:\\
\;\;\;\;x\\


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

    1. Initial program 83.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-83.2%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\left(x + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg5.5%

        \[\leadsto \tan \left(y + z\right) + \left(x + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg5.5%

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

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

        \[\leadsto \color{blue}{e^{\log \left(\tan \left(y + z\right) + \left(x - a\right)\right)}} \]
    8. Applied rewrite-once5.5%

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

      \[\leadsto e^{\color{blue}{-1 \cdot \log \left(\frac{1}{x}\right)}} \]

    if -1.5 < a < 1.55000000000000004

    1. Initial program 81.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-81.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < a

    1. Initial program 83.8%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.5:\\ \;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 9: 50.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.6:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;\left(x - a\right) + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= a -1.6) x (if (<= a 1.55) (+ (- x a) (tan (+ y z))) x)))
double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.6) {
		tmp = x;
	} else if (a <= 1.55) {
		tmp = (x - a) + tan((y + z));
	} 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 (a <= (-1.6d0)) then
        tmp = x
    else if (a <= 1.55d0) then
        tmp = (x - a) + tan((y + z))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.6) {
		tmp = x;
	} else if (a <= 1.55) {
		tmp = (x - a) + Math.tan((y + z));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if a <= -1.6:
		tmp = x
	elif a <= 1.55:
		tmp = (x - a) + math.tan((y + z))
	else:
		tmp = x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (a <= -1.6)
		tmp = x;
	elseif (a <= 1.55)
		tmp = Float64(Float64(x - a) + tan(Float64(y + z)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (a <= -1.6)
		tmp = x;
	elseif (a <= 1.55)
		tmp = (x - a) + tan((y + z));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.6], x, If[LessEqual[a, 1.55], N[(N[(x - a), $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6:\\
\;\;\;\;x\\

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

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.6000000000000001 or 1.55000000000000004 < a

    1. Initial program 83.5%

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

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

    if -1.6000000000000001 < a < 1.55000000000000004

    1. Initial program 81.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-81.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.6:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;\left(x - a\right) + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 10: 50.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.55:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= a -1.55) x (if (<= a 1.55) (- x (- a (tan (+ y z)))) x)))
double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.55) {
		tmp = x;
	} else if (a <= 1.55) {
		tmp = x - (a - tan((y + z)));
	} 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 (a <= (-1.55d0)) then
        tmp = x
    else if (a <= 1.55d0) then
        tmp = x - (a - tan((y + z)))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -1.55) {
		tmp = x;
	} else if (a <= 1.55) {
		tmp = x - (a - Math.tan((y + z)));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if a <= -1.55:
		tmp = x
	elif a <= 1.55:
		tmp = x - (a - math.tan((y + z)))
	else:
		tmp = x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (a <= -1.55)
		tmp = x;
	elseif (a <= 1.55)
		tmp = Float64(x - Float64(a - tan(Float64(y + z))));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (a <= -1.55)
		tmp = x;
	elseif (a <= 1.55)
		tmp = x - (a - tan((y + z)));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.55], x, If[LessEqual[a, 1.55], N[(x - N[(a - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55:\\
\;\;\;\;x\\

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

\mathbf{else}:\\
\;\;\;\;x\\


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

    1. Initial program 83.5%

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

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

    if -1.55000000000000004 < a < 1.55000000000000004

    1. Initial program 81.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-81.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.55:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.55:\\ \;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 11: 31.4% 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 82.6%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification31.9%

    \[\leadsto x \]

Reproduce

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