tan-example (used to crash)

Percentage Accurate: 79.4% → 99.7%
Time: 39.5s
Alternatives: 9
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 9 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.4% 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(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(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) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
end
code[x_, y_, z_, a_] := 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] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

    \[\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.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) \]
  5. Simplified99.8%

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

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

Alternative 2: 89.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.055 \lor \neg \left(a \leq 1.14 \cdot 10^{-7}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.0550000000000000003 or 1.14000000000000002e-7 < a

    1. Initial program 79.6%

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

    if -0.0550000000000000003 < a < 1.14000000000000002e-7

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 89.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.055 \lor \neg \left(a \leq 1.14 \cdot 10^{-7}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.0550000000000000003 or 1.14000000000000002e-7 < a

    1. Initial program 79.6%

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

    if -0.0550000000000000003 < a < 1.14000000000000002e-7

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 69.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.1 \cdot 10^{-20} \lor \neg \left(a \leq 0.0047\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 (<= a -1.1e-20) (not (<= a 0.0047)))
   (+ x (- (tan y) (tan a)))
   (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -1.1e-20) || !(a <= 0.0047)) {
		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 ((a <= (-1.1d-20)) .or. (.not. (a <= 0.0047d0))) 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 ((a <= -1.1e-20) || !(a <= 0.0047)) {
		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 (a <= -1.1e-20) or not (a <= 0.0047):
		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 ((a <= -1.1e-20) || !(a <= 0.0047))
		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 ((a <= -1.1e-20) || ~((a <= 0.0047)))
		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[a, -1.1e-20], N[Not[LessEqual[a, 0.0047]], $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}\;a \leq -1.1 \cdot 10^{-20} \lor \neg \left(a \leq 0.0047\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 a < -1.09999999999999995e-20 or 0.00470000000000000018 < a

    1. Initial program 77.6%

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

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

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

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      3. expm1-udef54.7%

        \[\leadsto x + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\tan y\right)} - 1\right)} - \tan a\right) \]
    4. Applied egg-rr54.7%

      \[\leadsto x + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\tan y\right)} - 1\right)} - \tan a\right) \]
    5. Step-by-step derivation
      1. expm1-def54.7%

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      2. expm1-log1p62.4%

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

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

    if -1.09999999999999995e-20 < a < 0.00470000000000000018

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.1 \cdot 10^{-20} \lor \neg \left(a \leq 0.0047\right):\\ \;\;\;\;x + \left(\tan y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \]

Alternative 5: 69.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{-11}:\\ \;\;\;\;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 (<= y -2.15e-11) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
	double tmp;
	if (y <= -2.15e-11) {
		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 (y <= (-2.15d-11)) 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 (y <= -2.15e-11) {
		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 y <= -2.15e-11:
		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 (y <= -2.15e-11)
		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 (y <= -2.15e-11)
		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[y, -2.15e-11], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.15000000000000001e-11

    1. Initial program 62.0%

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

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

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

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      3. expm1-udef49.8%

        \[\leadsto x + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\tan y\right)} - 1\right)} - \tan a\right) \]
    4. Applied egg-rr49.8%

      \[\leadsto x + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\tan y\right)} - 1\right)} - \tan a\right) \]
    5. Step-by-step derivation
      1. expm1-def49.8%

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      2. expm1-log1p62.3%

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

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

    if -2.15000000000000001e-11 < y

    1. Initial program 84.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\tan z + \left(x - \tan a\right)} \]
    5. Step-by-step derivation
      1. associate-+r-71.0%

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

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

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

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

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

Alternative 6: 79.4% 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 79.2%

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

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

Alternative 7: 60.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -8.6 \cdot 10^{-14} \lor \neg \left(a \leq 0.0235\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -8.6e-14) (not (<= a 0.0235)))
   (- x (tan a))
   (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -8.6e-14) || !(a <= 0.0235)) {
		tmp = x - 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 ((a <= (-8.6d-14)) .or. (.not. (a <= 0.0235d0))) then
        tmp = x - 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 ((a <= -8.6e-14) || !(a <= 0.0235)) {
		tmp = x - Math.tan(a);
	} else {
		tmp = x + (Math.tan((y + z)) - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -8.6e-14) or not (a <= 0.0235):
		tmp = x - math.tan(a)
	else:
		tmp = x + (math.tan((y + z)) - a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -8.6e-14) || !(a <= 0.0235))
		tmp = Float64(x - 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 ((a <= -8.6e-14) || ~((a <= 0.0235)))
		tmp = x - tan(a);
	else
		tmp = x + (tan((y + z)) - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -8.6e-14], N[Not[LessEqual[a, 0.0235]], $MachinePrecision]], N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.6 \cdot 10^{-14} \lor \neg \left(a \leq 0.0235\right):\\
\;\;\;\;x - \tan a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -8.59999999999999996e-14 or 0.0235 < a

    1. Initial program 78.1%

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)}} \]
      2. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\left(\color{blue}{\tan z} + x\right) - \frac{\sin a}{\cos a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      3. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\left(\tan z + x\right) - \color{blue}{\tan a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      4. associate--l+60.7%

        \[\leadsto \sqrt[3]{\left(\color{blue}{\left(\tan z + \left(x - \tan a\right)\right)} \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      5. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\left(\color{blue}{\tan z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      6. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\left(\tan z + x\right) - \color{blue}{\tan a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      7. associate--l+60.7%

        \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \color{blue}{\left(\tan z + \left(x - \tan a\right)\right)}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      8. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\left(\color{blue}{\tan z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
      9. tan-quot60.7%

        \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\left(\tan z + x\right) - \color{blue}{\tan a}\right)} \]
    4. Applied egg-rr60.7%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)}} \]
    5. Step-by-step derivation
      1. associate-*l*60.7%

        \[\leadsto \sqrt[3]{\color{blue}{\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right)}} \]
      2. cube-unmult60.7%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\tan z + \left(x - \tan a\right)\right)}^{3}}} \]
      3. associate-+r-60.8%

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

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

        \[\leadsto \sqrt[3]{{\color{blue}{\left(x + \left(\tan z - \tan a\right)\right)}}^{3}} \]
    6. Simplified60.8%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x + \left(\tan z - \tan a\right)\right)}^{3}}} \]
    7. Taylor expanded in z around 0 46.2%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(x - \frac{\sin a}{\cos a}\right)}^{3}}} \]
    8. Step-by-step derivation
      1. rem-cbrt-cube46.3%

        \[\leadsto \color{blue}{x - \frac{\sin a}{\cos a}} \]
      2. tan-quot46.4%

        \[\leadsto x - \color{blue}{\tan a} \]
      3. sub-neg46.4%

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

      \[\leadsto \color{blue}{x + \left(-\tan a\right)} \]
    10. Step-by-step derivation
      1. sub-neg46.4%

        \[\leadsto \color{blue}{x - \tan a} \]
    11. Simplified46.4%

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

    if -8.59999999999999996e-14 < a < 0.0235

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8.6 \cdot 10^{-14} \lor \neg \left(a \leq 0.0235\right):\\ \;\;\;\;x - \tan a\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \]

Alternative 8: 41.5% accurate, 2.0× speedup?

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

\\
x - \tan a
\end{array}
Derivation
  1. Initial program 79.2%

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)}} \]
    2. tan-quot60.0%

      \[\leadsto \sqrt[3]{\left(\left(\left(\color{blue}{\tan z} + x\right) - \frac{\sin a}{\cos a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    3. tan-quot60.0%

      \[\leadsto \sqrt[3]{\left(\left(\left(\tan z + x\right) - \color{blue}{\tan a}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    4. associate--l+60.0%

      \[\leadsto \sqrt[3]{\left(\color{blue}{\left(\tan z + \left(x - \tan a\right)\right)} \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    5. tan-quot60.0%

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

      \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\left(\tan z + x\right) - \color{blue}{\tan a}\right)\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    7. associate--l+60.0%

      \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \color{blue}{\left(\tan z + \left(x - \tan a\right)\right)}\right) \cdot \left(\left(\frac{\sin z}{\cos z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    8. tan-quot60.0%

      \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\left(\color{blue}{\tan z} + x\right) - \frac{\sin a}{\cos a}\right)} \]
    9. tan-quot60.0%

      \[\leadsto \sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\left(\tan z + x\right) - \color{blue}{\tan a}\right)} \]
  4. Applied egg-rr60.0%

    \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)}} \]
  5. Step-by-step derivation
    1. associate-*l*60.0%

      \[\leadsto \sqrt[3]{\color{blue}{\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\left(\tan z + \left(x - \tan a\right)\right) \cdot \left(\tan z + \left(x - \tan a\right)\right)\right)}} \]
    2. cube-unmult60.0%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\tan z + \left(x - \tan a\right)\right)}^{3}}} \]
    3. associate-+r-60.0%

      \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(\tan z + x\right) - \tan a\right)}}^{3}} \]
    4. +-commutative60.0%

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

      \[\leadsto \sqrt[3]{{\color{blue}{\left(x + \left(\tan z - \tan a\right)\right)}}^{3}} \]
  6. Simplified60.0%

    \[\leadsto \color{blue}{\sqrt[3]{{\left(x + \left(\tan z - \tan a\right)\right)}^{3}}} \]
  7. Taylor expanded in z around 0 42.7%

    \[\leadsto \sqrt[3]{\color{blue}{{\left(x - \frac{\sin a}{\cos a}\right)}^{3}}} \]
  8. Step-by-step derivation
    1. rem-cbrt-cube42.9%

      \[\leadsto \color{blue}{x - \frac{\sin a}{\cos a}} \]
    2. tan-quot42.9%

      \[\leadsto x - \color{blue}{\tan a} \]
    3. sub-neg42.9%

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

    \[\leadsto \color{blue}{x + \left(-\tan a\right)} \]
  10. Step-by-step derivation
    1. sub-neg42.9%

      \[\leadsto \color{blue}{x - \tan a} \]
  11. Simplified42.9%

    \[\leadsto \color{blue}{x - \tan a} \]
  12. Final simplification42.9%

    \[\leadsto x - \tan a \]

Alternative 9: 31.7% 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 79.2%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification30.8%

    \[\leadsto x \]

Reproduce

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